--- ../nisca-2.2/report.phtml Tue Feb 26 07:04:19 2002 +++ report.phtml Tue Feb 26 06:40:54 2002 @@ -72,7 +72,7 @@ global $X, $Y, $cnt_stamps, $ttf_font, $bitbyte, $in_out, $graph_background, $graph_text, $graph_border_light, $graph_border_dark, $graph_peak_highlight, $graph_incoming_data, $graph_outgoing_data, - $dateformat, $dformat, $tformat; + $dateformat, $dformat, $tformat, $flubber, $map; $img=imagecreate($X, $Y); if (eregi("i", $in_out)) { $do_in="y"; } else { unset($do_in); } @@ -168,18 +168,18 @@ $more_mod=1; if ($bitbyte=="b" && ($gtype=="bits" || $gtype=="bytes")) { $more_mod=8; } // If the Y values are greater than 1 gig, show results in gig. - if ($data_max >= 1024*1024*1024/$more_mod) { - $modifier = 1024*1024*1024; + if ($data_max >= 1000000000/$more_mod) { + $modifier = 1000000000; $mod_disp="G"; } // If the Y values are greater than 1 meg, show results in meg. - elseif ($data_max >= 1024*1024/$more_mod) { - $modifier = 1024*1024; + elseif ($data_max >= 1000000/$more_mod) { + $modifier = 1000000; $mod_disp="M"; } // If the Y values are greater than 1K, show results in K. - elseif ($data_max >= 1024/$more_mod) { - $modifier = 1024; + elseif ($data_max >= 1000/$more_mod) { + $modifier = 1000; $mod_disp="K"; } @@ -241,6 +241,7 @@ } // Draw the X-axis gridlines and labels: + $map="\n"; $j=0; $xgrid = $num_xpixels / 11; $xstep = $num_xpixels / ($numpoints-2); @@ -256,9 +257,33 @@ imagettftext ($img, 9, 0, $x0 + $pix - 24, $y1 + 31, $TEXTCOLOR, $ttf_font, $datelabel2); } imagedashedline ($img, $x0 + $pix, $y0, $x0 + $pix, $y1 + 7, $LBORDERCOLOR); +// Do the flubber. + if ($prev_i) { + $fx0=(integer)($x0+($xgrid * ($j-1))); + $fy0=$y0; + $fx1=(integer)($x0+$pix); + $fy1=$y1+7; + $flubber["f_month"]=(integer)date("n", $prev_i); + $flubber["f_day"]=(integer)date("j", $prev_i); + $flubber["f_year"]=(integer)date("Y", $prev_i); + $flubber["f_hour"]=(integer)date("G", $prev_i); + $flubber["f_min"]=(integer)date("i", $prev_i); + $flubber["f_sec"]=(integer)date("s", $prev_i); + $flubber["t_month"]=(integer)date("n", $i); + $flubber["t_day"]=(integer)date("j", $i); + $flubber["t_year"]=(integer)date("Y", $i); + $flubber["t_hour"]=(integer)date("G", $i); + $flubber["t_min"]=(integer)date("i", $i); + $flubber["t_sec"]=(integer)date("s", $i); + $querystring="report.phtml?flubber=" . urlencode(serialize($flubber)); + $map .= " \n"; + } + $prev_i=$i; $j++; } + $map .= "\n"; + $timerange=$stamp_max-$stamp_min; $xpct = $num_xpixels / $timerange; $ypct = $yceil * $modifier; @@ -353,6 +378,15 @@ $errtxt=""; +if ($flubber) { +// it will contain f_month, etc. + $tmp=unserialize(ss(urldecode($flubber))); + $flubber=$tmp; + foreach(array_keys($flubber) as $k) { + $$k=$flubber[$k]; // heheh... tricky. + } +} + if ($report == "" && count($hostif) < 1) { $errtxt .= "You have to pick at least one hostname/interface to do a report on.
\n"; } @@ -437,13 +471,13 @@ Rather a lot, isn't it? :) */ -$graph_background=strtoupper($g_bg); -$graph_text=strtoupper($g_text); -$graph_border_light=strtoupper($g_lborder); -$graph_border_dark=strtoupper($g_dborder); -$graph_peak_highlight=strtoupper($g_peak); -$graph_incoming_data=strtoupper($g_in); -$graph_outgoing_data=strtoupper($g_out); +if ($g_bg) { $graph_background=strtoupper($g_bg); } +if ($g_text) { $graph_text=strtoupper($g_text); } +if ($g_lborder) { $graph_border_light=strtoupper($g_lborder); } +if ($g_dborder) { $graph_border_dark=strtoupper($g_dborder); } +if ($g_peak) { $graph_peak_highlight=strtoupper($g_peak); } +if ($g_in) { $graph_incoming_data=strtoupper($g_in); } +if ($g_out) { $graph_outgoing_data=strtoupper($g_out); } if ($rpt_name != "" && $report == "") { $sq="select id from reports where name='$rpt_name'"; @@ -483,6 +517,18 @@ $random_msgs .= "Generated from saved report \"$rname\".
"; } +// we have to make this *after* the report options are loaded, if any. +// f_month, etc will be added by makegraph(). +// $timeperiod will always be "set_dates". +$flubber=array("hostif"=>$hostif, "bytes"=>$bytes, "packets"=>$packets, "errors"=>$errors, + "dropped"=>$dropped, "reportctl"=>$reportctl, "in_out"=>$in_out, "g_fmt"=>$g_fmt, + "multiple"=>$multiple, "avginterval"=>$avginterval, "timeperiod"=>"set_dates", + "graph_x"=>$graph_x, "graph_y"=>$graph_y, "summ_interval"=>$summ_interval, + "summ_units"=>$summ_units, "graph_background"=>$graph_background, "graph_text"=>$graph_text, + "graph_border_light"=>$graph_border_light, "graph_border_dark"=>$graph_border_dark, + "graph_peak_highlight"=>$graph_peak_highlight, "graph_incoming_data"=>$graph_incoming_data, + "graph_outgoing_data"=>$graph_outgoing_data); + // Now let's do some report generatin'... $start_stopwatch=getmicrotime(); @@ -838,7 +884,9 @@ echo "Couldn't create image file "bytes_$xtime.png"... probably write permissions.
\n"; } } - echo "

