Index: trunk/flowmon-web/config.inc.php =================================================================== --- trunk/flowmon-web/config.inc.php (revision 4) +++ trunk/flowmon-web/config.inc.php (revision 1) @@ -13,4 +13,5 @@ # Date formatstring $date_fmt_str = '%Y-%m-%d %T+%Z'; +$date_fmt = ('Y-m-d T'); # Chart Styles we support Index: trunk/flowmon-web/charts/proto-dist.inc.php =================================================================== --- trunk/flowmon-web/charts/proto-dist.inc.php (revision 4) +++ trunk/flowmon-web/charts/proto-dist.inc.php (revision 1) @@ -16,4 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Copyright 2004, 2005 Red Hat, Inc. +# +# AUTHOR: Andreas Thienemann # Index: trunk/flowmon-web/charts/top-src.inc.php =================================================================== --- trunk/flowmon-web/charts/top-src.inc.php (revision 4) +++ trunk/flowmon-web/charts/top-src.inc.php (revision 1) @@ -21,10 +21,15 @@ # -require_once('stacked-bars.inc.php'); +require_once('phplot-5.0.5/phplot.php'); // Get the data from the table, format it and write it out to a file -function chart_prepare($flowsrc, $starttime, $endtime, $nslookup = False) { +function chart_prepare($flowsrc, $starttime, $endtime, $timeframe = False) { global $date_fmt_str; global $dbh; + + if ($timeframe != False) { + $starttime = (time() - $timeframe); + $endtime = time(); + } // Define the plot properties @@ -32,4 +37,7 @@ $chart_title = $style.' '.$flowsrc.' - '.strftime($date_fmt_str, $starttime).' to '.strftime($date_fmt_str, $endtime); $ytitle = 'Bytes'; + $output = tempnam('tmp/', 'plot'); + $data_colors = array('SkyBlue', 'green', 'orange', 'blue', 'purple', 'red', 'violet', 'azure1', 'yellow', 'DarkGreen'); + // Grab the data from the database @@ -47,103 +55,125 @@ $q->execute(); - // Did this return anything at all? - if ($q->rowCount() == 0) { - // No - print('No data for query-period'); - return False; - } else { - // Yes? Carry on! + // Fill the legend build the WHERE limit + $legend = $q->fetchAll(PDO::FETCH_COLUMN, 0); + $limit = ''; + for ($i = 0; $i < count($legend); $i++) { + $limit .= @$legend[$i].', '; + if (array_key_exists($i, $legend)) { + $legend[$i] = long2ip($legend[$i]); + } else { + $legend[$i] = ''; + } + } + $legend[] = 'rest'; + $limit = substr($limit, 0, (strlen($limit) - 2)); - // Fill the legend build the WHERE limit - $legend = $q->fetchAll(PDO::FETCH_COLUMN, 0); - $limit = ''; - for ($i = 0; $i < count($legend); $i++) { - $limit .= @$legend[$i].', '; - if (array_key_exists($i, $legend)) { - $legend[$i] = long2ip($legend[$i]); - } else { - $legend[$i] = ''; - } - } - $legend[] = 'rest'; - $limit = substr($limit, 0, (strlen($limit) - 2)); - - // divide the timespan into 5min intervals - // query the traffic per talker in 5min intervals - // Initialize the data_table - $data = array(); - $steps = 0; - $rest_table = array(); - for ($time1 = $starttime; $time1 < $endtime; $time1 += (5 * 60)) { - $time2 = ($time1 + (5 * 60)); - $steps++; - // Add the column header (time) to the data array - $data[] = array(strftime('%H:%M', $time1)); - $q = $dbh->prepare('SELECT IPSrc, SUM(Bytes) AS TrafficSum - FROM Flows - WHERE TimeStop BETWEEN ? AND ? - AND IPSrc IN ('.$limit.') - AND FlowSrc = ? - GROUP BY IPSrc - ORDER BY TrafficSum DESC - LIMIT 0, 9'); - $q->bindParam(1, $time1, PDO::PARAM_INT); - $q->bindParam(2, $time2, PDO::PARAM_INT); - $q->bindParam(3, sprintf('%u', ip2long($flowsrc)), PDO::PARAM_INT); - $q->execute(); - $r = $q->fetchAll(); - $i = (count($data) - 1); - foreach ($r as $row) { - $tmpdata[$i][$row[0]] = $row[1]; - } - - // Get the rest of the aggregated traffic to fill up the bars - $q = $dbh->prepare('SELECT SUM(Bytes) AS TrafficSum - FROM Flows - WHERE TimeStop BETWEEN ? AND ? - AND IPSrc NOT IN ('.$limit.') - AND FlowSrc = ?'); - $q->bindParam(1, $time1, PDO::PARAM_INT); - $q->bindParam(2, $time2, PDO::PARAM_INT); - $q->bindParam(3, sprintf('%u', ip2long($flowsrc)), PDO::PARAM_INT); - $q->execute(); - $rest_table[] = $q->fetch(); + // divide the timespan into 5min intervals + // query the traffic per talker in 5min intervals + // Initialize the data_table + $data = array(); + $steps = 0; + $rest_table = array(); + for ($time1 = $starttime; $time1 < $endtime; $time1 += (5 * 60)) { + $time2 = ($time1 + (5 * 60)); + $steps++; + // Add the column header (time) to the data array + $data[] = array(strftime('%H:%M', $time1)); + $q = $dbh->prepare('SELECT IPSrc, SUM(Bytes) AS TrafficSum + FROM Flows + WHERE TimeStop BETWEEN ? AND ? + AND IPSrc IN ('.$limit.') + AND FlowSrc = ? + GROUP BY IPSrc + ORDER BY TrafficSum DESC + LIMIT 0, 9'); + $q->bindParam(1, $time1, PDO::PARAM_INT); + $q->bindParam(2, $time2, PDO::PARAM_INT); + $q->bindParam(3, sprintf('%u', ip2long($flowsrc)), PDO::PARAM_INT); + $q->execute(); + $r = $q->fetchAll(); + $i = (count($data) - 1); + foreach ($r as $row) { + $tmpdata[$i][$row[0]] = $row[1]; } - // Iterate through the legend and fill the data array from the temporary data array - // This function makes sure that each top talker is always at the same position - // in the multidimensional data table. - // This is necessary for phpplot to assign the same color to each host on - // sequential columns - // $ip is the key for the temp_data lookup - foreach ($legend as $ip) { - for($i = 0; $i < $steps; $i++) { - if (array_key_exists($i, $tmpdata)) { - // The "column" exists, let's sort the rows - $key = sprintf('%u', ip2long($ip)); - if (array_key_exists($key, $tmpdata[$i])) { - $data[$i][] = $tmpdata[$i][$key]; - } else { - $data[$i][] = ''; - } + // Get the rest of the aggregated traffic to fill up the bars + $q = $dbh->prepare('SELECT SUM(Bytes) AS TrafficSum + FROM Flows + WHERE TimeStop BETWEEN ? AND ? + AND IPSrc NOT IN ('.$limit.') + AND FlowSrc = ?'); + $q->bindParam(1, $time1, PDO::PARAM_INT); + $q->bindParam(2, $time2, PDO::PARAM_INT); + $q->bindParam(3, sprintf('%u', ip2long($flowsrc)), PDO::PARAM_INT); + $q->execute(); + $rest_table[] = $q->fetch(); + } + + // Iterate through the legend and fill the data array from the temporary data array + // This function makes sure that each top talker is always at the same position + // in the multidimensional data table. + // This is necessary for phpplot to assign the same color to each host on + // sequential columns + // $ip is the key for the temp_data lookup + foreach ($legend as $ip) { + for($i = 0; $i < $steps; $i++) { + if (array_key_exists($i, $tmpdata)) { + // The "column" exists, let's sort the rows + $key = sprintf('%u', ip2long($ip)); + if (array_key_exists($key, $tmpdata[$i])) { + $data[$i][] = $tmpdata[$i][$key]; } else { $data[$i][] = ''; } + } else { + $data[$i][] = ''; } } + } - // Append the data from the rest_table to the data array - for($i = 0; $i < $steps; $i++) { - $data[$i][(count($data[$i]) - 1)] = $rest_table[$i][0]; - } + // Append the data from the rest_table to the data array + for($i = 0; $i < $steps; $i++) { + $data[$i][(count($data[$i]) - 1)] = $rest_table[$i][0]; + } - if ($nslookup === True) { - for ($i=0; $i < count($legend); $i++) { - $legend[$i] = gethostbyaddr($legend[$i]).' ('.$legend[$i].')'; - } - } + // Create the chart, write it to tmp/output.png + $plot = new PHPlot(900, 400); + $plot->SetIsInline(True); + //$plot->SetPrintImage(False); + $plot->SetImageBorderType('plain'); + $plot->SetDataColors($data_colors); - return draw_stackedbar($chart_title, $legend, $ytitle, $data); + + $plot->SetPlotType('stackedbars'); + $plot->SetDataType('text-data'); + $plot->SetDataValues($data); + + $plot->SetTitle($chart_title); + $plot->SetYTitle($ytitle); + $plot->SetLegend($legend); + + $plot->SetXTickLabelPos('none'); + $plot->SetXTickPos('none'); + + $plot->SetLegendPixels(760, 40); + $plot->SetMarginsPixels(100, 150, 50, 50); + + + $plot->SetNumberFormat(',', '.'); + $plot->SetPrecisionY(0); + $plot->SetYLabelType('data'); + + $plot->SetOutputFile($output); + $plot->DrawGraph(); + + chmod($output, 0644); + $target = dirname($output).'/'.basename($output).'.png'; + if (rename($output, $target)) { + return 'tmp/'.basename($target); + } else { + return False; } } + Index: trunk/flowmon-web/charts/top-dst.inc.php =================================================================== --- trunk/flowmon-web/charts/top-dst.inc.php (revision 4) +++ trunk/flowmon-web/charts/top-dst.inc.php (revision 1) @@ -21,15 +21,19 @@ # -require_once('stacked-bars.inc.php'); +require_once('phplot-5.0.5/phplot.php'); // Get the data from the table, format it and write it out to a file -function chart_prepare($flowsrc, $starttime, $endtime, $timeframe = False) { +function chart_prepare($flowsrc, $starttime, $endtime) { global $date_fmt_str; global $dbh; + // Define the plot properties - $style = 'Top Sources'; + $style = 'Top Destination'; $chart_title = $style.' '.$flowsrc.' - '.strftime($date_fmt_str, $starttime).' to '.strftime($date_fmt_str, $endtime); $ytitle = 'Bytes'; + $output = tempnam('tmp/', 'plot'); + $data_colors = array('SkyBlue', 'green', 'orange', 'blue', 'purple', 'red', 'violet', 'azure1', 'yellow', 'DarkGreen'); + // Grab the data from the database @@ -47,97 +51,120 @@ $q->execute(); - // Did this return anything at all? - if ($q->rowCount() == 0) { - // No - print('No data for query-period'); - return False; - } else { - // Yes? Carry on! + // Fill the legend build the WHERE limit + $legend = $q->fetchAll(PDO::FETCH_COLUMN, 0); + $limit = ''; + for ($i = 0; $i < count($legend); $i++) { + $limit .= @$legend[$i].', '; + if (array_key_exists($i, $legend)) { + $legend[$i] = long2ip($legend[$i]); + } else { + $legend[$i] = ''; + } + } + $legend[] = 'rest'; + $limit = substr($limit, 0, (strlen($limit) - 2)); - // Fill the legend build the WHERE limit - $legend = $q->fetchAll(PDO::FETCH_COLUMN, 0); - $limit = ''; - for ($i = 0; $i < count($legend); $i++) { - $limit .= @$legend[$i].', '; - if (array_key_exists($i, $legend)) { - $legend[$i] = long2ip($legend[$i]); - } else { - $legend[$i] = ''; - } - } - $legend[] = 'rest'; - $limit = substr($limit, 0, (strlen($limit) - 2)); - - // divide the timespan into 5min intervals - // query the traffic per talker in 5min intervals - // Initialize the data_table - $data = array(); - $steps = 0; - $rest_table = array(); - for ($time1 = $starttime; $time1 < $endtime; $time1 += (5 * 60)) { - $time2 = ($time1 + (5 * 60)); - $steps++; - // Add the column header (time) to the data array - $data[] = array(strftime('%H:%M', $time1)); - $q = $dbh->prepare('SELECT IPDst, SUM(Bytes) AS TrafficSum - FROM Flows - WHERE TimeStop BETWEEN ? AND ? - AND IPDst IN ('.$limit.') - AND FlowSrc = ? - GROUP BY IPDst - ORDER BY TrafficSum DESC - LIMIT 0, 9'); - $q->bindParam(1, $time1, PDO::PARAM_INT); - $q->bindParam(2, $time2, PDO::PARAM_INT); - $q->bindParam(3, sprintf('%u', ip2long($flowsrc)), PDO::PARAM_INT); - $q->execute(); - $r = $q->fetchAll(); - $i = (count($data) - 1); - foreach ($r as $row) { - $tmpdata[$i][$row[0]] = $row[1]; - } - - // Get the rest of the aggregated traffic to fill up the bars - $q = $dbh->prepare('SELECT SUM(Bytes) AS TrafficSum - FROM Flows - WHERE TimeStop BETWEEN ? AND ? - AND IPDst NOT IN ('.$limit.') - AND FlowSrc = ?'); - $q->bindParam(1, $time1, PDO::PARAM_INT); - $q->bindParam(2, $time2, PDO::PARAM_INT); - $q->bindParam(3, sprintf('%u', ip2long($flowsrc)), PDO::PARAM_INT); - $q->execute(); - $rest_table[] = $q->fetch(); + // divide the timespan into 5min intervals + // query the traffic per talker in 5min intervals + // Initialize the data_table + $data = array(); + $steps = 0; + $rest_table = array(); + for ($time1 = $starttime; $time1 < $endtime; $time1 += (5 * 60)) { + $time2 = ($time1 + (5 * 60)); + $steps++; + // Add the column header (time) to the data array + $data[] = array(strftime('%H:%M', $time1)); + $q = $dbh->prepare('SELECT IPDst, SUM(Bytes) AS TrafficSum + FROM Flows + WHERE TimeStop BETWEEN ? AND ? + AND IPDst IN ('.$limit.') + AND FlowSrc = ? + GROUP BY IPDst + ORDER BY TrafficSum DESC + LIMIT 0, 9'); + $q->bindParam(1, $time1, PDO::PARAM_INT); + $q->bindParam(2, $time2, PDO::PARAM_INT); + $q->bindParam(3, sprintf('%u', ip2long($flowsrc)), PDO::PARAM_INT); + $q->execute(); + $r = $q->fetchAll(); + $i = (count($data) - 1); + foreach ($r as $row) { + $tmpdata[$i][$row[0]] = $row[1]; } - // Iterate through the legend and fill the data array from the temporary data array - // This function makes sure that each top talker is always at the same position - // in the multidimensional data table. - // This is necessary for phpplot to assign the same color to each host on - // sequential columns - // $ip is the key for the temp_data lookup - foreach ($legend as $ip) { - for($i = 0; $i < $steps; $i++) { - if (array_key_exists($i, $tmpdata)) { - // The "column" exists, let's sort the rows - $key = sprintf('%u', ip2long($ip)); - if (array_key_exists($key, $tmpdata[$i])) { - $data[$i][] = $tmpdata[$i][$key]; - } else { - $data[$i][] = ''; - } + // Get the rest of the aggregated traffic to fill up the bars + $q = $dbh->prepare('SELECT SUM(Bytes) AS TrafficSum + FROM Flows + WHERE TimeStop BETWEEN ? AND ? + AND IPDst NOT IN ('.$limit.') + AND FlowSrc = ?'); + $q->bindParam(1, $time1, PDO::PARAM_INT); + $q->bindParam(2, $time2, PDO::PARAM_INT); + $q->bindParam(3, sprintf('%u', ip2long($flowsrc)), PDO::PARAM_INT); + $q->execute(); + $rest_table[] = $q->fetch(); + } + + // Iterate through the legend and fill the data array from the temporary data array + // This function makes sure that each top talker is always at the same position + // in the multidimensional data table. + // This is necessary for phpplot to assign the same color to each host on + // sequential columns + // $ip is the key for the temp_data lookup + foreach ($legend as $ip) { + for($i = 0; $i < $steps; $i++) { + if (array_key_exists($i, $tmpdata)) { + // The "column" exists, let's sort the rows + $key = sprintf('%u', ip2long($ip)); + if (array_key_exists($key, $tmpdata[$i])) { + $data[$i][] = $tmpdata[$i][$key]; } else { $data[$i][] = ''; } + } else { + $data[$i][] = ''; } } + } - // Append the data from the rest_table to the data array - for($i = 0; $i < $steps; $i++) { - $data[$i][(count($data[$i]) - 1)] = $rest_table[$i][0]; - } + // Append the data from the rest_table to the data array + for($i = 0; $i < $steps; $i++) { + $data[$i][(count($data[$i]) - 1)] = $rest_table[$i][0]; + } - return draw_stackedbar($chart_title, $legend, $ytitle, $data); + // Create the chart, write it to tmp/output.png + $plot = new PHPlot(800, 400); + $plot->SetIsInline(True); + //$plot->SetPrintImage(False); + $plot->SetImageBorderType('plain'); + $plot->SetDataColors($data_colors); + + + $plot->SetPlotType('stackedbars'); + $plot->SetDataType('text-data'); + $plot->SetDataValues($data); + + $plot->SetTitle($chart_title); + $plot->SetYTitle($ytitle); + $plot->SetLegend($legend); + + $plot->SetXTickLabelPos('none'); + $plot->SetXTickPos('none'); + + $plot->SetNumberFormat(',', '.'); + $plot->SetPrecisionY(0); + + $plot->SetOutputFile($output); + $plot->DrawGraph(); + + chmod($output, 0644); + $target = dirname($output).'/'.basename($output).'.png'; + if (rename($output, $target)) { + return 'tmp/'.basename($target); + } else { + return False; } } + Index: trunk/flowmon-web/charts/top-ports-src.inc.php =================================================================== --- trunk/flowmon-web/charts/top-ports-src.inc.php (revision 4) +++ trunk/flowmon-web/charts/top-ports-src.inc.php (revision 1) @@ -21,5 +21,5 @@ # -require_once('stacked-bars.inc.php'); +require_once('phplot-5.0.5/phplot.php'); // Get the data from the table, format it and write it out to a file @@ -33,4 +33,6 @@ $chart_title = $style.' '.$flowsrc.' - '.strftime($date_fmt_str, $starttime).' to '.strftime($date_fmt_str, $endtime); $ytitle = 'Bytes'; + $output = tempnam('tmp/', 'plot'); + $data_colors = array('SkyBlue', 'green', 'orange', 'blue', 'purple', 'red', 'violet', 'azure1', 'yellow', 'DarkGreen'); @@ -133,6 +135,36 @@ } - return draw_stackedbar($chart_title, $legend, $ytitle, $data); + // Create the chart + $plot = new PHPlot(800, 400); + $plot->SetIsInline(True); + //$plot->SetPrintImage(False); + $plot->SetImageBorderType('plain'); + $plot->SetDataColors($data_colors); + + $plot->SetPlotType('stackedbars'); + $plot->SetDataType('text-data'); + $plot->SetDataValues($data); + + $plot->SetTitle($chart_title); + $plot->SetYTitle($ytitle); + $plot->SetLegend($legend); + + $plot->SetXTickLabelPos('none'); + $plot->SetXTickPos('none'); + + $plot->SetNumberFormat(',', '.'); + $plot->SetPrecisionY(0); + + $plot->SetOutputFile($output); + $plot->DrawGraph(); + + chmod($output, 0644); + $target = dirname($output).'/'.basename($output).'.png'; + if (rename($output, $target)) { + return 'tmp/'.basename($target); + } else { + return False; + } } Index: trunk/flowmon-web/charts/top-ports-dst.inc.php =================================================================== --- trunk/flowmon-web/charts/top-ports-dst.inc.php (revision 4) +++ trunk/flowmon-web/charts/top-ports-dst.inc.php (revision 1) @@ -21,5 +21,5 @@ # -require_once('stacked-bars.inc.php'); +require_once('phplot-5.0.5/phplot.php'); // Get the data from the table, format it and write it out to a file @@ -33,4 +33,7 @@ $chart_title = $style.' '.$flowsrc.' - '.strftime($date_fmt_str, $starttime).' to '.strftime($date_fmt_str, $endtime); $ytitle = 'Bytes'; + $output = tempnam('tmp/', 'plot'); + $data_colors = array('SkyBlue', 'green', 'orange', 'blue', 'purple', 'red', 'violet', 'azure1', 'yellow', 'DarkGreen'); + // Grab the data from the database @@ -132,7 +135,36 @@ } - print_r($data); - return draw_stackedbar($chart_title, $legend, $ytitle, $data); + // Create the chart + $plot = new PHPlot(800, 400); + $plot->SetIsInline(True); + //$plot->SetPrintImage(False); + $plot->SetImageBorderType('plain'); + $plot->SetDataColors($data_colors); + + $plot->SetPlotType('stackedbars'); + $plot->SetDataType('text-data'); + $plot->SetDataValues($data); + + $plot->SetTitle($chart_title); + $plot->SetYTitle($ytitle); + $plot->SetLegend($legend); + + $plot->SetXTickLabelPos('none'); + $plot->SetXTickPos('none'); + + $plot->SetNumberFormat(',', '.'); + $plot->SetPrecisionY(0); + + $plot->SetOutputFile($output); + $plot->DrawGraph(); + + chmod($output, 0644); + $target = dirname($output).'/'.basename($output).'.png'; + if (rename($output, $target)) { + return 'tmp/'.basename($target); + } else { + return False; + } } Index: trunk/flowmon-web/charts/stacked-bars.inc.php =================================================================== --- trunk/flowmon-web/charts/stacked-bars.inc.php (revision 4) +++ (revision ) @@ -1,69 +1,0 @@ - -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published by -# the Free Software Foundation; version 2 only -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -require_once('phplot-5.0.5/phplot.php'); - -// accept data to plot through phplot -function draw_stackedbar($chart_title, $legend, $ytitle, $data) { - - - // Define general plot properties - $data_colors = array('SkyBlue', 'green', 'orange', 'blue', 'purple', 'red', 'violet', 'azure1', 'yellow', 'DarkGreen'); - - // Create the chart, write it to a newly created tmpfile. - $output = tempnam('tmp/', 'plot'); - - $plot = new PHPlot(900, 400); - $plot->SetIsInline(True); - - //$plot->SetPrintImage(False); - - $plot->SetImageBorderType('plain'); - $plot->SetDataColors($data_colors); - - $plot->SetPlotType('stackedbars'); - $plot->SetDataType('text-data'); - $plot->SetDataValues($data); - - $plot->SetTitle($chart_title); - $plot->SetYTitle($ytitle); - $plot->SetLegend($legend); - - $plot->SetXTickLabelPos('none'); - $plot->SetXTickPos('none'); - - $plot->SetLegendPixels(760, 40); - $plot->SetMarginsPixels(100, 150, 50, 50); - - $plot->SetNumberFormat(',', '.'); - $plot->SetPrecisionY(0); - $plot->SetYLabelType('data'); - - $plot->SetOutputFile($output); - $plot->DrawGraph(); - - chmod($output, 0644); - $target = dirname($output).'/'.basename($output).'.png'; - if (rename($output, $target)) { - return 'tmp/'.basename($target); - } else { - return False; - } -} - Index: trunk/flowmon-web/common.inc.php =================================================================== --- trunk/flowmon-web/common.inc.php (revision 6) +++ trunk/flowmon-web/common.inc.php (revision 1) @@ -55,6 +55,6 @@ // HTML Footer function html_footer() { - global $prog_name, $prog_url, $prog_vers, $date_fmt_str; - $foot = '

