From 3015e560eed7f25c176adb07191651e7c1be7db9 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Sun, 15 Sep 2013 05:29:16 +1000 Subject: [PATCH] make graphs via php --- src/graphit/create_data.sh | 11 ++- src/graphit/make_graphs.php | 149 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 src/graphit/make_graphs.php diff --git a/src/graphit/create_data.sh b/src/graphit/create_data.sh index 46d6543..1547156 100755 --- a/src/graphit/create_data.sh +++ b/src/graphit/create_data.sh @@ -10,23 +10,26 @@ fi rm -f data.rrd -START_TIME=`head -1 $INPUT` +START_TIME_A=`head -1 $INPUT` +START_TIME=`echo $START_TIME_A-10|bc` echo "Createing rrd archive" rrdtool create data.rrd --step 30 \ --start $START_TIME \ DS:offset:GAUGE:30:U:U \ DS:jitter:GAUGE:30:U:U \ -RRA:AVERAGE:0.5:1:480 \ RRA:AVERAGE:0.5:1:2880 \ RRA:AVERAGE:0.5:7:2880 \ RRA:AVERAGE:0.5:30:2880 \ RRA:AVERAGE:0.5:365:2880 +TIME=`echo "$START_TIME+30"|bc` +#END_TIME=`echo "$START_TIME cat $INPUT | while read line do - TIME="$line" + #TIME="$line" + TIME=`echo "$TIME+30"|bc` read line2 OFFSET=`echo $line2 |awk '{ print $9 }'` JITTER=`echo $line2 |awk '{ print $10 }'` @@ -38,7 +41,7 @@ done END_4HR=`echo $START_TIME+14400|bc` rrdtool graph 4hr_off.png --start $START_TIME \ - -w 600 -h 300 \ + -w 600 -h 300 -l -1 \ --end $END_4HR \ DEF:4hr_jit=data.rrd:jitter:AVERAGE \ LINE2:4hr_jit#00FF00 diff --git a/src/graphit/make_graphs.php b/src/graphit/make_graphs.php new file mode 100644 index 0000000..74c5208 --- /dev/null +++ b/src/graphit/make_graphs.php @@ -0,0 +1,149 @@ + $val) { + + // first, update all data + $off = $val["offset"]; + $jit = $val["jitter"]; + $ret = rrd_update("all_data.rrd", array("$key:$off:$jit")); + + // if we're previous to 4 hours, update 4hours as well + + if($key < $end_time_4) $ret = rrd_update("first_4_hours.rrd", array("$key:$off:$jit")); +} + + +// do the first four hour graphs +// create first four hours graph of jit +$options = array( +"--start","$time_begin", +"-w","600", +"-h","300", +"-l","-1", +"--end","$end_time_4", +"DEF:4hr_jit=first_4_hours.rrd:jitter:AVERAGE", +"LINE2:4hr_jit#00FF00" +); + +// graph of jit +rrd_graph("4hour_first_jit.png", $options); + +// create first four hours graph of off +$options = array( +"--start","$time_begin", +"-w","600", +"-h","300", +"-l","-1", +"--end","$end_time_4", +"DEF:4hr_jit=first_4_hours.rrd:offset:AVERAGE", +"LINE2:4hr_jit#00FF00" +); + +// graph of offset +rrd_graph("4hour_first_off.png", $options); + + + +$time_last_four = $time_end-(3600*4); + +// do the last four hour graphs +// create first four hours graph of jit +$options = array( +"--start","$time_last_four", +"-w","600", +"-h","300", +"--end","$time_end", +"DEF:4hr_jit=all_data.rrd:jitter:AVERAGE", +"LINE2:4hr_jit#00FF00" +); + +// graph of jit +rrd_graph("4hour_last_jit.png", $options); + +// create first four hours graph of off +$options = array( +"--start","$time_last_four", +"-w","600", +"-h","300", +"--end","$time_end", +"DEF:4hr_jit=all_data.rrd:offset:AVERAGE", +"LINE2:4hr_jit#00FF00" +); + +// graph of offset +rrd_graph("4hour_last_off.png", $options); +?> -- 1.7.0.4