Warning: include(/homepages/10/d653673895/htdocs/clickandbuilds/Tutarticle/wp-includes/wp-session-manager.php): failed to open stream: Permission denied in /homepages/10/d653673895/htdocs/clickandbuilds/Tutarticle/wp-load.php on line 1

Warning: include(): Failed opening 'wp-includes/wp-session-manager.php' for inclusion (include_path='.:/usr/lib/php7.0') in /homepages/10/d653673895/htdocs/clickandbuilds/Tutarticle/wp-load.php on line 1
Checking System Resources with sar | Tutarticle

Checking System Resources with sar

The System Activity Reporter (sar) is one of the oldest system monitoring facilities created for early UNIX systems—predating Linux by a few decades. The sar command itself can display system activity continuously, at set intervals (every second or two), and display it on the screen. It can also display system activity data that was gathered earlier.The sar command is part of the sysstat package. By installing sysstat and enabling the sysstat service, your system immediately begins gathering system activity data that can be reviewed later using certain options to the sar command. The data gathering is done by a crontab configuration fi le (/etc/cron.d/sysstat) that is launched at regular intervals. Look at what that file contains:

# cat /etc/cron.d/sysstat

# Run system activity accounting tool every 10 minutes

*/10 * * * * root /usr/lib64/sa/sa1 1 1

# 0 * * * * root /usr/lib64/sa/sa1 600 6 &

# Generate a daily summary of process accounting at 23:53

53 23 * * * root /usr/lib64/sa/sa2 -A

 

The first uncommented line runs the sa1 1 1 command every 10 minutes. This sa1 command gathers a range of system activity information just once (one time after waiting 1 second) and copies it to the /var/log/sa/sa?? file, where ?? is replaced by the current day. The sa2 -A command gathers all data gathered to this point in the day (at 11:23 p.m.) and places that in the /var/log/sa/sar?? file, where ?? is replaced by the current day.

To read the data in the sa?? and sar?? files, you can use some of the following sar commands:

# sar -u | less

Linux 3.10.0-123.el7.x86_64 (rhel7-01) 4/16/2017 _x86_64_ (4 CPU)

12:00:01 AM CPU %user %nice %system %iowait %steal %idle

12:10:01 AM all 6.48 0.00 0.82 0.59 0.00 92.12

12:20:01 AM all 6.50 0.00 0.78 0.82 0.00 91.91

The -u option shows CPU usage. By default, the output starts at midnight on the current day and then shows how much processing time is being consumed by different parts of the system. The output continues to show the activity every 10 minutes until the current time is reached. To see disk activity output, run the sar -d command. Again, output comes in 10-minute intervals starting at midnight.

# sar -d | less

Linux 3.10.0-123.el7.x86_64 (rhel7-01) 4/16/2017 _x86_64_ (4 CPU)

12:00:01 AM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz …

12:10:01 AM dev8-0 1.39 0.24 18.49 13.44 0.04 …

12:10:01 AM dev253- 02.59 0.24 18.49 7.24 0.04 …

If you want to run sar activity reports live, you can do that by adding counts and time intervals to the command line. For example:

# sar -n DEV 5 2

Linux 3.10.0-123.el7.x86_64 (rhel7-01) 4/16/2017 _x86_64_ (4 CPU)

11:19:36 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s…

11:19:41 PM lo 5.42 5.42 1.06 1.06 0.00 0.00…

11:19:41 PM eth0 0.00 0.00 0.00 0.00 0.00 0.00…

11:19:41 PM wlan0 1.00 1.00 0.10 0.12 0.00 0.00…

11:19:41 PM pan0 0.00 0.00 0.00 0.00 0.00 0.00…

11:19:41 PM tun0 0.00 0.00 0.00 0.00 0.00 0.00…

Average: IFACE rxpck/s txpck/s rxkB/s txkB/ rxcmp/s txcmp/s rxmcst/s

Average: lo 7.21 7.21 1.42 1.42 0.00 0.00 0.00

Average: eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00

Average: wlan0 4.70 4.00 4.81 0.63 0.00 0.00 0.00

Average: pan0 0.00 0.00 0.00 0.00 0.00 0.00 0.00

Average: tun0 3.70 2.90 4.42 0.19 0.00 0.00 0.00

With the -n Dev example just shown, you can see how much activity came across the different network interfaces on your system. You can see how many packets were transmitted and received and how many KB of data were transmitted and received. In that example, samplings of data were taken every 5 seconds and repeated twice. Refer to the sar, sadc, sa1, and sa2 man pages for more information on how sar data can be gathered and displayed.

Leave a reply:

Your email address will not be published.

Site Footer