This page was generated by '.$prog_name.' version '.$prog_vers.' at '.strftime($date_fmt_str).'

+ global $prog_name, $prog_vers, $date_fmt_str; + $foot = '

This page was generated by '.$prog_name.' version '.$prog_vers.' at '.strftime($date_fmt_str).'

@@ -67,5 +67,5 @@ $head = ' - + @@ -89,46 +89,2 @@ return $head; } - -function chartstyle_header() { - - global $chart_styles; - - if (@$_REQUEST['nslookup'] == 'on') { - $nslookup = 'checked="checked"'; - } else { - $nslookup = False; - } - if (@$_REQUEST['rolling'] == 'on') { - $rolling = 'checked="checked"'; - } else { - $rolling = False; - } - - $output = '
-
Back Home flowmon '.$title.'
- - - - - - - -
Start Date: Start Time: End Date: End Time: Chart Style: Nslookup: - Rolling chart: -
- '; - -// '); + print(''); print(''); print(html_footer()); @@ -74,5 +77,4 @@ // We have selected a probe, present with detailes form to get the chart parameters } else if (array_key_exists('action', $_REQUEST) && $_REQUEST['action'] == 'probe_select') { - print(html_header($title = 'FlowMon '.$prog_vers.' - running on '.$_SERVER['HTTP_HOST'], $calendar = True)); print(page_header($title = 'FlowMon Chart Parameters')); @@ -110,26 +112,4 @@ print(html_header($title = 'FlowMon '.$prog_vers.' - running on '.$_SERVER['HTTP_HOST'], $calendar = True)); print(page_header($title = 'FlowMon Traffic Chart')); - - // Initialize defaults which might not exist - if (!@array_key_exists('style', $_REQUEST)) { - $_REQUEST['style'] = 'Top Sources'; - } - if (!@array_key_exists('timeframe', $_REQUEST)) { - $_REQUEST['timeframe'] = '3600'; - } - if (@$_REQUEST['rolling'] == 'on') { - $_REQUEST['startdate'] = strftime('%Y-%m-%d', (time() - $_REQUEST['timeframe'])); - $_REQUEST['starttime'] = strftime('%H:%M', (time() - $_REQUEST['timeframe'])); - $_REQUEST['enddate'] = strftime('%Y-%m-%d'); - $_REQUEST['endtime'] = strftime('%H:%M'); - - $starttime = strtotime($_REQUEST['startdate'].' '.$_REQUEST['starttime']); - $endtime = strtotime($_REQUEST['enddate'].' '.$_REQUEST['endtime']); - } else { - // Sanitize user input - $starttime = strtotime($_REQUEST['startdate'].' '.$_REQUEST['starttime']); - $endtime = strtotime($_REQUEST['enddate'].' '.$_REQUEST['endtime']); - } - print(chartstyle_header($_REQUEST['startdate'], $_REQUEST['starttime'], $_REQUEST['enddate'], $_REQUEST['endtime'])); print('

