mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-02 03:24:53 +02:00
2013-02-14 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_netflow.php, operation/netflow/nf_live_view.php: fixed the show pie graph with table. Fixes: #3604468 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7653 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ad40156f0e
commit
68fc7e09b5
@ -1,3 +1,10 @@
|
|||||||
|
2013-02-14 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/functions_netflow.php, operation/netflow/nf_live_view.php:
|
||||||
|
fixed the show pie graph with table.
|
||||||
|
|
||||||
|
Fixes: #3604468
|
||||||
|
|
||||||
2013-02-14 Sergio Martin <sergio.martin@artica.es>
|
2013-02-14 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* pandoradb_data.sql: Fixed the macros of the
|
* pandoradb_data.sql: Fixed the macros of the
|
||||||
|
@ -366,7 +366,9 @@ function netflow_summary_table ($data) {
|
|||||||
$table->data[5][0] = '<b>'.__('Average bytes per packet').'</b>';
|
$table->data[5][0] = '<b>'.__('Average bytes per packet').'</b>';
|
||||||
$table->data[5][1] = format_numeric ($data['avgbpp']);
|
$table->data[5][1] = format_numeric ($data['avgbpp']);
|
||||||
|
|
||||||
return html_print_table ($table, true);
|
$html = html_print_table ($table, true);
|
||||||
|
|
||||||
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -821,13 +823,11 @@ function netflow_get_filter_arguments ($filter) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function netflow_get_chart_types () {
|
function netflow_get_chart_types () {
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
__('Area graph'),
|
'netflow_area' => __('Area graph'),
|
||||||
__('Pie graph'),
|
'netflow_pie_summatory' => __('Pie graph and Summary table'),
|
||||||
__('Data table'),
|
'netflow_statistics' => __('Statistics table'),
|
||||||
__('Statistics table'),
|
'netflow_data' => __('Data table'));
|
||||||
__('Summary table'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -923,7 +923,8 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
|
|||||||
}
|
}
|
||||||
$html .= graph_netflow_aggregate_area ($data, $interval, 850, 320, netflow_format_unit ($unit));
|
$html .= graph_netflow_aggregate_area ($data, $interval, 850, 320, netflow_format_unit ($unit));
|
||||||
return $html;
|
return $html;
|
||||||
} else if ($output == 'PDF') {
|
}
|
||||||
|
else if ($output == 'PDF') {
|
||||||
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
||||||
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
||||||
if ($interval_length != 0) {
|
if ($interval_length != 0) {
|
||||||
@ -931,7 +932,8 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
|
|||||||
}
|
}
|
||||||
$html .= graph_netflow_aggregate_area ($data, $interval, 850, 320, netflow_format_unit ($unit), 2, true);
|
$html .= graph_netflow_aggregate_area ($data, $interval, 850, 320, netflow_format_unit ($unit), 2, true);
|
||||||
return $html;
|
return $html;
|
||||||
} else if ($output == 'XML') {
|
}
|
||||||
|
else if ($output == 'XML') {
|
||||||
$xml = "<unit>$unit</unit>\n";
|
$xml = "<unit>$unit</unit>\n";
|
||||||
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
||||||
$xml .= "<resolution>$interval_length</resolution>\n";
|
$xml .= "<resolution>$interval_length</resolution>\n";
|
||||||
@ -947,14 +949,16 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
|
|||||||
}
|
}
|
||||||
$html .= graph_netflow_total_area ($data, $interval, 660, 320, netflow_format_unit ($unit));
|
$html .= graph_netflow_total_area ($data, $interval, 660, 320, netflow_format_unit ($unit));
|
||||||
return $html;
|
return $html;
|
||||||
} else if ($output == 'PDF') {
|
}
|
||||||
|
else if ($output == 'PDF') {
|
||||||
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
||||||
if ($interval_length != 0) {
|
if ($interval_length != 0) {
|
||||||
$html .= " <b>" . _('Resolution') . ":</b> $interval_length " . __('seconds');
|
$html .= " <b>" . _('Resolution') . ":</b> $interval_length " . __('seconds');
|
||||||
}
|
}
|
||||||
$html .= graph_netflow_total_area ($data, $interval, 660, 320, netflow_format_unit ($unit), 2, true);
|
$html .= graph_netflow_total_area ($data, $interval, 660, 320, netflow_format_unit ($unit), 2, true);
|
||||||
return $html;
|
return $html;
|
||||||
} else if ($output == 'XML') {
|
}
|
||||||
|
else if ($output == 'XML') {
|
||||||
$xml = "<unit>$unit</unit>\n";
|
$xml = "<unit>$unit</unit>\n";
|
||||||
$xml .= "<resolution>$interval_length</resolution>\n";
|
$xml .= "<resolution>$interval_length</resolution>\n";
|
||||||
$xml .= netflow_total_area_xml ($data);
|
$xml .= netflow_total_area_xml ($data);
|
||||||
@ -962,31 +966,6 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '1':
|
|
||||||
case 'netflow_pie':
|
|
||||||
$data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit, $connection_name);
|
|
||||||
if (empty ($data)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ($output == 'HTML') {
|
|
||||||
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
|
||||||
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
|
||||||
$html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate));
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
else if ($output == 'PDF') {
|
|
||||||
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
|
||||||
$html .= " <b>" . __('Aggregate') . ":</b> $aggregate";
|
|
||||||
$html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate), 2, true);
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
else if ($output == 'XML') {
|
|
||||||
$xml = "<unit>$unit</unit>\n";
|
|
||||||
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
|
||||||
$xml .= netflow_aggregate_pie_xml ($data);
|
|
||||||
return $xml;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '2':
|
case '2':
|
||||||
case 'netflow_data':
|
case 'netflow_data':
|
||||||
$data = netflow_get_data ($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, $unit, $connection_name);
|
$data = netflow_get_data ($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, $unit, $connection_name);
|
||||||
@ -1015,7 +994,8 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
|
|||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
case 'netflow_statistics':
|
case 'netflow_statistics':
|
||||||
$data = netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max_aggregates, $unit, $connection_name);
|
$data = netflow_get_stats ($start_date, $end_date, $filter,
|
||||||
|
$aggregate, $max_aggregates, $unit, $connection_name);
|
||||||
if (empty ($data)) {
|
if (empty ($data)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1028,15 +1008,81 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
|
|||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
case 'netflow_summary':
|
case 'netflow_summary':
|
||||||
|
$data_summary = netflow_get_summary ($start_date, $end_date,
|
||||||
$data = netflow_get_summary ($start_date, $end_date, $filter, $connection_name);
|
$filter, $connection_name);
|
||||||
if (empty ($data)) {
|
if (empty ($data)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($output == 'HTML' || $output == 'PDF') {
|
if ($output == 'HTML' || $output == 'PDF') {
|
||||||
return netflow_summary_table ($data);
|
return netflow_summary_table ($data_summary);
|
||||||
} else if ($output == 'XML') {
|
}
|
||||||
return netflow_summary_xml ($data);
|
else if ($output == 'XML') {
|
||||||
|
return netflow_summary_xml ($data_summary);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
case 'netflow_pie':
|
||||||
|
$data_pie = netflow_get_stats ($start_date, $end_date,
|
||||||
|
$filter, $aggregate, $max_aggregates, $unit,
|
||||||
|
$connection_name);
|
||||||
|
if (empty ($data_pie)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ($output == 'HTML') {
|
||||||
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
||||||
|
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
||||||
|
$html .= graph_netflow_aggregate_pie ($data_pie, netflow_format_aggregate ($aggregate));
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
else if ($output == 'PDF') {
|
||||||
|
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
|
||||||
|
$html .= " <b>" . __('Aggregate') . ":</b> $aggregate";
|
||||||
|
$html .= graph_netflow_aggregate_pie ($data_pie, netflow_format_aggregate ($aggregate), 2, true);
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
else if ($output == 'XML') {
|
||||||
|
$xml = "<unit>$unit</unit>\n";
|
||||||
|
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
||||||
|
$xml .= netflow_aggregate_pie_xml ($data_pie);
|
||||||
|
return $xml;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'netflow_pie_summatory':
|
||||||
|
$data_summary = netflow_get_summary ($start_date, $end_date,
|
||||||
|
$filter, $connection_name);
|
||||||
|
if (empty ($data_summary)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data_pie = netflow_get_stats ($start_date, $end_date,
|
||||||
|
$filter, $aggregate, $max_aggregates, $unit,
|
||||||
|
$connection_name);
|
||||||
|
if (empty ($data_pie)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($output) {
|
||||||
|
case 'HTML':
|
||||||
|
$html = '<table>';
|
||||||
|
$html .= '<tr>';
|
||||||
|
$html .= '<td>';
|
||||||
|
$html .= netflow_summary_table ($data_summary);
|
||||||
|
$html .= "<b>" . __('Unit') . ":</b> " .
|
||||||
|
netflow_format_unit ($unit);
|
||||||
|
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
||||||
|
$html .= '</td>';
|
||||||
|
$html .= '<td>';
|
||||||
|
$html .= graph_netflow_aggregate_pie ($data_pie, netflow_format_aggregate ($aggregate));
|
||||||
|
$html .= '</td>';
|
||||||
|
$html .= '</tr>';
|
||||||
|
$html .= '</table>';
|
||||||
|
return $html;
|
||||||
|
break;
|
||||||
|
case 'PDF':
|
||||||
|
break;
|
||||||
|
case 'XML':
|
||||||
|
return netflow_summary_xml ($data_summary);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1083,11 +1129,17 @@ function netflow_xml_report ($id, $start_date, $end_date, $interval_length = 0)
|
|||||||
$item_types = netflow_get_chart_types ();
|
$item_types = netflow_get_chart_types ();
|
||||||
|
|
||||||
// Print report items
|
// Print report items
|
||||||
$report_contents = db_get_all_rows_sql ("SELECT * FROM tnetflow_report_content WHERE id_report='" . $report['id_report'] . "' ORDER BY `order`");
|
$report_contents = db_get_all_rows_sql ("SELECT *
|
||||||
|
FROM tnetflow_report_content
|
||||||
|
WHERE id_report='" . $report['id_report'] . "'
|
||||||
|
ORDER BY `order`");
|
||||||
foreach ($report_contents as $content) {
|
foreach ($report_contents as $content) {
|
||||||
|
|
||||||
// Get item filters
|
// Get item filters
|
||||||
$filter = db_get_row_sql("SELECT * FROM tnetflow_filter WHERE id_sg = '" . io_safe_input ($content['id_filter']) . "'", false, true);
|
$filter = db_get_row_sql("SELECT *
|
||||||
|
FROM tnetflow_filter
|
||||||
|
WHERE id_sg = '" . io_safe_input ($content['id_filter']) . "'",
|
||||||
|
false, true);
|
||||||
if ($filter === FALSE) {
|
if ($filter === FALSE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ $filter['advanced_filter'] = get_parameter('advanced_filter','');
|
|||||||
$filter['advanced_filter'] = get_parameter('advanced_filter','');
|
$filter['advanced_filter'] = get_parameter('advanced_filter','');
|
||||||
|
|
||||||
// Read chart configuration
|
// Read chart configuration
|
||||||
$chart_type = (int) get_parameter('chart_type', 0);
|
$chart_type = get_parameter('chart_type', 'netflow_area');
|
||||||
$max_aggregates = (int) get_parameter('max_aggregates', 0);
|
$max_aggregates = (int) get_parameter('max_aggregates', 0);
|
||||||
$period = (int) get_parameter('period', '86400');
|
$period = (int) get_parameter('period', '86400');
|
||||||
$update_date = (int) get_parameter('update_date', 0);
|
$update_date = (int) get_parameter('update_date', 0);
|
||||||
@ -105,7 +105,9 @@ if (! defined ('METACONSOLE')) {
|
|||||||
//Header
|
//Header
|
||||||
ui_print_page_header (__('Netflow live view'), "images/networkmap/so_cisco_new.png", false, "", false, array ());
|
ui_print_page_header (__('Netflow live view'), "images/networkmap/so_cisco_new.png", false, "", false, array ());
|
||||||
if (! is_executable ($config['netflow_nfdump'])) {
|
if (! is_executable ($config['netflow_nfdump'])) {
|
||||||
ui_print_error_message(__('nfdump binary not found!'));
|
ui_print_error_message(
|
||||||
|
sprintf(__('nfdump binary (%s) not found!'),
|
||||||
|
$config['netflow_nfdump']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -142,8 +144,10 @@ else if ($update != '' && check_acl ($config["id_user"], 0, "AW")) {
|
|||||||
// Save filter args
|
// Save filter args
|
||||||
$filter_copy['filter_args'] = netflow_get_filter_arguments ($filter_copy);
|
$filter_copy['filter_args'] = netflow_get_filter_arguments ($filter_copy);
|
||||||
|
|
||||||
$result = db_process_sql_update ('tnetflow_filter', $filter_copy, array ('id_sg' => $filter_id));
|
$result = db_process_sql_update ('tnetflow_filter', $filter_copy,
|
||||||
ui_print_result_message ($result, __('Filter updated successfully'), __('Error updating filter'));
|
array('id_sg' => $filter_id));
|
||||||
|
ui_print_result_message ($result, __('Filter updated successfully'),
|
||||||
|
__('Error updating filter'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -166,7 +170,7 @@ echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&s
|
|||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
|
|
||||||
echo "<td>" .
|
echo "<td>" .
|
||||||
'<b>'.__('Date').'</b>' .
|
'<b>' . __('Date') . '</b>' .
|
||||||
"</td>";
|
"</td>";
|
||||||
echo "<td>" .
|
echo "<td>" .
|
||||||
html_print_input_text ('date', $date, false, 10, 10, true) .
|
html_print_input_text ('date', $date, false, 10, 10, true) .
|
||||||
@ -185,10 +189,10 @@ echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&s
|
|||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
|
|
||||||
echo "<td>" . '<b>'.__('Type').'</b>' . "</td>";
|
echo "<td>" . '<b>' . __('Type') . '</b>' . "</td>";
|
||||||
echo "<td>" . html_print_select (netflow_get_chart_types (), 'chart_type', $chart_type,'','',0,true) . "</td>";
|
echo "<td>" . html_print_select (netflow_get_chart_types (), 'chart_type', $chart_type,'','',0,true) . "</td>";
|
||||||
|
|
||||||
echo "<td>" . '<b>'.__('Max. values').'</b>' . "</td>";
|
echo "<td>" . '<b>' . __('Max. values') . '</b>' . "</td>";
|
||||||
$max_values = array ('2' => '2',
|
$max_values = array ('2' => '2',
|
||||||
'5' => '5',
|
'5' => '5',
|
||||||
'10' => '10',
|
'10' => '10',
|
||||||
@ -367,7 +371,9 @@ if ($draw != '') {
|
|||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
echo "<br/>";
|
echo "<br/>";
|
||||||
echo netflow_draw_item ($start_date, $end_date, $interval_length, $chart_type, $filter, $max_aggregates, $connection_name);
|
echo netflow_draw_item ($start_date, $end_date,
|
||||||
|
$interval_length, $chart_type, $filter,
|
||||||
|
$max_aggregates, $connection_name);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user