To be honest, I would use Monit for this. It's available from RPMForge via yum for your particular version of Linux.
Monit is a tool for monitoring processes and daemons. Usually this is done via PID, but you can also match on a process string. Since VMWare Server process strings end in a "vm_name.vmx" specification, you can set Monit to check against that string. The only example of a VMWare Server 1.0.x system I have handy has ONE VM running, but as long as you know the names of the *.vmx files, you can list them independently in the monit config file.
Here's the output of monit procmatch vmx
:
[root@abc ~]# monit procmatch vmx
List of processes matching pattern "vmx":
------------------------------------------
/usr/lib/vmware/bin/vmware-vmx -# product=2;name=VMware Server;version=2.0.1;buildnumber=156745;licensename=VMware GSX Server for Linux;licenseversion=3.0 build-156745; -@ pipe=/tmp/vmhsdaemon-0/vmx226abb1efa53200b;readyEvent=52 /vmware/abc_Web/abc_Web.vmx
------------------------------------------
Total matches: 1
Adding a small VMWare check entry to the monit config file (create and entry for each unique VM you need to monitor)...
check process vmware
matching "vmware-vmx"
This shows the status of what's being monitored.
[root@abc ~]# monit status
Process 'vmware-vmx'
status running
monitoring status monitored
pid 25171
parent pid 1
uptime 992d 8h 5m
children 0
memory kilobytes 1107796
memory kilobytes total 1107796
memory percent 18.1%
memory percent total 18.1%
cpu percent 0.0%
cpu percent total 0.0%
data collected Thu Apr 26 04:49:12 2012
Then, there's a web interface to control processes at http://servername:2812
A bit further in the top
man page there is:
If a process is in the "SLEEP" or "LOCK" state, the state column will
report the name of the event or lock on which the process is waiting.
Lock names are prefixed with an asterisk "*" while sleep events are
not
So basically, all the non-capital "STATE", non prefixed with an asterisk are sleep events name.
These label are set in FreeBSD kernel, so this is where you should go to find their meaning.
Sadly there is no nice summary as the event name is set by the sleep
calls.
For instance, somewhere in /usr/src/sys/kern/sys_pipe.c
in the pipe_read
function:
error = msleep(rpipe, PIPE_MTX(rpipe), PRIBIO | PCATCH, "piperd", 0);
Or in /usr/src/sys/kern/sys_pipe.c
in the kern_nanosleep
function:
error = tsleep(&nanowait, PWAIT | PCATCH, "nanslp", tvtohz(&tv));
Best Answer
Because top doesn't provide this (no references), obviously you will need to use
ps
in your scripts.HTH