--- projects/cms/source/host/generic/statgrab.pl 2001/02/05 17:51:56 1.29 +++ projects/cms/source/host/generic/statgrab.pl 2001/02/05 19:59:35 1.30 @@ -2,8 +2,8 @@ #----------------------------------------------------------------- # Machine statistics grabber -# $Author: pjm2 $ -# $Id: statgrab.pl,v 1.29 2001/02/05 17:51:56 pjm2 Exp $ +# $Author: tdb $ +# $Id: statgrab.pl,v 1.30 2001/02/05 19:59:35 tdb Exp $ # # A Perl script to return various information about a host machine # by examining the output of some common Unix/Linux commands. @@ -21,13 +21,43 @@ $| = 1; # You'd be silly not to use this ;) use strict; -# Paths -my($topbin) = "/usr/local/sbin/top"; -my($dfbin) = "/usr/bin/df"; -my($usersbin) = "/usr/ucb/users"; -my($unamebin) = "/usr/bin/uname"; -my($uptimebin) = "/usr/bin/uptime"; +# Have to hope this will work really. +my($ostype) = `uname -s`; chop($ostype); +# Decide which paths we should use. +my($topbin); my($dfbin); my($usersbin); my($unamebin); my($uptimebin); + +if ($ostype eq "SunOS") { + # covers: Solaris 8 + $topbin = "/usr/local/sbin/top"; + $dfbin = "/usr/bin/df"; + $usersbin = "/usr/ucb/users"; + $unamebin = "/usr/bin/uname"; + $uptimebin = "/usr/bin/uptime"; +} +elsif ($ostype eq "Linux") { + # covers: Debian r2.2 + $topbin = "/usr/bin/top"; + $dfbin = "/bin/df"; + $usersbin = "/usr/bin/users"; + $unamebin = "/bin/uname"; + $uptimebin = "/usr/bin/uptime"; +} +elsif ($ostype eq "FreeBSD") { + # covers: FreeBSD 4.2-STABLE + $topbin = "/usr/bin/top"; + $dfbin = "/bin/df"; + $usersbin = "/usr/bin/users"; + $unamebin = "/usr/bin/uname"; + $uptimebin = "/usr/bin/uptime"; +} +else { + print "statgrab.pl Error: Unable to identify system type - \"$ostype\".\n"; + print "\"uname -s\" does not report one of the following known types;\n"; + print " SunOS, Linux, FreeBSD\n"; + exit(1); +} + # Run the following components: - &print_ident(); &include_osver(); @@ -42,15 +72,11 @@ exit(0); - - - - # prints out an identifier for this version of statgrab.pl # the host should check this when reading data # means the host must be checked and updated to work with newer versions. sub print_ident() { - print 'version statgrab.pl $Revision: 1.29 $'; + print 'version statgrab.pl $Revision: 1.30 $'; print "\n"; }