--- projects/cms/source/host/generic/statgrab.pl 2001/01/28 19:50:15 1.14 +++ projects/cms/source/host/generic/statgrab.pl 2001/01/29 12:21:18 1.17 @@ -2,8 +2,8 @@ #----------------------------------------------------------------- # Machine statistics grabber -# $Author: pjm2 $ -# $Id: statgrab.pl,v 1.14 2001/01/28 19:50:15 pjm2 Exp $ +# $Author: tdb $ +# $Id: statgrab.pl,v 1.17 2001/01/29 12:21:18 tdb Exp $ # # A Perl script to return various information about a host machine # by examining the output of some common Unix/Linux commands. @@ -26,10 +26,12 @@ 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"; # Run the following components: - &print_ident(); &include_osver(); +&include_uptime(); &include_users(); &include_top(); &include_disk(); @@ -48,7 +50,7 @@ exit(0); # 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.14 $'; + print 'version statgrab.pl $Revision: 1.17 $'; print "\n"; } @@ -107,7 +109,8 @@ sub include_users() { # Find out all users on this machine. my($users) = `$usersbin`; - chop($users); + $users = "\n" unless defined $users; + chop $users; my($users_count) = 0; $users_count++ while $users =~ /\w+/g; my($users_list) = $users; @@ -184,5 +187,15 @@ sub include_osver() { &print_pair(0, "packet.os.platform", $os_platform); &print_pair(0, "packet.os.sysname", $os_sysname); &print_pair(0, "packet.os.version", $os_version); + +} + +# sub to get system uptime. +sub include_uptime() { + + # Need a regexp guru to strip the junk on this line + my($uptime) = `$uptimebin`; + + &print_pair(0, "packet.os.uptime", $uptime); -} +} \ No newline at end of file