8 error_log("Sorry, wrong arguments, need at least the log file name");
16 // first, load the data from the log
17 $fh = fopen($argv[1], "r");
19 // in a way, we're fudging here cause we just add 30 to time all the time
24 while(($line = fgets($fh)) !== false) {
26 $time = ((int)(trim($line)/30))*30;
31 $epl_line = fgets($fh);
33 // parse the line... oh crap
34 $lini = preg_split("/ +/", $epl_line);
35 $ta[$time]["offset"] = trim($lini[8])*1000;
36 $ta[$time]["jitter"] = trim($lini[9])*1000;
45 // create archive 1 - only has 4 hours
48 "--start", "$time_begin",
49 "DS:offset:GAUGE:30:U:U",
50 "DS:jitter:GAUGE:30:U:U",
51 "RRA:AVERAGE:0.5:1:2880"
54 $ret = rrd_create("first_4_hours.rrd", $options);
57 echo "RRD Creation problem: ".rrd_error()."\n";
60 // create archive 1 everything
63 "--start", "$time_begin",
64 "DS:offset:GAUGE:30:U:U",
65 "DS:jitter:GAUGE:30:U:U",
66 "RRA:AVERAGE:0.5:1:2880",
67 "RRA:AVERAGE:0.5:7:2880",
68 "RRA:AVERAGE:0.5:30:2880",
69 "RRA:AVERAGE:0.5:365:2880"
72 $ret = rrd_create("all_data.rrd", $options);
75 echo "RRD Creation problem: ".rrd_error()."\n";
78 $end_time_4 = $time_begin + (3600*$time_lapse_start);
80 foreach($ta as $key => $val) {
82 // first, update all data
83 $off = $val["offset"];
84 $jit = $val["jitter"];
85 $ret = rrd_update("all_data.rrd", array("$key:$off:$jit"));
87 // if we're previous to 4 hours, update 4hours as well
89 if($key < $end_time_4) $ret = rrd_update("first_4_hours.rrd", array("$key:$off:$jit"));
93 // do the first four hour graphs
94 // create first four hours graph of jit
96 "--start","$time_begin",
100 "--end","$end_time_4",
101 "DEF:".$time_lapse_start."hr_jit=first_4_hours.rrd:jitter:AVERAGE",
102 "LINE2:".$time_lapse_start."hr_jit#00FF00"
106 rrd_graph($time_lapse_start."hour_first_jit.png", $options);
108 // create first four hours graph of off
110 "--start","$time_begin",
114 "--end","$end_time_4",
115 "DEF:".$time_lapse_start."hr_jit=first_4_hours.rrd:offset:AVERAGE",
116 "LINE2:".$time_lapse_start."hr_jit#00FF00"
120 rrd_graph($time_lapse_start."hour_first_off.png", $options);
124 $time_last_four = $time_end-(3600*$time_lapse_end);
126 // do the last four hour graphs
127 // create first four hours graph of jit
129 "--start","$time_last_four",
133 "DEF:".$time_lapse_end."hr_jit=all_data.rrd:jitter:AVERAGE",
134 "LINE2:".$time_lapse_end."hr_jit#00FF00"
138 rrd_graph($time_lapse_end."hour_last_jit.png", $options);
140 // create first four hours graph of off
142 "--start","$time_last_four",
146 "DEF:".$time_lapse_end."hr_jit=all_data.rrd:offset:AVERAGE",
147 "LINE2:".$time_lapse_end."hr_jit#00FF00"
151 rrd_graph($time_lapse_end."hour_last_off.png", $options);