my( $host, $service, $color, $start, $time, $sum, $message ) = @_;
if ($service ne 'cpu' ) { return; }
-
+ $time = time;
my( $line, $rawfs, $used, $pct, $name, %namemap, $target );
&main::save_data('>', "$RRDDIR/$host/.rrd-la", "");
if ( $sum =~ m/load\s+=\s+([^,]+),\s+([\d]+)\s+users,\s+(\d+)/ ) {
- ( $load, $users, $jobs ) = ( $1, $2, $3 );
-
+ $users = $2;
+ $jobs = $3;
+ $load = $1;
+ } elsif ( $sum =~ m/(\d+)\s+users\,\s+(\d+)\s+procs\,\s+load=([^,]+)/ ) {
+ $users = $1;
+ $jobs = $2;
+ $load = $3;
+ }
+ $load =~ s/%//;
+
+ if((defined $load) and (defined $jobs) and (defined $users)) {
# If .rrd file not found, built it
if ( ! -f "$RRDDIR/$host/la.rrd" ) {
&debug("$RRDDIR/$host/la.rrd not found creating it",4);
&debug("Updating $host Load Avg rrd file",4);
{ local $SIG{'PIPE'} = 'IGNORE';
local $SIG{'CHLD'} = 'IGNORE';
-
system "$RRDTOOL update $RRDDIR/$host/la.rrd " .
"$time:$load:$users:$jobs";
if ($@) { &error("Error: rrdtool update: $@"); }
}
+ } else {
+ &debug("Type cpu true but not parseable",4);
}
}