2005/03/16 sysstat (iostat,mpstat,sar)

The sysstat package is a set of tools that those of us from the Unix world sorely missed on Linux.

Most missed was sar. A few years back, SCO had released sar so that it could be ported to Linux, but the initial work was slow and lacked many features. I'm glad to see that's all changed.


Hate these ads?

The value of sar (for those not familiar with it) is that it collects statistics through cron (the sysstat rpm automatically installs a "sysstat" job in /etc/cron.d for this). You can examine the results at your leisure, but more importantly this means that you can see what "normal" performance looks like for your system, which is critically important in diagnosing sudden problems.

Without any flags, sar reports cpu usage:



07:00:00 AM       CPU     %user     %nice   %system   %iowait     %idle
07:10:00 AM       all      0.27      0.00      0.14      0.06     99.53
07:20:00 AM       all      1.22      0.00      1.58      0.41     96.80
07:30:00 AM       all      0.14      0.00      0.09      0.00     99.76
07:40:00 AM       all      0.30      0.00      0.39      0.19     99.11


A neat feature of sar I wasn't aware of is the ability to run it against a specific process id:



# sar -x 29801  5 50



07:03:12 AM       PID  minflt/s  majflt/s     %user   %system   nswap/s   CPU
07:03:17 AM     29801      0.00      0.00      0.00      0.00      0.00     0
07:03:22 AM     29801      1.60      0.00      0.20      0.00      0.00     0
07:03:27 AM     29801      1.60      0.00      0.00      0.20      0.00     0
07:03:32 AM     29801      1.40      0.00      0.20      0.00      0.00     0







Many other reports are available; see the man page. Through a "sa2" script (enabled in the sysstat crontab), daily ASCII versions of full sar reports are produced in the /var/log/sa directory.

The iostat command concentrates on i/o:



avg-cpu:  %user   %nice    %sys %iowait   %idle
           0.73    0.06    0.83    1.56   96.82



Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
hdd               3.28       100.00         1.95   50382778     981856
hdd1              0.00         0.00         0.00         16          0
hdd2              0.00         0.00         0.00        112          0
hdd3              3.28       100.00         1.95   50382330     981856
hda               8.83       379.38        24.96  191146538   12574646
hda1              0.00         0.21         0.00     107528       1534
hda2              8.80       379.04        24.74  190971418   12464952
hda3              0.02         0.13         0.21      67272     108160


You can specify a particular device also:



iostat /dev/hda



avg-cpu:  %user   %nice    %sys %iowait   %idle
           0.73    0.06    0.83    1.56   96.82



Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
hda               8.82       379.22        24.95  191146538   12578110


On more recent kernels, "iostat -x" displays even more information. Finally, "mpstat", shows cpu specific data and can report on multiple cpu's if present:



09:04:35 AM  CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
09:04:35 AM  all    0.73    0.06    0.76    1.56    0.06    0.00   96.82    122.40


Of course with any of these, understanding the information presented is the hard part. The man pages are short on details, and even if you track some of these to their source, it can still be difficult to understand what a particular statistic implies about the state of your system and what, if anything, you should do about it. So much to learn, so little time..



Comments /Words2005/2005_03_16.html


Add your comments

Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner


ad

Views for this page
Today This Week This Month This Year  Overall
2287858 6,742

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

pavatar.jpg
More:
       - Performance
       - Linux
       - Unix




Unix/Linux Consultants

Your ad here - $24.00 yearly!

http://www.schewanick.com SCO Unix, Solaris, Linx (various), PHP, MySQL, Apache, uniBasic, dL4, Perl, System Administration and more....


http://bcstechnology.net Full service Linux & UNIX systems integrator; Windows to UNIX/Linux Client-Server Specialist; Secure E-Mail & Website Hosting; Thoroughbred Software Developer; Custom Industrial Automation; Hardware & Electronics Experts; In Business Since 1985.


http://www.vss3.com SCO/Caldera OpenServer, Unixware & Linux. Tarantella & Non-stop Clustering









Change Congress

Related Posts