$font2Total average $reptype per second:

\n

\n"; + $tmp=preg_replace('/%%%MAPNAME%%%/', "bytes_$xtime", $map); + echo "$tmp\n

$font2Total average $reptype per second:

\n" . + "

\n"; } unset($cnt_stamps, $cnt_rbytes, $cnt_tbytes); } @@ -1125,7 +1173,10 @@ echo "Couldn't create image file "bytes_$xtime.png"... probably write permissions.
\n"; } } - echo "

$font2Average $reptype per second transferred on $hostal->$ifal:

\n

\n"; + $tmp=preg_replace('/%%%MAPNAME%%%/', "bytes_$xtime", $map); + echo "$tmp\n

$font2Average $reptype per second transferred on $hostal->$ifal:

\n" . + "

\n"; + } if ($packets != "") { if ($g_fmt=="j") { @@ -1137,7 +1188,9 @@ echo "Couldn't create image file "packets_$xtime.png"... probably write permissions.
\n"; } } - echo "

$font2Average packets per second transferred on $hostal->$ifal:

\n

\n"; + $tmp=preg_replace('/%%%MAPNAME%%%/', "packets_$xtime", $map); + echo "

$font2Average packets per second transferred on $hostal->$ifal:

\n" . + "

\n"; } if ($errors != "") { if ($g_fmt=="j") { @@ -1149,7 +1202,9 @@ echo "Couldn't create image file "errors_$xtime.png"... probably write permissions.
\n"; } } - echo "

$font2Average errors per second on $hostal->$ifal:

\n

\n"; + $tmp=preg_replace('/%%%MAPNAME%%%/', "errors_$xtime", $map); + echo "

$font2Average errors per second on $hostal->$ifal:

\n" . + "

\n"; } if ($dropped != "") { if ($g_fmt=="j") { @@ -1161,7 +1216,9 @@ echo "Couldn't create image file "dropped_$xtime.png"... probably write permissions.
\n"; } } - echo "

$font2Average dropped Packets per second on $hostal->$ifal:

\n

\n"; + $tmp=preg_replace('/%%%MAPNAME%%%/', "dropped_$xtime", $map); + echo "

$font2Average dropped Packets per second on $hostal->$ifal:

\n" . + "

\n"; } }