[comp.unix.programmer] Question about rstat

troyt@Autodesk.COM (Troy Taylor - Network Dude) (05/25/91)

I'm trying put together a small utility that will check cpu 
status of remote Sun servers. It seems like the rstat() utility 
will do the job, except I'm not too sure how to interpret the info...

Here's a sample output from a rstat() call to a Sun 4/490 running 4.1;

cp_time_0 51130
cp_time_1 1412
cp_time_2 48213
cp_time_3 573995
dk_xfer_0 14656
dk_xfer_1 29071
dk_xfer_2 0
dk_xfer_3 0
v_pgpgin 12406
v_pgpgout 2397
v_pswpin 0
v_pswpout 8
v_intr 197020
if_ipackets 99010
if_ierrors 34
if_opackets 55593
if_oerrors 0
if_collisions 76
v_swtch 294918
boottime.tv_sec 675094263
boottime.tv_usec 580000
curtime.tv_sec 675107758
curtime.tv_usec 590009
avenrun_0 94
avenrun_1 33
avenrun_2 4

Now what?? Seems like the data is coming out ok. I get changing values for
each call, but I'm just not too sure how to get a percentage of CPU used 
using the data given...

Any ideas??


--
---------------------------------------------------------------------------
Troy R. Taylor				                 troyt@Autodesk.com 
							        or
			       {fernwood,apple,decwrl,uunet}!autodesk!troyt

mycroft@kropotki.gnu.ai.mit.edu (Charles Hannum) (05/28/91)

In article <5110@autodesk.COM> troyt@Autodesk.COM (Troy Taylor - Network Dude) writes:

   I'm trying put together a small utility that will check cpu 
   status of remote Sun servers. It seems like the rstat() utility 
   will do the job, except I'm not too sure how to interpret the info...

If that's really all you want, then it looks like you want:

CPU - user     cp_time_0 51130
CPU - nice     cp_time_1 1412
CPU - system   cp_time_2 48213
CPU - idle     cp_time_3 573995

There may be more than four CPU states on your machine, in which case these
will not add up to the total picture.