]> git.etc.gen.nz Git - spong.git/commitdiff
moved file to spong-rrd CVS
authorStephen L Johnson <sjohnson@monsters.org>
Thu, 17 Jan 2002 16:06:51 +0000 (16:06 +0000)
committerStephen L Johnson <sjohnson@monsters.org>
Thu, 17 Jan 2002 16:06:51 +0000 (16:06 +0000)
contrib/plugins/spong-server/post_rrd_vmstat [deleted file]

diff --git a/contrib/plugins/spong-server/post_rrd_vmstat b/contrib/plugins/spong-server/post_rrd_vmstat
deleted file mode 100644 (file)
index 4bc34ed..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-# Register routine with plugin registery
-$POSTFUNCS{'rrd_vmstat'} = \&post_rrd_vmstat;
-
-# Take the vmstat status message and create rrd databases for a lot of 
-# interesting stats
-
-# RRA to be created for each RRD
-# "daily" 5min avg last 48hr
-# "weekly" 30min avg last 12days
-# "monthly 2hr avg last 48days
-# "yearly" 24hr avg last 576days
-$RRAS = "RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:576 RRA:AVERAGE:0.5:24:576 " . 
-        "RRA:AVERAGE:0.5:288:576";
-
-$RRAS = "RRA:AVERAGE:0.5:1:52560"; # detailed 5 minute data for 365 days
-
-$RRDTOOL = "/usr/local/rrdtool/bin/rrdtool";
-$RRDDIR  = "/usr/local/spong-test/var/rrd";
-
-sub post_rrd_vmstat {
-   my( $msg ) = @_;
-
-   my $host = $msg->{'host'};
-
-   # If message is not a status vmstat message, ignore it
-   if ( $msg->{'cmd'} ne 'status' || $msg->{'service'} ne 'vmstat') {
-      return;
-   }
-
-   # Touch the file for vmstat This will also create the dir if needed.
-   &main::save_data('>', "$RRDDIR/$host/.rrd-vmstat", "");
-
-   my $time = time;
-
-   my( $proc_run, $proc_block, $proc_swap, $swpd, $free, $buff, $cache,
-       $si, $so, $bi, $bo, $cs, $cpu_us, $cpu_sy, $cpu_id, $mem_free );
-
-   # Begin parsing the message field for vmstat values
-   {
-       local $\ = '';  # ignore \n's for grep'ing the message
-       
-       $mem_free = $1 if  $msg->{'message'} =~ /mem_free =\s+([\d.]+)/;
-       $proc_run = $1 if  $msg->{'message'} =~ /proc_run =\s+([\d.]+)/;
-       $proc_block = $1 if  $msg->{'message'} =~ /proc_block =\s+([\d.]+)/;
-       $si = $1         if  $msg->{'message'} =~ /si =\s+([\d.]+)/;
-       $so = $1         if  $msg->{'message'} =~ /so =\s+([\d.]+)/;
-       $pi = $1         if  $msg->{'message'} =~ /pi =\s+([\d.]+)/;
-       $po = $1         if  $msg->{'message'} =~ /po =\s+([\d.]+)/;
-       $cs = $1         if  $msg->{'message'} =~ /cs =\s+([\d.]+)/;
-       $cpu_us = $1     if  $msg->{'message'} =~ /cpu_us =\s+([\d.]+)/;
-       $cpu_sy = $1     if  $msg->{'message'} =~ /cpu_sy =\s+([\d.]+)/;
-       $cpu_id = $1     if  $msg->{'message'} =~ /cpu_id =\s+([\d.]+)/;
-   }
-
-   # If .rrd file not found, built it
-   if ( ! -f "$RRDDIR/$host/vmstat.rrd" ) {
-     &debug("$RRDDIR/$host/vmstat.rrd not found creating it",4);
-     {  local $SIG{'PIPE'} = 'IGNORE';
-        local $SIG{'CHLD'} = 'IGNORE';
-
-        eval {
-           system "$RRDTOOL create $RRDDIR/$host/vmstat.rrd " . 
-                  "DS:mem_free:GAUGE:600:0:U " .
-                  "DS:proc_run:GAUGE:600:0:U " .
-                  "DS:proc_block:GAUGE:600:0:U " .
-                  "DS:swap_in:GAUGE:600:0:U " .
-                  "DS:swap_out:GAUGE:600:0:U " .
-                  "DS:page_in:GAUGE:600:0:U " .
-                  "DS:page_out:GAUGE:600:0:U " .
-                  "DS:cxt_switch:GAUGE:600:0:U " .
-                  "DS:cpu_user:GAUGE:600:0:100 " .
-                  "DS:cpu_sys:GAUGE:600:0:100 " .
-                  "DS:cpu_idle:GAUGE:600:0:100 " .
-                  $RRAS ; 
-        };
-      }
-      if (@?) { &error("Error: rrdtool create: $@"); }
-   }
-
-   # Update the .rrd file
-   &debug("Updating $host vmstat rrd file",4);
-   {  local $SIG{'PIPE'} = 'IGNORE';
-      local $SIG{'CHLD'} = 'IGNORE';
-      system "$RRDTOOL update $RRDDIR/$host/vmstat.rrd " .
-             "$time:$mem_free:$proc_run:$proc_block:$si:$so:$pi:$po:" .
-             "$cs:$cpu_us:$cpu_sy:$cpu_id";
-      if ($@) { &error("Error: rrdtool update: $@"); }
-   }
-
-}
-
-# I'm include perl code, I need this line.
-1;
-