2013-02-04 Miguel de Dios <miguel.dedios@artica.es>

* install.php: cleaned source code style.
	
	* godmode/netflow/nf_edit.php, include/functions_netflow.php: fixed
	the empty data.
	
	Fixes: #3603092




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7567 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-02-04 12:19:17 +00:00
parent 0d9606c92f
commit c2a39c1ee8
4 changed files with 50 additions and 25 deletions

View File

@ -1,3 +1,12 @@
2013-02-04 Miguel de Dios <miguel.dedios@artica.es>
* install.php: cleaned source code style.
* godmode/netflow/nf_edit.php, include/functions_netflow.php: fixed
the empty data.
Fixes: #3603092
2013-02-04 Miguel de Dios <miguel.dedios@artica.es> 2013-02-04 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/pandora_alerts.js: cleaned source code style. * include/javascript/pandora_alerts.js: cleaned source code style.

View File

@ -31,14 +31,15 @@ if (! check_acl ($config["id_user"], 0, "AW")) {
} }
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
//Header //Header
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
ui_print_page_header (__('Manage Netflow Filter'), "images/networkmap/so_cisco_new.png", false, "", true); ui_print_page_header (__('Manage Netflow Filter'), "images/networkmap/so_cisco_new.png", false, "", true);
} else { }
else {
$nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')),
array('link' => 'index.php?sec=netf&sec2=godmode/netflow/nf_edit', 'text' => __('Netflow filters'))); array('link' => 'index.php?sec=netf&sec2=godmode/netflow/nf_edit', 'text' => __('Netflow filters')));
ui_meta_print_page_header($nav_bar); ui_meta_print_page_header($nav_bar);
ui_meta_print_header(__("Netflow filters")); ui_meta_print_header(__("Netflow filters"));
@ -53,7 +54,7 @@ if ($delete) {
$id_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id); $id_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id);
$result = db_process_sql_delete ('tnetflow_filter', $result = db_process_sql_delete ('tnetflow_filter',
array ('id_sg' => $id)); array ('id_sg' => $id));
$result2 = db_process_sql_delete ('tnetflow_report_content', $result2 = db_process_sql_delete ('tnetflow_report_content',
array ('id_filter' => $id_filter)); array ('id_filter' => $id_filter));
@ -81,7 +82,7 @@ if ($multiple_delete) {
$result2 = db_process_sql_delete ('tnetflow_report_content', $result2 = db_process_sql_delete ('tnetflow_report_content',
array ('id_filter' => $id_filter)); array ('id_filter' => $id_filter));
if ($result === false) { if ($result === false) {
db_process_sql_rollback(); db_process_sql_rollback();
break; break;
@ -94,7 +95,7 @@ if ($multiple_delete) {
if ($result !== false) $result = true; if ($result !== false) $result = true;
else $result = false; else $result = false;
ui_print_result_message ($result, ui_print_result_message ($result,
__('Successfully deleted'), __('Successfully deleted'),
__('Not deleted. Error deleting data')); __('Not deleted. Error deleting data'));
@ -113,7 +114,8 @@ $table->head = array ();
$table->head[0] = __('Name'); $table->head[0] = __('Name');
$table->head[1] = __('Group'); $table->head[1] = __('Group');
$table->head[2] = __('Action') . $table->head[2] = __('Action') .
html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); html_print_checkbox('all_delete', 0, false, true, false,
'check_all_checkboxes();');
$table->style = array (); $table->style = array ();
$table->style[0] = 'font-weight: bold'; $table->style[0] = 'font-weight: bold';
$table->align = array (); $table->align = array ();

View File

@ -297,7 +297,8 @@ function netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit) {
$source_count++; $source_count++;
$j++; $j++;
} }
} else { }
else {
$table->style[1] = 'padding: 4px;'; $table->style[1] = 'padding: 4px;';
} }
@ -306,6 +307,8 @@ function netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit) {
$table->head[1] = __('Data'); $table->head[1] = __('Data');
$table->align[1] = "right"; $table->align[1] = "right";
$i = 0; $i = 0;
foreach ($data as $timestamp => $value) { foreach ($data as $timestamp => $value) {
$table->data[$i][0] = date ($time_format, $timestamp); $table->data[$i][0] = date ($time_format, $timestamp);
$table->data[$i][1] = format_numeric ($value['data']) . '&nbsp;' . netflow_format_unit ($unit); $table->data[$i][1] = format_numeric ($value['data']) . '&nbsp;' . netflow_format_unit ($unit);
@ -398,29 +401,30 @@ function netflow_is_net ($address) {
function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $aggregate, $max, $unit, $connection_name = '') { function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $aggregate, $max, $unit, $connection_name = '') {
global $nfdump_date_format; global $nfdump_date_format;
global $config; global $config;
// Requesting remote data // Requesting remote data
if (defined ('METACONSOLE') && $connection_name != '') { if (defined ('METACONSOLE') && $connection_name != '') {
$data = metaconsole_call_remote_api ($connection_name, 'netflow_get_data', "$start_date|$end_date|$interval_length|" . base64_encode(json_encode($filter)) . "|$aggregate|$max|$unit"); $data = metaconsole_call_remote_api ($connection_name, 'netflow_get_data', "$start_date|$end_date|$interval_length|" . base64_encode(json_encode($filter)) . "|$aggregate|$max|$unit");
return json_decode ($data, true); return json_decode ($data, true);
} }
// Calculate the number of intervals // Calculate the number of intervals
if ($interval_length <= 0) { if ($interval_length <= 0) {
$num_intervals = $config['graph_res'] * 50; $num_intervals = $config['graph_res'] * 50;
$period = $end_date - $start_date; $period = $end_date - $start_date;
$interval_length = (int) ($period / $num_intervals); $interval_length = (int) ($period / $num_intervals);
} else { }
else {
$period = $end_date - $start_date; $period = $end_date - $start_date;
$num_intervals = (int) ($period / $interval_length); $num_intervals = (int) ($period / $interval_length);
} }
// Set a max number of intervals // Set a max number of intervals
if ($num_intervals > $config['netflow_max_resolution']) { if ($num_intervals > $config['netflow_max_resolution']) {
$num_intervals = $config['netflow_max_resolution']; $num_intervals = $config['netflow_max_resolution'];
$interval_length = (int) ($period / $num_intervals); $interval_length = (int) ($period / $num_intervals);
} }
// If there is aggregation calculate the top n // If there is aggregation calculate the top n
if ($aggregate != 'none') { if ($aggregate != 'none') {
$values['data'] = array (); $values['data'] = array ();
@ -435,10 +439,10 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
// Call nfdump // Call nfdump
$agg_command = $command . " -s $aggregate/bytes -n $max -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); $agg_command = $command . " -s $aggregate/bytes -n $max -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
exec($agg_command, $string); exec($agg_command, $string);
// Reamove the first line // Reamove the first line
$string[0] = ''; $string[0] = '';
// Parse aggregates // Parse aggregates
foreach($string as $line){ foreach($string as $line){
if ($line=='') { if ($line=='') {
@ -447,7 +451,8 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
$val = explode(',',$line); $val = explode(',',$line);
if ($aggregate == 'proto') { if ($aggregate == 'proto') {
$values['sources'][$val[3]] = 1; $values['sources'][$val[3]] = 1;
} else { }
else {
$values['sources'][$val[4]] = 1; $values['sources'][$val[4]] = 1;
} }
} }
@ -479,7 +484,7 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
else { else {
$values = array (); $values = array ();
} }
$interval_start = $start_date; $interval_start = $start_date;
for ($i = 0; $i < $num_intervals; $i++, $interval_start+=$interval_length+1) { for ($i = 0; $i < $num_intervals; $i++, $interval_start+=$interval_length+1) {
$interval_end = $interval_start + $interval_length; $interval_end = $interval_start + $interval_length;
@ -511,7 +516,8 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
$values[$interval_start]['data'] = $data['totalbytes']; $values[$interval_start]['data'] = $data['totalbytes'];
break; break;
} }
} else { }
else {
// Set default values // Set default values
foreach ($values['sources'] as $source => $discard) { foreach ($values['sources'] as $source => $discard) {
@ -522,12 +528,16 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
if (! isset ($values['sources'][$line['agg']])) { if (! isset ($values['sources'][$line['agg']])) {
continue; continue;
} }
$values['data'][$interval_start][$line['agg']] = $line['data']; $values['data'][$interval_start][$line['agg']] = $line['data'];
} }
} }
} }
if (($aggregate != 'none') && (empty($values['data']))) {
return array();
}
return $values; return $values;
} }
@ -963,12 +973,14 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
$html .= "&nbsp;<b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate); $html .= "&nbsp;<b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
$html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate)); $html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate));
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 .= "&nbsp;<b>" . __('Aggregate') . ":</b> $aggregate"; $html .= "&nbsp;<b>" . __('Aggregate') . ":</b> $aggregate";
$html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate), 2, true); $html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate), 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 .= netflow_aggregate_pie_xml ($data); $xml .= netflow_aggregate_pie_xml ($data);
@ -989,8 +1001,10 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
$html .= "&nbsp;<b>" . _('Resolution') . ":</b> $interval_length " . __('seconds'); $html .= "&nbsp;<b>" . _('Resolution') . ":</b> $interval_length " . __('seconds');
} }
$html .= netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit); $html .= netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit);
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";

View File

@ -345,7 +345,7 @@ function oracle_drop_all_objects ($connection) {
$stmt = oci_parse($connection, $stmt = oci_parse($connection,
"BEGIN " . "BEGIN " .
"FOR cur_rec IN (SELECT object_name, object_type " . "FOR cur_rec IN (SELECT object_name, object_type " .
"FROM user_objects " . "FROM user_objects " .
"WHERE object_type IN ('TABLE', 'VIEW', 'PACKAGE', 'PROCEDURE', 'FUNCTION', 'SEQUENCE', 'SNAPSHOT', 'MATERIALIZED VIEW')) LOOP " . "WHERE object_type IN ('TABLE', 'VIEW', 'PACKAGE', 'PROCEDURE', 'FUNCTION', 'SEQUENCE', 'SNAPSHOT', 'MATERIALIZED VIEW')) LOOP " .
"BEGIN " . "BEGIN " .
"IF cur_rec.object_type = 'TABLE' THEN " . "IF cur_rec.object_type = 'TABLE' THEN " .