# This routine checks the 5min CPU load avg from the uptime comand. This
# check also return a status of warning if the uptime is less then 1 hour.
-# $Id: check_cpu,v 1.3 2001/09/28 19:16:59 sljohnson Exp $
+# $Id: check_cpu,v 1.4 2005/09/13 14:09:24 willamowius Exp $
use Spong::SafeExec qw(safe_exec);
my $color = "green";
my $uptime = safe_exec($UPTIME,30);
my( $message, $jobs );
+ my $LINES = 0;
my $s = 'up\s+([^\,]+)\,.*\s(\d+) user.+?' .
'[0-9\.]+\,\s*([0-9\.]+)\,\s*([0-9\.]+)\s*$';
my( $up, $users, $load ) = ( $uptime =~ /$s/ );
my @msg = safe_exec($PS,30);
- for ( 0..10 ) { $message .= $msg[$_] };
+ $LINES = ($#msg - 1) if ($LINES <= 0);
+ for ( 0..$LINES ) { $message .= $msg[$_] };
$jobs = $#msg; # num of jobs is 1 less number of entries in @msg
# Check to see if the system has only been up a short time, and if it has