--- src/sys_agent.pl 2005-11-25 12:11:43.000000000 -0500 +++ ../../sys_agent.pl 2007-12-18 13:55:51.585941000 -0500 @@ -23,6 +23,8 @@ BEGIN{ eval{ require Socket6; import Socket6; $HAVE_S6 = 1; }} verify_access(@ARGV) if @ARGV; +$ENV{'PATH'}='/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin'; + # read request chop($line = ); $line =~ tr/\r//d; @@ -64,9 +66,21 @@ print "$l\n"; close F; }else{ - # QQQ - # the format of uptime varies significantly, I am too lazy - # to write the code at the moment + if( $^O eq 'solaris' ){ + my $ut = output_of_command('uptime'); + my($days,$hours,$minutes) = $ut =~ /up\s(\d+)\s.+,\s+(\d{1,2}):(\d{2}),/; + if(defined($days) && defined($hours) && defined($minutes)){ + #convert into all seconds + my $seconds = ($minutes * 60); + $seconds += ($hours * 3600); + $seconds += ($days * 86400); + print "$seconds\n"; + } + }else{ + # QQQ + # the format of uptime varies significantly, I am too lazy + # to write the code at the moment + } } } @@ -83,6 +97,37 @@ print "$df\n"; } +if( $what eq 'zpool' ){ + my $zpool = output_of_command('zpool', 'status', $arg); + print "$zpool\n"; +} + +if( $what eq 'smart' ){ + my $smart = output_of_command('smartctl', '-H', $arg); + $smart =~ s/.*SMART (?:Health Status|overall-health[^:]+):\s([^\n]+)\n.*/$1/s; + print "$smart\n"; +} + +if( $what eq 'metastat' ){ + my $metastat = output_of_command('metastat', $arg); + if($metastat =~ /^${arg}/){ + unless($metastat =~ /\s+(?:State|Status): [^(?:Okay)]/){ + print "OK\n"; + } + } +} + +if( $what eq 'filecount' ){ + my($dir,$pattern) = split /\s+/, $arg, 2; + if(opendir(DIR, $dir)){ + my $files = grep {/$pattern/} readdir DIR; + closedir DIR; + print "$files\n"; + }else{ + print "error opendir [$arg]: $!\n"; + } +} + if( $what eq 'netstat' ){ # arg: interface [in|out] # extremely non-portable