From: Stephen L Johnson Date: Wed, 29 Mar 2000 03:45:52 +0000 (+0000) Subject: added parsing for bbnt client output X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fspong-2_6_0;p=spong.git added parsing for bbnt client output changed rrdtool update command to use N instead of time stamp from update message. Remote server time varianes can cause data loss --- diff --git a/contrib/plugins/spong-server/data_rrd_la b/contrib/plugins/spong-server/data_rrd_la index 274723c..df3272c 100755 --- a/contrib/plugins/spong-server/data_rrd_la +++ b/contrib/plugins/spong-server/data_rrd_la @@ -19,14 +19,23 @@ sub data_rrd_la { 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); @@ -46,11 +55,12 @@ sub data_rrd_la { &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"; + "N:$load:$users:$jobs"; if ($@) { &error("Error: rrdtool update: $@"); } } + } else { + &debug("Type cpu true but not parseable",4); } }