Statistics

'); @@ -140,16 +120,12 @@ } + // Sanitize user input + $starttime = strtotime($_REQUEST['startdate'].' '.$_REQUEST['starttime']); + $endtime = strtotime($_REQUEST['enddate'].' '.$_REQUEST['endtime']); if (!isvalid_probe($_REQUEST['probe'])) { die("Invalid Probe"); } - // Do we want namelookups? - if (@$_REQUEST['nslookup'] == 'on') { - $nslookup = True; - } else { - $nslookup = False; - } - - $file = chart_prepare($_REQUEST['probe'], $starttime, $endtime, $nslookup=$nslookup); + $file = chart_prepare($_REQUEST['probe'], $starttime, $endtime); print(''); @@ -159,3 +135,29 @@ print(html_footer()); +// Rolling chart requested +} else if (array_key_exists('action', $_REQUEST) && $_REQUEST['action'] == 'rollingchart') { + print(html_header($title = 'FlowMon '.$prog_vers.' - running on '.$_SERVER['HTTP_HOST'], $calendar = False, $refresh = 300)); + print(page_header($title = 'FlowMon Rolling Traffic Chart')); + print('
+

Rolling Statistics (updated every 5min)

'); + + // Import the Chart-Plugin + if (array_key_exists($_REQUEST['style'], $chart_styles)) { + require_once('charts/'.$chart_styles[$_REQUEST['style']]); + } + + // Sanitize user input + if (!isvalid_probe($_REQUEST['probe'])) { + die("Invalid Probe"); + } + + $file = chart_prepare($_REQUEST['probe'], False, False, $_REQUEST['timeframe']); + + print(''); + + print('
'); + + print(html_footer()); + + }