what is the best way to determine system OS?

Mike Meyer mwm at mired.org
Tue Apr 26 06:13:01 EDT 2005


Roel Schroeven <rschroev_nospam_ml at fastmail.fm> writes:

> googleboy wrote:
>
>> What this script does is use take the output of vmstat to report idle
>> cpu cycles (or memory stuff, etc.) over a period specified by a
>> parameter,  all the better to be a plugin for a monitoring service.
>> Basically it parses the output of the command,  runs through a whole
>> bunch of regex to discard everything not required and then reports the
>> info.  Everything I had checked out that responded "Linux" to a uname
>> command had identical output for vmstat until FC3.   FC3 seems to use
>> similar output to BSD.   I wrote a simple if-then loop to try to
>> determine which regex function to use, but it obivously isn't working
>> under fc3.
>
> In that case, it seems to be a better idea to check the version of
> vmstat that's on the system. At least, I presume that such differences
> in behaviour can be deduced from the vmstat version string.

Hmm. That doesn't seem to work here:

guru% vmstat --version
vmstat: illegal option -- -
usage: vmstat [-aimsz] [-c count] [-M core [-N system]] [-w wait]
              [-n devs] [disks]
guru% what $(which vmstat)
/usr/bin/vmstat:
	 Copyright (c) 1980, 1986, 1991, 1993

The man page doesn't turn up any information on how to extract a
version for vmstat, either.

vmstat isn't a very unixish program. It's output clearly wasn't
designed to be used as input to other programs.

         <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list