How To use sar tool  to monitor system performance in ParrotOs 3.9

To use sar tool  in ParrotOs 3.9

sar is part of sysstat package. sar tool is used to monitor the performance of various Linux subsystems. It collects performance data and stores them. This tutorial explains how to monitor the Linux system performance using sar tool. 

 

Using sar tool

First, you need to install  sysstat  which is essential for this installation process. 

┌─[root@linuxhelp]─[~]
└──╼ #apt-get install sysstat
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Suggested packages:
  isag
The following packages will be upgraded:
  sysstat
1 upgraded, 0 newly installed, 0 to remove and 1332 not upgraded.
Need to get 390 kB of archives.
After this operation, 15.4 kB of additional disk space will be used.
Get:1 http://parrot.asis.io stable/main amd64 sysstat amd64 11.6.1-1 [390 kB]
Fetched 390 kB in 4s (83.7 kB/s)
Preconfiguring packages ...
(Reading database ... 419795 files and directories currently installed.)
Preparing to unpack .../sysstat_11.6.1-1_amd64.deb ...
Unpacking sysstat (11.6.1-1) over (11.6.0-1) ...
Setting up sysstat (11.6.1-1) ...
Installing new version of config file /etc/sysstat/sysstat ...
Processing triggers for doc-base (0.10.7) ...
Processing 1 changed doc-base file...
Registering documents with scrollkeeper...
Processing triggers for systemd (235-2) ...
Processing triggers for man-db (2.7.6.1-2) ...
Configuring sandbox profiles....
Sandbox profile

 

 

To check the version of sar, you need to run the sar command with -v option. 

┌──[root@linuxhelp]─[~]
└──╼ #sar -V
sysstat version 11.6.0
(C) Sebastien Godard (sysstat < at>  orange.fr)

 

Option -q is used with sar to display the total no of processes, queue length and load average of your system, with some time interval. 

┌─[root@linuxhelp]─[~]
└──╼ #sar -q 2 5
Linux 4.13.0-parrot4-amd64 (linuxhelp)                 Friday 12 January 2018   _x86_64_            (2 CPU)

03:43:06  IST   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15   blocked
03:43:08  IST         1       272      0.01      0.02      0.02         0
03:43:10  IST         0       272      0.01      0.02      0.02         0
03:43:12  IST         0       272      0.01      0.02      0.02         0
03:43:14  IST         0       272      0.01      0.02      0.02         0
03:43:16  IST         0       272      0.01      0.02      0.02         0
Average:            0       272      0.01      0.02      0.02         0

 

In order to view the network statistics, you need to run the following command. 

┌─[root@linuxhelp]─[~]
└──╼ #sar -n DEV 1 1
Linux 4.13.0-parrot4-amd64 (linuxhelp)                 Friday 12 January 2018   _x86_64_            (2 CPU)

03:51:04  IST     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
03:51:05  IST        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:51:05  IST      eth0     10.00      0.00      0.59      0.00      0.00      0.00      0.00      0.05

Average:        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
Average:           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:         eth0     10.00      0.00      0.59      0.00      0.00      0.00      0.00      0.05

 

In order to exclude any particular network device, make sure you run the following command. 

┌─[root@linuxhelp]─[~]
└──╼ #sar -n DEV 1 1 | egrep -v eth0
Linux 4.13.0-parrot4-amd64 (linuxhelp)                 Friday 12 January 2018   _x86_64_            (2 CPU)

03:44:00  IST     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
03:44:01  IST        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
Average:           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

 

To know the disk statics of your system with some time delay and line  counts, then use option &ndash d with sar command.

┌─[root@linuxhelp]─[~]
└──╼ #sar -d 1 2
Linux 4.13.0-parrot4-amd64 (linuxhelp)                 Friday 12 January 2018   _x86_64_            (2 CPU)

03:55:33  IST       DEV       tps     rkB/s     wkB/s   areq-sz    aqu-sz     await     svctm     %util
03:55:34  IST    dev8-0      2.00      0.00     12.00      6.00      0.00      0.00      0.00      0.00

03:55:34  IST       DEV       tps     rkB/s     wkB/s   areq-sz    aqu-sz     await     svctm     %util
03:55:35  IST    dev8-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:          DEV       tps     rkB/s     wkB/s   areq-sz    aqu-sz     await     svctm     %util
Average:       dev8-0      1.00      0.00      6.00      6.00      0.00      0.00      0.00      0.00

 

 

To view the memory statics of your system with some delay and line counts, run the following command. 

┌─[root@linuxhelp]─[~]
└──╼ #sar -r 1 3
Linux 4.13.0-parrot4-amd64 (linuxhelp)                 Friday 12 January 2018   _x86_64_            (2 CPU)

03:57:35  IST kbmemfree   kbavail kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
03:57:36  IST     81392    220316    852152     91.28     35480    215688   2335840     80.93    370684    300868         0
03:57:37  IST     81360    220284    852184     91.28     35480    215688   2335840     80.93    370684    300868         0
03:57:38  IST     81416    220340    852128     91.28     35480    215688   2335840     80.93    370684    300868         0
Average:        81389    220313    852155     91.28     35480    215688   2335840     80.93    370684    300868         0

