The utility package sysstat provides several tools for resource monitoring on GNU / Linux.
One such tool is the sar. It shows data from various system counters in real time or data collected through the progam sadc, which is run by the sa1 and sa2 scripts running in cron.
Keep the history of the use of resources is an important step in the analysis of performance of the servers. Show here as the sar can help in this task.
1. Installing the package sysstat
1.1 CentOS 5.7
yum install sysstat After installation, the data are already being collected.
1.1.1 Add IO statistics Detailed disk by editing the following file:
vi / etc / cron.d / sysstat 1.1.2 Add the-d option in the script sa1:
* / 10 **** root / usr/lib64/sa/sa1-d 1 1 These statistics tend to occupy a larger space on disk and also generate a higher overhead because we are monitoring the disks and using them to record the information generated. Therefore, it is recommended to use this option only if you need to drill down capabilities for disk and partition. Otherwise, the sar already provides general statistics IO, summarizing the use of all disks.
1.1.3 Adjusting the time history for one month (31 days), sequinte editing the file:
vi / etc / sysconfig / sysstat Change the value of the variable HISTORY, as follows:
HISTORY = 31 CentOS in the reports are stored in:
/ Var / log / sa / sa DD Where "DD" is the day of the month.
Checking the version:
# Sar-V sysstat version 7.0.2 (C) Sebastien Godard
1.2 Debian 6.0
apt-get install sysstat By default, the collection of data is not enabled in Debian. To activate it, run the following command, and select Yes:
dpkg-reconfigure sysstat 1.2.1 Add IO statistics Detailed disk by editing the following file:
vi / etc / default / sysstat Modify the option to script sa1:
SA1_OPTIONS = "S-XDISK" This option has the same effect as the-d option used on CentOS, however on Debian 6.0 version of sysstat package is newer, so the change.
Debian already keeps history for a month, which is the maximum supported.
Reports are stored in:
/ Var / log / sysstat / sa DD Where "DD" is the day of the month.
Checking the version:
# Sar-V sysstat version 9.0.6.1 (C) Sebastien Godard (sysstat <at> orange.fr)
2. Displaying statistics collected
Once collected, the data can be read / extracted using the sar command. Here are some common options display. The outputs of the commands are cut presenting data only for illustration purposes.
The meaning of each column can be found in the man page for sar , but some columns will destacas most common presentation of commands.
2.1 Displaying CPU statistics
sar-u ... 10:49:54 CPU% user% nice% system% iowait% steal% idle 10:50:01 all 0.28 0.07 0.23 0.03 0.00 99.39 10:50:54 all 0.68 0.03 0.21 0.18 0.00 98.89 10:51:54 all 0.59 0.03 0.17 0.07 0.00 99.13 10:52:54 all 0.77 0.03 0.17 0.11 0.00 98.92 10:53:54 all 1.39 0.04 0.19 0.28 0.00 98.11 10:54:54 all 1.74 0.03 0.26 0.42 0.00 97.56 Average: all 1.40 0.03 0.55 1.23 0.00 96.78
Note that the last line shows the average of the data displayed.
2.2 General statistics IO (discs)
sar-b ... 10:49:54 tps rtPS WTPs bread / s bwrtn / s 10:56:54 148.40 60.47 87.93 1079.20 2670.47 10:57:54 102.95 13.60 89.35 251.78 2687.08 10:58:54 53.33 20.98 32.35 345.24 1793.73 10:59:54 46.53 18.40 28.13 351.47 1651.03 11:00:01 12.84 7.46 5.37 119.40 387.46 11:00:54 72.90 18.92 53.98 457.96 2344.41 11:01:54 127.03 42.67 84.37 737.07 2965.30 11:02:54 127.04 41.18 85.86 874.16 2313.10 Average: 333.73 269.65 64.08 36793.14 17341.19
These disk statistics are generated by default in Debian as well on CentOS. The values shown are for the use of all disks added.
The first data column shows the values of TPS (transfers per second), which represents the total number of data transfers per second, in units of 512 bytes. This value is also known as IOPS (Input / Output Operations Per Second), an extremely important in determining bottleneck on the disks.
A first step in determining a possible bottleneck would calculate the Nominal IOPS of disk arrays. Then compare the values of tps (general and detailed) reported by sar to get an idea how the current load of the disks. Values greater than the calculated IOPS are possible due to the data cache, by both the operating system and the controller. Constant values near the nominal IOPS can indicate serious problems bottleneck on the disks.
This is only one of the points to be considered. The performance analysis servers are several aspects that need to be taken into consideration. How to proceed in such cases is a subject too complex and leave for an upcoming article.
2.3 Detailed statistics IO (discs)
sar-dp 11:01:54 DEV tps rd_sec / s wr_sec / s avgrq avgqu-sz-sz await svctm% util 11:03:54 sda 12.44 53.61 683.40 59.27 0.03 2.16 1.26 1.57 11:03:54 sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 11:03:54 sda2 7.22 0.00 439.41 60.88 0.01 1.37 0.12 0.09 11:03:54 sda3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 11:03:54 sda4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 11:03:54 sda5 0.48 0.00 215.24 445.24 0.00 4.34 0.52 0.03 11:03:54 sda6 4.73 53.61 28.75 17.40 0.01 3.13 3.08 1.46 11:03:54 sdb 29.17 440.87 115.95 19.09 0.08 2.62 2.19 6.38 11:03:54 sdb1 29.17 440.87 115.95 19.09 0.08 2.62 2.19 6.38 Average: sda 69.05 12076.35 8321.86 295.41 0.91 13.22 1.69 11.68 Average: sda1 0.00 0.62 0.00 157.26 0.00 1.65 1.61 0.00 Average: sda2 8.24 140.96 360.38 60.82 0.02 2.25 0.78 0.64 Average: sda3 0.00 0.04 0.02 27.20 0.00 4.51 3.71 0.00 Average: sda4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Average: sda5 0.80 0.01 459.13 574.34 0.02 22.38 0.85 0.07 Average: sda6 60.00 11934.73 7502.34 323.94 0.88 14.61 1.86 11.17 Average: sdb 97.63 6293.25 336.87 67.91 0.36 3.67 1.59 15.55 Average: sdb1 97.63 6293.25 336.87 67.91 0.36 3.67 1.59 15.55
These statistics are not generated by default. You need to activate them, as shown earlier.
The-p option shows the names of disk devices.
As we can see, here we have the tps per disk and partition, as well as requests for read and write (rd_sec / s, wr_sec / s). It is easier now to identify a disk or partition with IO bottleneck.
2.4 Network Statistics
sar-n DEV ... 11:05:54 IFACE rxpck / s txpck / s rxbyt / s txbyt / s rxcmp / s txcmp / s rxmcst / s It 11:05:54 66.12 66.12 27142.28 27142.28 0.00 0.00 0.00 11:05:54 eth0 337.11 347.18 62816.76 184603.47 0.00 0.00 0.00 Eth1 11:05:54 54.83 129.91 5027.33 173077.71 0.00 0.00 0.00 Average: lo 45.80 45.80 16683.79 16683.79 0.00 0.00 0.00 Average: eth0 2111.12 4084.43 186005.46 5746933.35 0.00 0.00 0.00 Average: eth1 17.24 31.50 1864.39 40021.03 0.00 0.00 0.00
2.5 Statistics Memory
sar-r ... 10:49:54 kbmemfree kbmemused% memused kbbuffers kbcached kbswpfree kbswpused% swpused kbswpcad 11:15:54 675540 98321864 99.32 102264 86246792 5242484 2728 0.05 100 11:16:54 1061092 97936312 98.93 102324 86276892 5242484 2728 0, 05 100 11:17:54 1031768 97965636 98.96 102544 86303576 5242484 2728 0.05 100 11:18:54 940476 98056928 99.05 102616 86347000 5242484 2728 0.05 100 Average: 764861 98232543 99.23 59250 93499185 5242198 3014 0 , 06 74
2.6 Paging memory
sar-B 10:49:54 pgpgin / s pgpgout / s fault / s majflt / s 11:17:54 347.66 728.97 5979.53 0.00 11:18:54 617.81 428.28 12143.55 0.00 11:19:54 376.93 347.18 13665.98 0.00 11:20:01 182.79 175.07 4677.30 0.00 Average: 8975.72 4241.81 6346.00 0.01
2.7 Display Options
In addition to the data collected, the sar has the option to display real-time data. The following required parameters:
sar-u 1 10 The first parameter is the time, the second parameter is a counter. In the example the CPU data are displayed in 1 second intervals for a total of 10 times.
When running sar, it always displays the values of the current day. The-f option identifies a day (file) specific month:
sar-f / var/log/sa/sa10 And the-s option determines an initial time:
sar-s 23:00:00 Combining the two, we obtain values closer to the time of interest:
sar-f / var/log/sa/sa10 23:55:00-s-u 23:55:48 CPU% user% nice% system% iowait% steal% idle 23:56:48 all 1.79 0.03 1.12 2.19 0.00 94.87 23:57:48 all 3.22 0.03 1.24 0.92 0.00 94.58 23:58:48 all 2.82 0.03 1.43 1.50 0.00 94.21 23:59:48 all 3.33 0.03 1.09 0.81 0.00 94.74 Average: all 2.79 0.03 1.22 1.36 0.00 94.60
Any of the above can be applied to the above example, allowing filtering by date and time of any data collected. Recalling that the data are stored for up to one month.
The files with the data collected can be copied to another location, thus increasing the time available for consultation history.
References:
Main site of the project:
http://sebastien.godard.pagesperso-orange.fr
Additional Information:
http://www.thegeekstuff.com/2011/03/sar-examples/
http://sys-log.bencane.com/2012/07/sar-sysstat-linux-performance-statistics-with-ease/

