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:
parent
85c3f27936
commit
19b67559ae
|
@ -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>
|
||||
|
||||
* include/javascript/pandora_alerts.js: cleaned source code style.
|
||||
|
|
|
@ -31,14 +31,15 @@ if (! check_acl ($config["id_user"], 0, "AW")) {
|
|||
}
|
||||
|
||||
$pure = get_parameter('pure', 0);
|
||||
|
||||
|
||||
//Header
|
||||
if (! defined ('METACONSOLE')) {
|
||||
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')),
|
||||
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_header(__("Netflow filters"));
|
||||
|
@ -53,7 +54,7 @@ if ($delete) {
|
|||
$id_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id);
|
||||
$result = db_process_sql_delete ('tnetflow_filter',
|
||||
array ('id_sg' => $id));
|
||||
|
||||
|
||||
$result2 = db_process_sql_delete ('tnetflow_report_content',
|
||||
array ('id_filter' => $id_filter));
|
||||
|
||||
|
@ -81,7 +82,7 @@ if ($multiple_delete) {
|
|||
|
||||
$result2 = db_process_sql_delete ('tnetflow_report_content',
|
||||
array ('id_filter' => $id_filter));
|
||||
|
||||
|
||||
if ($result === false) {
|
||||
db_process_sql_rollback();
|
||||
break;
|
||||
|
@ -94,7 +95,7 @@ if ($multiple_delete) {
|
|||
|
||||
if ($result !== false) $result = true;
|
||||
else $result = false;
|
||||
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully deleted'),
|
||||
__('Not deleted. Error deleting data'));
|
||||
|
@ -113,7 +114,8 @@ $table->head = array ();
|
|||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Group');
|
||||
$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[0] = 'font-weight: bold';
|
||||
$table->align = array ();
|
||||
|
|
|
@ -297,7 +297,8 @@ function netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit) {
|
|||
$source_count++;
|
||||
$j++;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$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->align[1] = "right";
|
||||
$i = 0;
|
||||
|
||||
|
||||
foreach ($data as $timestamp => $value) {
|
||||
$table->data[$i][0] = date ($time_format, $timestamp);
|
||||
$table->data[$i][1] = format_numeric ($value['data']) . ' ' . 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 = '') {
|
||||
global $nfdump_date_format;
|
||||
global $config;
|
||||
|
||||
|
||||
// Requesting remote data
|
||||
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");
|
||||
return json_decode ($data, true);
|
||||
}
|
||||
|
||||
|
||||
// Calculate the number of intervals
|
||||
if ($interval_length <= 0) {
|
||||
$num_intervals = $config['graph_res'] * 50;
|
||||
$period = $end_date - $start_date;
|
||||
$interval_length = (int) ($period / $num_intervals);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$period = $end_date - $start_date;
|
||||
$num_intervals = (int) ($period / $interval_length);
|
||||
}
|
||||
|
||||
|
||||
// Set a max number of intervals
|
||||
if ($num_intervals > $config['netflow_max_resolution']) {
|
||||
$num_intervals = $config['netflow_max_resolution'];
|
||||
$interval_length = (int) ($period / $num_intervals);
|
||||
}
|
||||
|
||||
|
||||
// If there is aggregation calculate the top n
|
||||
if ($aggregate != 'none') {
|
||||
$values['data'] = array ();
|
||||
|
@ -435,10 +439,10 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
|
|||
// Call nfdump
|
||||
$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);
|
||||
|
||||
|
||||
// Reamove the first line
|
||||
$string[0] = '';
|
||||
|
||||
|
||||
// Parse aggregates
|
||||
foreach($string as $line){
|
||||
if ($line=='') {
|
||||
|
@ -447,7 +451,8 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
|
|||
$val = explode(',',$line);
|
||||
if ($aggregate == 'proto') {
|
||||
$values['sources'][$val[3]] = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values['sources'][$val[4]] = 1;
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +484,7 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
|
|||
else {
|
||||
$values = array ();
|
||||
}
|
||||
|
||||
|
||||
$interval_start = $start_date;
|
||||
for ($i = 0; $i < $num_intervals; $i++, $interval_start+=$interval_length+1) {
|
||||
$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'];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
// Set default values
|
||||
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']])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$values['data'][$interval_start][$line['agg']] = $line['data'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($aggregate != 'none') && (empty($values['data']))) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
@ -963,12 +973,14 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
|
|||
$html .= " <b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
|
||||
$html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate));
|
||||
return $html;
|
||||
} else if ($output == 'PDF') {
|
||||
}
|
||||
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') {
|
||||
}
|
||||
else if ($output == 'XML') {
|
||||
$xml = "<unit>$unit</unit>\n";
|
||||
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
||||
$xml .= netflow_aggregate_pie_xml ($data);
|
||||
|
@ -989,8 +1001,10 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
|
|||
$html .= " <b>" . _('Resolution') . ":</b> $interval_length " . __('seconds');
|
||||
}
|
||||
$html .= netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit);
|
||||
|
||||
return $html;
|
||||
} else if ($output == 'XML') {
|
||||
}
|
||||
else if ($output == 'XML') {
|
||||
$xml = "<unit>$unit</unit>\n";
|
||||
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
||||
$xml .= "<resolution>$interval_length</resolution>\n";
|
||||
|
|
|
@ -345,7 +345,7 @@ function oracle_drop_all_objects ($connection) {
|
|||
$stmt = oci_parse($connection,
|
||||
"BEGIN " .
|
||||
"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 " .
|
||||
"BEGIN " .
|
||||
"IF cur_rec.object_type = 'TABLE' THEN " .
|
||||
|
|
Loading…
Reference in New Issue