To display only CPU statistic of your system

 

If you want to display only CPU statistic of your system with some time delay and line counts use option &ndash u with sar command.

┌─[root@linuxhelp]─[~]
└──╼ #sar -u 1 3
Linux 4.13.0-parrot4-amd64 (linuxhelp)                 Friday 12 January 2018   _x86_64_            (2 CPU)

03:58:45  IST     CPU     %user     %nice   %system   %iowait    %steal     %idle
03:58:46  IST     all      1.52      0.00      0.51      0.00      0.00     97.98
03:58:47  IST     all      2.53      0.00      1.01      0.00      0.00     96.46
03:58:48  IST     all      2.02      0.00      1.52      0.00      0.00     96.46
Average:        all      2.02      0.00      1.01      0.00      0.00     96.97

 

If you want to check the specific CPU usage of your system, use &ndash P with your processor name. In the below command, ALL option will list all CPU statistic of your system. Suppose in your machine, if you have three CPU core by default then your first system number starts with 0 and 2nd CPU number is 1 and remaining CPU number followed by the series.

┌─[root@linuxhelp]─[~]
└──╼ #sar -P ALL 1 1
Linux 4.13.0-parrot4-amd64 (linuxhelp)                 Friday 12 January 2018   _x86_64_            (2 CPU)

04:00:38  IST     CPU     %user     %nice   %system   %iowait    %steal     %idle
04:00:39  IST     all      0.00      0.00      1.01      0.00      0.00     98.99
04:00:39  IST       0      0.00      0.00      1.01      0.00      0.00     98.99
04:00:39  IST       1      0.00      0.00      1.00      0.00      0.00     99.00

Average:        CPU     %user     %nice   %system   %iowait    %steal     %idle
Average:        all      0.00      0.00      1.01      0.00      0.00     98.99
Average:          0      0.00      0.00      1.01      0.00      0.00     98.99
Average:          1      0.00      0.00      1.00      0.00      0.00     99.00

 

If you want to know your swap memory statistic report then use option -S it swap memory statistic, suppose in your output “ kbswpfree” and “ swpused” in 0 state means your system is not booting.

 

┌─[root@linuxhelp]─[~]
└──╼ #sar -S 1 1
Linux 4.13.0-parrot4-amd64 (linuxhelp)                 Friday 12 January 2018   _x86_64_            (2 CPU)

04:02:17  IST kbswpfree kbswpused  %swpused  kbswpcad   %swpcad
04:02:18  IST   1945584      7180      0.37      1708     23.79
Average:      1945584      7180      0.37      1708     23.79

 

If you want to know the input and output statistic of your CPU with some time delay and no of counts, then use option &ndash b.

┌─[root@linuxhelp]─[~]
└──╼ #sar -b 1 3
Linux 4.13.0-parrot4-amd64 (www.linuxhelp1.com)             Friday 12 January 2018          _x86_64_        (2 CPU)
Linux 4.13.0-parrot4-amd64 (linuxhelp)        Friday 12 January 2018          _x86_64_        (2 CPU)
09:54:58 PM       tps      rtps      wtps   bread/s   bwrtn/s
09:54:59 PM      2.04      0.00      2.04      0.00     89.80
09:55:00 PM      0.00      0.00      0.00      0.00      0.00
Average:            1.02      0.00      1.02      0.00     44.90

 

tps &ndash Transactions per second (this includes both read and write)
rtps &ndash Read transactions per second
wtps &ndash Write transactions per second
bread/s &ndash Bytes read per second
bwrtn/s &ndash Bytes written per second

 

Using -w,  the total number of processes created per second, and total number of context switches per second, with some time delay and line counts, can be checked. 

┌─[root@linuxhelp]─[~]
└──╼ #sar -w 1 3
Linux 4.13.0-parrot4-amd64 (linuxhelp)        Friday 12 January 2018          _x86_64_        (2 CPU)

04:05:15  IST    proc/s   cswch/s
04:05:16  IST      0.00    276.00
04:05:17  IST      0.00    191.00
04:05:18  IST      0.00    212.00
Average:         0.00    226.33

Collect, report, or save system activity information.

Tag : Parrot OS SAR
FAQ
Q
How to print the RAM usage report using the "sar" command in Linux?
A
Use the option of "-r" with "sar" command to print the RAM usage report using the "sar" command in Linux. For syntax: "sar -r".
Q
How can I get the "swap" memory usage report using the "sar" command in Linux?
A
You can use the option of "-S" with " sar" command to get the "swap" memory usage report using the "sar" command in Linux. For syntax: "sar -S".
Q
how to install and use sar on centos?
A
use the following link, https://www.linuxhelp.com/monitor-linux-system-performance-using-sar-tool/
Q
Can you give me the link to get "SAR" package for OpenSUSE?
A
Use the following link to get SAR" package for OpenSUSE as "https://software.opensuse.org/package/sysstat".
Q
How to install "SAR" command in Ubuntu?
A
You can use the command to install "SAR" command in Ubuntu. For syntax: "apt-get install sysstat".