5 error_log("Sorry, wrong arguments, need at least the log file name");
13 // first, load the data from the log
14 $fh = fopen($argv[1], "r");
16 // in a way, we're fudging here cause we just add 30 to time all the time
21 while(($line = fgets($fh)) !== false) {
23 $time = ((int)(trim($line)/30))*30;
28 $epl_line = fgets($fh);
30 // parse the line... oh crap
31 $lini = preg_split("/ +/", $epl_line);
32 $ta[$time]["offset"] = trim($lini[8]);
33 $ta[$time]["jitter"] = trim($lini[9]);
42 // create archive 1 - only has 4 hours
45 "--start", "$time_begin",
46 "DS:offset:GAUGE:30:U:U",
47 "DS:jitter:GAUGE:30:U:U",
48 "RRA:AVERAGE:0.5:1:2880"
51 $ret = rrd_create("first_4_hours.rrd", $options);
54 echo "RRD Creation problem: ".rrd_error()."\n";
57 // create archive 1 everything
60 "--start", "$time_begin",
61 "DS:offset:GAUGE:30:U:U",
62 "DS:jitter:GAUGE:30:U:U",
63 "RRA:AVERAGE:0.5:1:2880",
64 "RRA:AVERAGE:0.5:7:2880",
65 "RRA:AVERAGE:0.5:30:2880",
66 "RRA:AVERAGE:0.5:365:2880"
69 $ret = rrd_create("all_data.rrd", $options);
72 echo "RRD Creation problem: ".rrd_error()."\n";
75 $end_time_4 = $time_begin + (3600*4);
77 foreach($ta as $key => $val) {
79 // first, update all data
80 $off = $val["offset"];
81 $jit = $val["jitter"];
82 $ret = rrd_update("all_data.rrd", array("$key:$off:$jit"));
84 // if we're previous to 4 hours, update 4hours as well
86 if($key < $end_time_4) $ret = rrd_update("first_4_hours.rrd", array("$key:$off:$jit"));
90 // do the first four hour graphs
91 // create first four hours graph of jit
93 "--start","$time_begin",
97 "--end","$end_time_4",
98 "DEF:4hr_jit=first_4_hours.rrd:jitter:AVERAGE",
99 "LINE2:4hr_jit#00FF00"
103 rrd_graph("4hour_first_jit.png", $options);
105 // create first four hours graph of off
107 "--start","$time_begin",
111 "--end","$end_time_4",
112 "DEF:4hr_jit=first_4_hours.rrd:offset:AVERAGE",
113 "LINE2:4hr_jit#00FF00"
117 rrd_graph("4hour_first_off.png", $options);
121 $time_last_four = $time_end-(3600*4);
123 // do the last four hour graphs
124 // create first four hours graph of jit
126 "--start","$time_last_four",
130 "DEF:4hr_jit=all_data.rrd:jitter:AVERAGE",
131 "LINE2:4hr_jit#00FF00"
135 rrd_graph("4hour_last_jit.png", $options);
137 // create first four hours graph of off
139 "--start","$time_last_four",
143 "DEF:4hr_jit=all_data.rrd:offset:AVERAGE",
144 "LINE2:4hr_jit#00FF00"
148 rrd_graph("4hour_last_off.png", $options);