| Tips about monitor/analyse performance in Linux |
|
|
|
| News - Ubuntu / Linux / Unix |
| Written by Mark Veenstra |
| Monday, 25 April 2011 10:07 |
|
In this article I am going to discuss some commands of Linux about how to analyse the performance of a Linux system. The commands I am going to use are: sar, top, pcacct, netstat, lsof, iostat and vmstat. I will discuss some usefull parameters of these commands and how to read the output of these commands. Hopefully these commands will help you to find what is causes your system to have a lack of performance. Feel free to comment on this article if you have some other usefull tips.
SAR The first command I would like to discuss is 'sar'. Sar stands for System Activity Registration and is standard installed on all Linux/Unix systems. If sar isn't installed on your system you can install it using your package manager, in CentOS it will be 'yum install sysstat'. Sar will show you the use of resources of a system, adding parameters to sar will show you the resources of the selected 'hardware'. With sar you can also view the use of resources from the past, default it will show you the use of resources of the current day (starting from midnight). By default sar holds data from the past 8 days. During office hours the data files of sar will be filled every 20 minutes with data and outside the office hours every hour. These statistic counters for sar are filled bij a cron into a logfile. By default these logfiles are named '/var/adm/sa/saXX' on Unix and '/var/log/sa/saXX' on Linux', replace 'XX' with the day of the month. Now the basics are known let us go through a few parameters of sar: Kind of hardware: processor(s) Kind of hardware: disk(s) NETSTAT Network delays are difficult to analyse, normally this is something for specialists, but with netstat you can get some information from several protocols since boot time. The information shown will not give you information about network delays it can also be the case that the receiving side has a processor that is running at 100% or it is swapping memory, but it gives you an indication about what is going on over the network. Let us go through a few usefull parameters: Command to execute: netstat -i Command to execute: netstat -s Command to execute: netstat -n | grep 8022 | grep ESTABLISHED | wc –l LSOF If you found a TCP or UDP port in the output of your netstat command that looks weird to you or you want to find out which process is using this port you can use the command lsof. This will display the process that is using that port. Also lsof can do a lot more things. Look into the manpage of lsof for further options. For example. You saw with 'netstat -a' that there is a IPP port in use on your system. You can find out which port is using this process with the command: lsof -i @<hostname>:631 PSACCT / ACCTON / ACCT If you would like to monitor performance from a process point of view you need to get into 'psacct'. I am not going to discuss it here, but I will give some links to a website where you can get some more information: http://www.cyberciti.biz/faq/linux-unix-bsd-varaccountpacct-or-varlogaccountpacct-file/ VMSTAT / IOSTAT The command vmstat gives you information about processes, memory, paging, block IO, traps, and cpu activity. The command iostat reports Central Processing Unit (CPU) statistics and input/output statistics for devices, partitions and network filesystems (NFS). For these commands I also refer you to this website: http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html |
| Last Updated on Monday, 25 April 2011 10:40 |




Click here to hear this article
Comments
Seriously, I tried to harvest the best ideas from all of them, and there ARE a lot of great concepts. Over the past 10 years collectl has grown in functionality and whenever I find something it can't do, I try to add it. It had become very popular in the world of High Performance Computing for monitoring some of the most demanding systems in the world.
One thing I including in the documentation is a cheat-sheet of sorts that maps collectl commands to existing tools. While it's only a subset of what collectl can do it might help give you some perspective of just how broad its functionality is.
-mark
You need to insert "-d" to the follwing lines in /usr/lib64/sa/sa1 (or /usr/lib/sa/sa1) on a 32 bit system
exec ${ENDIR}/sadc -d -F -L 1 1 -
exec ${ENDIR}/sadc -d -F -L $* -
You also need to remove/archive the current day database file /var/log/sa/sa28 (