$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)\" "; foreach(glob("/home/sysadmin/rrd/data/*.rrd") as $each) { $ip = basename($each, '.rrd'); $formatting .= "DEF:src=/home/sysadmin/rrd/data/{$ip}.rrd:srcdata:AVERAGE " . "VDEF:srcavg=src,AVERAGE " . "VDEF:srcmaxa=src,MAXIMUM " . "AREA:src#0000FF:\"S/Inbound Data Xfer \" " . "GPRINT:srcavg:\"Avg\\:%8.2lf %Sbps\" " . "GPRINT:srcmaxa:\"Max\\:%8.2lf %Sbps\\n\" " . "DEF:dst=/home/sysadmin/rrd/data/{$ip}.rrd:dstdata:AVERAGE " . "VDEF:dstavg=dst,AVERAGE " . "VDEF:dstmaxa=dst,MAXIMUM " . "LINE1:dst#00FF00:\"D/Outbound Data Xfer\" " . "GPRINT:dstavg:\"Avg\\:%8.2lf %Sbps\" " . "GPRINT:dstmaxa:\"Max\\:%8.2lf %Sbps\\n\" "; } $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"); } }