All pastes #49542 Raw Edit

Anonymous

public text v1 · immutable
#49542 ·published 2006-04-16 23:44 UTC
rendered paste body
$opt = getopt('d');

    
    $fivemin_command = "rrdtool graph /home/sysadmin/rrd/img/{$ip}_fivemin.png --end now --start end-300 --title \"5 minutes network data use for {$ip}\"";
    $tenmin_command = "rrdtool graph /home/sysadmin/rrd/img/{$ip}_tenmin.png --end now --start end-600 --title \"10 minutes network data use for {$ip}\"";
    $hour_command = "rrdtool graph /home/sysadmin/rrd/img/{$ip}_hour.png --end now --start end-3600 --title \"Hourly network data use for {$ip}\"";
    $day_command = "rrdtool graph /home/sysadmin/rrd/img/{$ip}_day.png --end now --start end-86300 --title \"Daily network data use for {$ip}\"";
    $week_command = "rrdtool graph /home/sysadmin/rrd/img/{$ip}_week.png --end now --start end-7d --title \"Weekly network data use for {$ip}\"";
    $month_command = "rrdtool graph /home/sysadmin/rrd/img/{$ip}_month.png --end now --start end-31d --title \"Monthly data use for {$ip}\"";
    $year_command = "rrdtool graph /home/sysadmin/rrd/img/{$ip}_year.png --end now --start end-365d --title \"Yearly data use for {$ip}\"";
    $formatting = "-z --width 500 -v \"Avg Xfer (per sec)\" ";
$lala = 0;
foreach(glob("/home/sysadmin/rrd/data/*.rrd") as $each)
{
$ip = basename($each, '.rrd');
                  $formatting .= "DEF:src{$lala}=/home/sysadmin/rrd/data/{$ip}.rrd:srcdata:AVERAGE " . 
              "VDEF:srcavg=src{$lala},AVERAGE " .
              "VDEF:srcmaxa=src{$lala},MAXIMUM " .
                      "AREA:src{$lala}#0000FF:\"S/Inbound Data Xfer \" " .
              "GPRINT:srcavg:\"Avg\\:%8.2lf %Sbps\"  " .
              "GPRINT:srcmaxa:\"Max\\:%8.2lf %Sbps\\n\" " .
                  "DEF:dst{$lala}=/home/sysadmin/rrd/data/{$ip}.rrd:dstdata:AVERAGE " . 
              "VDEF:dstavg=dst{$lala},AVERAGE " .
              "VDEF:dstmaxa=dst{$lala},MAXIMUM " .
              "LINE1:dst{$lala}#00FF00:\"D/Outbound Data Xfer\" " .
                         "GPRINT:dstavg:\"Avg\\:%8.2lf %Sbps\"  " .
              "GPRINT:dstmaxa:\"Max\\:%8.2lf %Sbps\\n\" ";
$lala++;
}
$formatting .=        "COMMENT:\"Last Updated on\:\" " .
                      "COMMENT:\" ".date("D M j G")."\" " .
                      "COMMENT:\"\:\" " .
                      "COMMENT:\" " . date("i T Y") . "\\n\" " .
                      "COMMENT:\"For more information, please contact us at SentienSystems(.net) .\\n\" ";


    foreach(array('fivemin', 'tenmin', 'hour', 'day', 'week', 'month', 'year') as $time)
    {
        $time_command = $time . "_command";
        $command = $$time_command ." ". $formatting;
        if(isset($opt['d'])) print($command . "\n");
        system("/usr/bin/" . $command . ">/dev/null");
    }
}