APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

sysstat (iostat,mpstat,sar) and maybe u386mon


© March 2005 Tony Lawrence
2005/03/16

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.

When I mention this to Linux folk, the first reaction is usually "What do I need that for? It's all in /proc!". Well, that's not really the point.

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..

CPU usage from u386mon

The u386mon is like "top", with multiple pages showing network statistics, kernel and memory statistics and a dynamic display of highest cpu using processes.

Interestingly, there are multiple references in Google talking about porting u386mon to Linux, but I can't find where anyone acutally has.

I did find source at SCO (but no SCO binary).

Apparently the port was attempted by Warren Tucker - see the note at the very bottom of this "panel" man page.


Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> sysstat (iostat,mpstat,sar) and maybe u386mon


Inexpensive and informative Apple related e-books:

Take Control of iCloud

Take Control of the Mac Command Line with Terminal, Second Edition

Take Control of Parallels Desktop 12

iOS 10: A Take Control Crash Course

Take Control of Pages




More Articles by © Tony Lawrence




Printer Friendly Version

Have you tried Searching this site?

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.

Contact us


Printer Friendly Version





All of science is nothing more than the refinement of everyday thinking. (Albert Einstein)




Linux posts

Troubleshooting posts


This post tagged:

Linux

Performance

Unix



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode