2012-01-13 Ramon Novoa <rnovoa@artica.es>

* include/functions_graph.php,
	  include/functions_netflow.php,
	  operation/netflow/nf_view.php: Aesthetic fixes.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5369 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2012-01-13 14:52:52 +00:00
parent 57d91d50c3
commit 9e77c38d5c
4 changed files with 51 additions and 31 deletions

View File

@ -1,3 +1,9 @@
2012-01-13 Ramon Novoa <rnovoa@artica.es>
* include/functions_graph.php,
include/functions_netflow.php,
operation/netflow/nf_view.php: Aesthetic fixes.
2012-01-13 Ramon Novoa <rnovoa@artica.es>
* include/functions_graph.php,

View File

@ -1936,12 +1936,11 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
* Print an area graph with netflow aggregated
*/
function graph_netflow_aggregate_area ($data, $period, $width, $height, $title, $unit_name, $avg_only = 0, $pure=0, $date = 0, $only_image = false, $homeurl = '') {
function graph_netflow_aggregate_area ($data, $period, $width, $height, $only_image) {
global $config;
global $graphic_type;
echo"<h4>".__('Area graph')."</h4>";
include_flash_chart_script($homeurl);
include_flash_chart_script($config['homeurl']);
if (empty ($data)) {
echo fs_error_image ();
@ -1991,8 +1990,14 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $title,
$flash_chart = false;
}
return stacked_area_graph($flash_chart, $chart, $width, $height, null, $sources,
null, "images/image_problem.opaque.png", "", "",
if ($config['homeurl'] != '') {
$homeurl = $config['homeurl'] . '/';
} else {
$homeurl = '';
}
return area_graph($flash_chart, $chart, $width, $height, array (), $sources,
null, "images/image_problem.opaque.png", "", "", $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size'], "");
}
@ -2002,12 +2007,11 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $title,
/**
* Print an area graph with netflow total
*/
function graph_netflow_total_area ($data, $period, $width, $height, $title, $unit_name, $avg_only = 0, $pure=0, $date = 0, $only_image = false, $homeurl = '') {
function graph_netflow_total_area ($data, $period, $width, $height, $only_image) {
global $config;
global $graphic_type;
echo"<h4>Gráfica de área</h4>";
include_flash_chart_script($homeurl);
include_flash_chart_script($config['homeurl']);
if (empty ($data)) {
echo fs_error_image ();
@ -2041,6 +2045,12 @@ function graph_netflow_total_area ($data, $period, $width, $height, $title, $uni
$flash_chart = false;
}
if ($config['homeurl'] != '') {
$homeurl = $config['homeurl'] . '/';
} else {
$homeurl = '';
}
return area_graph($flash_chart, $chart, $width, $height, array (), array (),
array (), "images/image_problem.opaque.png", "", "", $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
@ -2050,12 +2060,10 @@ function graph_netflow_total_area ($data, $period, $width, $height, $title, $uni
/**
* Print a pie graph with netflow aggregated
*/
function graph_netflow_aggregate_pie ($data) {
function graph_netflow_aggregate_pie ($data, $aggregate) {
global $config;
global $graphic_type;
echo"<h4>".__('Graphic totalized')."</h4>";
if (empty ($data)) {
echo fs_error_image ();
return;
@ -2073,6 +2081,7 @@ function graph_netflow_aggregate_pie ($data) {
}
$i++;
}
return pie3d_graph($config['flash_charts'], $values, 320, 200,
__('Other'), '', $config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size']);

View File

@ -184,7 +184,7 @@ function sort_netflow_data (&$netflow_data) {
usort($netflow_data, "compare_flows");
}
function netflow_stat_table ($data, $start_date, $end_date, $show){
function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){
global $nfdump_date_format;
$start_date = date ($nfdump_date_format, $start_date);
@ -193,29 +193,28 @@ function netflow_stat_table ($data, $start_date, $end_date, $show){
$table->width = '50%';
$table->class = 'databox';
$table->data = array();
$title = __('From')." ".$start_date." ".__('to')." ".$end_date;
$j = 0;
$x = 1;
echo"<h4>".__('Amount per period')." (".$show.")</h4>";
$table->data[0][0] = '<b>'.__('Rank').'</b>';
$table->data[0][1] = '<b>'.$title.'</b>';
$table->data[0][0] = '<b>' . __($aggregate) . '</b>';
$table->data[0][1] = '<b>' . __($unit) . '</b>';
while (isset ($data[$j])) {
$agg = $data[$j]['agg'];
if (!isset($values[$agg])){
$values[$agg] = $data[$j]['data'];
$table->data[$x][0] = $agg;
$table->data[$x][1] = format_numeric ($data[$j]['data']) .' '.$show;
$table->data[$x][1] = format_numeric ($data[$j]['data']);
} else {
$values[$agg] += $data[$j]['data'];
$table->data[$x][0] = $agg;
$table->data[$x][1] = format_numeric ($data[$j]['data']) .' '.$show;
$table->data[$x][1] = format_numeric ($data[$j]['data']);
}
$j++;
$x++;
}
html_print_table($table);
html_print_table($table);
}
/**
@ -224,11 +223,11 @@ html_print_table($table);
* @param array data Statistic data.
* @param string start_date Start date.
* @param string end_date End date.
* @param string unit Unit to display.
* @param string aggregate Aggregate field.
*
* @return The statistics table.
*/
function netflow_data_table ($data, $start_date, $end_date, $unit){
function netflow_data_table ($data, $start_date, $end_date, $aggregate) {
global $nfdump_date_format;
$period = $end_date - $start_date;
@ -253,12 +252,11 @@ function netflow_data_table ($data, $start_date, $end_date, $unit){
}
$values = array();
//$table->size = array ('50%');
$table->size = array ('50%');
$table->class = 'databox';
$table->data = array();
echo"<h4>".__('Table values'). " (".$unit.")</h4>";
$table->data[0][0] = '<b>'.__('Rank').'</b>';
$table->data[0][0] = '<b>'.__($aggregate).'</b>';
$j = 0;
$source_index = array ();
@ -326,6 +324,7 @@ function netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggreg
$values['sources'] = array ();
$agg_command = $command . " -s $aggregate/$unit -n $max -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
exec($agg_command, $string);
foreach($string as $line){
if ($line=='') {
continue;
@ -381,7 +380,7 @@ function netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggreg
function netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max, $unit){
global $nfdump_date_format;
$command .= ' -s ' . $aggregate . ' -n ' . $max . ' -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
$command .= " -s $aggregate/$unit -n $max -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
exec($command, $string);
if(! is_array($string)){

View File

@ -136,6 +136,7 @@ for ($x = 0; isset($all_rcs[$x]['id_rc']); $x++) {
// Get item filters
$filter = db_get_row_sql("SELECT * FROM tnetflow_filter WHERE id_sg = '" . io_safe_input ($content_report['id_filter']) . "'", false, true);
$command = netflow_get_command ($filter);
$title = $filter['id_name'];
$aggregate = $filter['aggregate'];
$unit = $filter['output'];
@ -145,23 +146,28 @@ for ($x = 0; isset($all_rcs[$x]['id_rc']); $x++) {
$unique_id = $report_id . '_' . $content_id . '_' . ($end_date - $start_date);
$data = netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max_aggregates, $unit);
if ($aggregate != 'none') {
echo graph_netflow_aggregate_area($data, $interval, 660, 320, '', '', '', '', $end_date, $unit);
echo '<h4>' . $title . ' (' . __($aggregate) . '/' . __($unit) . ')</h4>';
echo graph_netflow_aggregate_area($data, $interval, 660, 320, 0);
} else {
echo graph_netflow_total_area($data, $interval, 660, 320, '', '','','',$date);
echo '<h4>' . $title . ' (' . __($unit) . ')</h4>';
echo graph_netflow_total_area($data, $interval, 660, 320, 0);
}
break;
case '1':
$result = netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max_aggregates, $unit);
echo graph_netflow_aggregate_pie($result);
$data = netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max_aggregates, $unit);
echo '<h4>' . $title . ' (' . __($aggregate) . '/' . __($unit) . ')</h4>';
echo graph_netflow_aggregate_pie($data, $aggregate, $unit, $title);
break;
case '2':
$unique_id = $report_id . '_' . $content_id . '_' . ($end_date - $start_date);
$data = netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max_aggregates, $unit);
echo netflow_data_table ($data, $start_date, $end_date, $unit);
echo '<h4>' . $title . ' (' . __($aggregate) . '/' . __($unit) . ')</h4>';
echo netflow_data_table ($data, $start_date, $end_date, $aggregate);
break;
case '3':
$data = netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max_aggregates, $unit);
echo netflow_stat_table ($data, $start_date, $end_date, $unit);
echo '<h4>' . $title . '</h4>';
echo netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit);
break;
default:
echo fs_error_image();