Tuesday, January 20, 2015

Using the Linux sar command






What is sar?


The sar command is part of the Linux systat package, which is a collection of tools to help monitor your server's usage statistics.

What can I do with sar data?

The most common thing you can do with the sar command is simply running it by itself, this will provide you with the default view of data that has been logged.

sar

So if you run this command alone:

sar

You'll get output back like this:

This is showing the current day's CPU statistics, which generally isn't going to be too helpful. However sar has a lot of other features built in that can come in very handy
sar -q

When using the -q flag on the sar command, you're presented with the process run queue and server load average, which is much more helpful in spotting possible server bottlenecks.

root@server146 ~]# sar
Linux 2.6.32-042stab093.4 (server146.cladosolutions.com)     01/20/2015     _x86_64_    (2 CPU)

10:14:04 AM       LINUX RESTART

10:20:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
10:30:01 AM     all      2.27      0.00      0.76      0.50      0.00     96.47
10:40:01 AM     all      6.11      0.00      1.34      5.55      0.00     87.00
10:50:01 AM     all      0.23      0.00      0.03      0.07      0.00     99.67
11:00:01 AM     all      0.00      0.00      0.00      0.02      0.00     99.97
11:10:01 AM     all      0.01      0.00      0.01      0.04      0.00     99.95
11:20:01 AM     all      0.01      0.00      0.01      0.04      0.00     99.95
11:30:01 AM     all      0.01      0.17      0.14      1.63      0.00     98.04
11:40:01 AM     all      0.00      0.00      0.01      0.02      0.00     99.97
11:50:01 AM     all      0.01      0.00      0.01      0.04      0.00     99.95
12:00:01 PM     all      0.92      0.00      0.32      0.19      0.00     98.57
12:10:01 PM     all      0.62      0.00      0.18      0.16      0.00     99.04
12:20:01 PM     all      0.76      0.00      0.28      0.16      0.00     98.80
Average:        all      0.91      0.01      0.26      0.70      0.00     98.1


sar -q

When using the -q flag on the sar command, you're presented with the process run queue and server load average, which is much more helpful in spotting possible server bottlenecks.

So if you run this command:

sar -q

You'll get output back like this


[root@server146 ~]# sar -q
Linux 2.6.32-042stab093.4 (server146.cladosolutions.com)     01/20/2015     _x86_64_    (2 CPU)

10:14:04 AM       LINUX RESTART

10:20:01 AM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
10:30:01 AM         0       295      0.22      0.13      0.09
10:40:01 AM         0       261      0.00      0.13      0.14
10:50:01 AM         0       262      0.00      0.01      0.06
11:00:01 AM         0       261      0.00      0.00      0.00
11:10:01 AM         0       262      0.00      0.00      0.00
11:20:01 AM         0       262      0.00      0.00      0.00
11:30:01 AM         0       261      0.00      0.01      0.00
11:40:01 AM         0       261      0.00      0.00      0.00
11:50:01 AM         0       261      0.00      0.00      0.00
12:00:01 PM         0       284      0.00      0.00      0.00
12:10:01 PM         0       293      0.00      0.00      0.00
12:20:01 PM         0       301      0.00      0.00      0.00
Average:            0       272      0.02      0.02      0.02

No comments:

Post a Comment