change graph a bit
[wyse_ntpd.git] / src / graphit / make_graphs.php
index 74c5208..575fccf 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+$time_lapse_start = 3;
+$time_lapse_end = 24;
+
 if(isset($argc)) {
        if($argc!=2) {
                error_log("Sorry, wrong arguments, need at least the log file name");
@@ -29,8 +32,8 @@ while(($line = fgets($fh)) !== false) {
 
        // parse the line... oh crap
        $lini = preg_split("/ +/", $epl_line);
-       $ta[$time]["offset"] = trim($lini[8]);
-       $ta[$time]["jitter"] = trim($lini[9]);
+       $ta[$time]["offset"] = trim($lini[8])*1000;
+       $ta[$time]["jitter"] = trim($lini[9])*1000;
 
        $time_end = $time;
 
@@ -72,7 +75,7 @@ if(!$ret) {
        echo "RRD Creation problem: ".rrd_error()."\n";
 }
 
-$end_time_4 = $time_begin + (3600*4);
+$end_time_4 = $time_begin + (3600*$time_lapse_start);
 
 foreach($ta as $key => $val) {
 
@@ -95,30 +98,30 @@ $options = array(
 "-h","300",
 "-l","-1",
 "--end","$end_time_4",
-"DEF:4hr_jit=first_4_hours.rrd:jitter:AVERAGE",
-"LINE2:4hr_jit#00FF00"
+"DEF:".$time_lapse_start."hr_jit=first_4_hours.rrd:jitter:AVERAGE",
+"LINE2:".$time_lapse_start."hr_jit#00FF00"
 );
 
 // graph of jit
-rrd_graph("4hour_first_jit.png", $options);
+rrd_graph($time_lapse_start."hour_first_jit.png", $options);
 
 // create first four hours graph of off
 $options = array(
 "--start","$time_begin",
 "-w","600",
 "-h","300",
-"-l","-1",
+"-l","-1000",
 "--end","$end_time_4",
-"DEF:4hr_jit=first_4_hours.rrd:offset:AVERAGE",
-"LINE2:4hr_jit#00FF00"
+"DEF:".$time_lapse_start."hr_jit=first_4_hours.rrd:offset:AVERAGE",
+"LINE2:".$time_lapse_start."hr_jit#00FF00"
 );
 
 // graph of offset
-rrd_graph("4hour_first_off.png", $options);
+rrd_graph($time_lapse_start."hour_first_off.png", $options);
 
 
 
-$time_last_four = $time_end-(3600*4);
+$time_last_four = $time_end-(3600*$time_lapse_end);
 
 // do the last four hour graphs
 // create first four hours graph of jit
@@ -127,12 +130,12 @@ $options = array(
 "-w","600",
 "-h","300",
 "--end","$time_end",
-"DEF:4hr_jit=all_data.rrd:jitter:AVERAGE",
-"LINE2:4hr_jit#00FF00"
+"DEF:".$time_lapse_end."hr_jit=all_data.rrd:jitter:AVERAGE",
+"LINE2:".$time_lapse_end."hr_jit#00FF00"
 );
 
 // graph of jit
-rrd_graph("4hour_last_jit.png", $options);
+rrd_graph($time_lapse_end."hour_last_jit.png", $options);
 
 // create first four hours graph of off
 $options = array(
@@ -140,10 +143,10 @@ $options = array(
 "-w","600",
 "-h","300",
 "--end","$time_end",
-"DEF:4hr_jit=all_data.rrd:offset:AVERAGE",
-"LINE2:4hr_jit#00FF00"
+"DEF:".$time_lapse_end."hr_jit=all_data.rrd:offset:AVERAGE",
+"LINE2:".$time_lapse_end."hr_jit#00FF00"
 );
 
 // graph of offset
-rrd_graph("4hour_last_off.png", $options);
+rrd_graph($time_lapse_end."hour_last_off.png", $options);
 ?>