2012-12-12 Ramon Novoa <rnovoa@artica.es>

* pandoradb_data.sql,
	  include/functions_config.php,
	  include/functions_netflow.php,
	  operation/netflow/nf_live_view.php,
	  pandoradb.data.postgreSQL.sql,
	  pandoradb.data.oracle.sql,
	  godmode/setup/setup_netflow.php: Added the maximum netflow chart
	  resolution to the setup. Added byte and byteperseconds units.
	  Small improvements.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7268 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2012-12-12 12:10:16 +00:00
parent 922b3e3524
commit e0bd5f334f
8 changed files with 53 additions and 31 deletions

View File

@ -1,3 +1,15 @@
2012-12-12 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,
include/functions_config.php,
include/functions_netflow.php,
operation/netflow/nf_live_view.php,
pandoradb.data.postgreSQL.sql,
pandoradb.data.oracle.sql,
godmode/setup/setup_netflow.php: Added the maximum netflow chart
resolution to the setup. Added byte and byteperseconds units.
Small improvements.
2012-12-12 Sergio Martin <sergio.martin@artica.es> 2012-12-12 Sergio Martin <sergio.martin@artica.es>
* include/functions_config.php: Added configuration * include/functions_config.php: Added configuration

View File

@ -52,7 +52,9 @@ $table->data[2][0] = '<b>'.__('Daemon binary path').'</b>';
$table->data[2][1] = html_print_input_text ('netflow_daemon', $config['netflow_daemon'], false, 50, 200, true); $table->data[2][1] = html_print_input_text ('netflow_daemon', $config['netflow_daemon'], false, 50, 200, true);
$table->data[3][0] = '<b>'.__('Nfdump binary path').'</b>'; $table->data[3][0] = '<b>'.__('Nfdump binary path').'</b>';
$table->data[3][1] = html_print_input_text ('netflow_nfdump', $config['netflow_nfdump'], false, 50, 200, true); $table->data[3][1] = html_print_input_text ('netflow_nfdump', $config['netflow_nfdump'], false, 50, 200, true);
$table->data[4][0] = '<b>'.__('Maximum chart resolution').'</b>' . ui_print_help_tip (__("Maximum number of points that a netflow area chart will display. The higher the resolution the performance. Values between 50 and 100 are recommended."), true);
$table->data[4][1] = html_print_input_text ('netflow_max_resolution', $config['netflow_max_resolution'], false, 50, 200, true);
echo '<form id="netflow_setup" method="post">'; echo '<form id="netflow_setup" method="post">';
html_print_table ($table); html_print_table ($table);

View File

@ -297,6 +297,7 @@ function config_update_config () {
config_update_value ('netflow_interval', get_parameter ('netflow_interval')); config_update_value ('netflow_interval', get_parameter ('netflow_interval'));
config_update_value ('netflow_daemon', get_parameter ('netflow_daemon')); config_update_value ('netflow_daemon', get_parameter ('netflow_daemon'));
config_update_value ('netflow_nfdump', get_parameter ('netflow_nfdump')); config_update_value ('netflow_nfdump', get_parameter ('netflow_nfdump'));
config_update_value ('netflow_max_resolution', get_parameter ('netflow_max_resolution'));
break; break;
} }
@ -558,7 +559,7 @@ function config_process_config () {
} }
if (!isset ($config['netflow_interval'])) { if (!isset ($config['netflow_interval'])) {
config_update_value ( 'netflow_interval', SECONDS_5MINUTES); config_update_value ( 'netflow_interval', SECONDS_10MINUTES);
} }
if (!isset ($config['netflow_daemon'])) { if (!isset ($config['netflow_daemon'])) {
@ -569,6 +570,10 @@ function config_process_config () {
config_update_value ( 'netflow_nfdump', '/usr/bin/nfdump'); config_update_value ( 'netflow_nfdump', '/usr/bin/nfdump');
} }
if (!isset ($config['netflow_max_resolution'])) {
config_update_value ( 'netflow_max_resolution', '50');
}
if (!isset ($config['auth'])) { if (!isset ($config['auth'])) {
config_update_value ( 'auth', 'mysql'); config_update_value ( 'auth', 'mysql');
} }

View File

@ -352,8 +352,8 @@ function netflow_summary_table ($data) {
$table->style[1] = 'border: 1px solid black;padding: 4px'; $table->style[1] = 'border: 1px solid black;padding: 4px';
$table->data[0][0] = '<b>'.__('Total flows').'</b>'; $table->data[0][0] = '<b>'.__('Total flows').'</b>';
$table->data[0][1] = format_numeric ($data['totalflows']); $table->data[0][1] = format_numeric ($data['totalflows']);
$table->data[1][0] = '<b>'.__('Total megabytes').'</b>'; $table->data[1][0] = '<b>'.__('Total bytes').'</b>';
$table->data[1][1] = format_numeric ((int)($data['totalbytes'] / 1048576)); $table->data[1][1] = format_numeric ($data['totalbytes']);
$table->data[2][0] = '<b>'.__('Total packets').'</b>'; $table->data[2][0] = '<b>'.__('Total packets').'</b>';
$table->data[2][1] = format_numeric ($data['totalpackets']); $table->data[2][1] = format_numeric ($data['totalpackets']);
$table->data[3][0] = '<b>'.__('Average bits per second'). '</b>'; $table->data[3][0] = '<b>'.__('Average bits per second'). '</b>';
@ -506,8 +506,8 @@ function netflow_get_data_from_summary ($start_date, $end_date, $interval_length
} }
// Set a max number of intervals // Set a max number of intervals
if ($num_intervals > 100) { if ($num_intervals > $config['netflow_max_resolution']) {
$num_intervals = 50; $num_intervals = $config['netflow_max_resolution'];
$interval_length = (int) ($period / $num_intervals); $interval_length = (int) ($period / $num_intervals);
} }
@ -623,23 +623,7 @@ $total += $values[$interval_start]['data'];
continue; continue;
} }
switch ($unit){ $values['data'][$interval_start][$line['agg']] = $line['data'];
case "megabytes":
$values['data'][$interval_start][$line['agg']] = $line['data'] / 1024;
break;
case "megabytespersecond":
$values['data'][$interval_start][$line['agg']] = $line['data'] / 1024 / ($end_date - $start_date);
break;
case "kilobytes":
$values['data'][$interval_start][$line['agg']] = $line['data'];
break;
case "kilobytespersecond":
$values['data'][$interval_start][$line['agg']] = $line['data'] / ($end_date - $start_date);
break;
default:
$values['data'][$interval_start][$line['agg']] = $line['data'] * 1024;
break;
}
} }
} }
} }
@ -727,8 +711,12 @@ function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $
$values[$i]['data'] = $val[9] / 1024 / $interval_length; $values[$i]['data'] = $val[9] / 1024 / $interval_length;
break; break;
default: default:
case "bytes":
$values[$i]['data'] = $val[9]; $values[$i]['data'] = $val[9];
break; break;
case "bytespersecond":
$values[$i]['data'] = $val[9] / $interval_length;
break;
} }
$i++; $i++;
} }
@ -1075,8 +1063,12 @@ function netflow_parse_file ($start_date, $end_date, $interval_length, $file, &$
$values['data'][$timestamp][$agg] = $interval_total[$agg] / 1024 / $interval_length; $values['data'][$timestamp][$agg] = $interval_total[$agg] / 1024 / $interval_length;
break; break;
default: default:
case 'bytes':
$values['data'][$timestamp][$agg] = $interval_total[$agg]; $values['data'][$timestamp][$agg] = $interval_total[$agg];
break; break;
case 'bytespersecond':
$values['data'][$timestamp][$agg] = $interval_total[$agg] / $interval_length;
break;
} }
$no_data = 0; $no_data = 0;
@ -1092,21 +1084,25 @@ function netflow_parse_file ($start_date, $end_date, $interval_length, $file, &$
// Calculate interval data // Calculate interval data
switch ($unit) { switch ($unit) {
case 'megabytes': case 'megabytes':
$values[$timestamp]['data'] = $interval_total / 1048576; $values[$timestamp]['data'] = $interval_total / 1048576;
break; break;
case 'megabytespersecond': case 'megabytespersecond':
$values[$timestamp]['data'] = $interval_total / 1048576 / $interval_length; $values[$timestamp]['data'] = $interval_total / 1048576 / $interval_length;
break; break;
case 'kilobytes': case 'kilobytes':
$values[$timestamp]['data'] = $interval_total / 1024; $values[$timestamp]['data'] = $interval_total / 1024;
break; break;
case 'kilobytespersecond': case 'kilobytespersecond':
$values[$timestamp]['data'] = $interval_total / 1024 / $interval_length; $values[$timestamp]['data'] = $interval_total / 1024 / $interval_length;
break; break;
default: default:
case 'bytes':
$values[$timestamp]['data'] = $interval_total; $values[$timestamp]['data'] = $interval_total;
break; break;
case 'bytespersecond':
$values[$timestamp]['data'] = $interval_total / $interval_length;
break;
} }
$no_data = 0; $no_data = 0;
@ -1679,6 +1675,10 @@ function netflow_format_unit ($unit) {
return __('kB'); return __('kB');
case 'kilobytespersecond': case 'kilobytespersecond':
return __('kB/s'); return __('kB/s');
case 'bytes':
return __('B');
case 'bytespersecond':
return __('B/s');
default: default:
return ''; return '';
} }

View File

@ -240,7 +240,7 @@ echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&s
$table->data[6][1] = html_print_select ($aggregate_list, "aggregate", $filter['aggregate'], '', '', 0, true, false, true, '', false); $table->data[6][1] = html_print_select ($aggregate_list, "aggregate", $filter['aggregate'], '', '', 0, true, false, true, '', false);
$table->data[6][2] = '<b>'.__('Output format').'</b>'; $table->data[6][2] = '<b>'.__('Output format').'</b>';
$show_output = array ('kilobytes' => __('Kilobytes'), 'megabytes' => __('Megabytes'), 'kilobytespersecond' => __('Kilobytes per second'), 'megabytespersecond' => __('Megabytes per second')); $show_output = array ('bytes' => __('Bytes'), 'bytespersecond' => __('Bytes per second'), 'kilobytes' => __('Kilobytes'), 'megabytes' => __('Megabytes'), 'kilobytespersecond' => __('Kilobytes per second'), 'megabytespersecond' => __('Megabytes per second'));
$table->data[6][3] = html_print_select ($show_output, 'output', $filter['output'], '', '', 0, true, false, true, '', false); $table->data[6][3] = html_print_select ($show_output, 'output', $filter['output'], '', '', 0, true, false, true, '', false);
html_print_table ($table); html_print_table ($table);

View File

@ -88,9 +88,10 @@ INSERT INTO tconfig (token, value) VALUES ('integria_api_password', ' ');
INSERT INTO tconfig (token, value) VALUES ('integria_inventory', '0'); INSERT INTO tconfig (token, value) VALUES ('integria_inventory', '0');
INSERT INTO tconfig (token, value) VALUES ('integria_url', ' '); INSERT INTO tconfig (token, value) VALUES ('integria_url', ' ');
INSERT INTO tconfig (token, value) VALUES ('netflow_path', '/var/spool/pandora/data_in/netflow'); INSERT INTO tconfig (token, value) VALUES ('netflow_path', '/var/spool/pandora/data_in/netflow');
INSERT INTO tconfig (token, value) VALUES ('netflow_interval', '300'); INSERT INTO tconfig (token, value) VALUES ('netflow_interval', '3600');
INSERT INTO tconfig (token, value) VALUES ('netflow_daemon', '/usr/bin/nfcapd'); INSERT INTO tconfig (token, value) VALUES ('netflow_daemon', '/usr/bin/nfcapd');
INSERT INTO tconfig (token, value) VALUES ('netflow_nfdump', '/usr/bin/nfdump'); INSERT INTO tconfig (token, value) VALUES ('netflow_nfdump', '/usr/bin/nfdump');
INSERT INTO tconfig (token, value) VALUES ('netflow_max_resolution', '50');
INSERT INTO tconfig (token, value) VALUES ('event_fields', 'evento,id_agente,estado,timestamp'); INSERT INTO tconfig (token, value) VALUES ('event_fields', 'evento,id_agente,estado,timestamp');
INSERT INTO tconfig (token, value) VALUES ('list_ACL_IPs_for_API', '127.0.0.1'); INSERT INTO tconfig (token, value) VALUES ('list_ACL_IPs_for_API', '127.0.0.1');
INSERT INTO tconfig (token, value) VALUES ('enable_pass_policy', 0); INSERT INTO tconfig (token, value) VALUES ('enable_pass_policy', 0);

View File

@ -84,9 +84,10 @@ INSERT INTO "tconfig" ("token", "value") VALUES
('integria_inventory', '0'), ('integria_inventory', '0'),
('integria_url', ''), ('integria_url', ''),
('netflow_path', '/var/spool/pandora/data_in/netflow'), ('netflow_path', '/var/spool/pandora/data_in/netflow'),
('netflow_interval', '300'), ('netflow_interval', '3600'),
('netflow_daemon', '/usr/bin/nfcapd'), ('netflow_daemon', '/usr/bin/nfcapd'),
('netflow_nfdump', '/usr/bin/nfdump'), ('netflow_nfdump', '/usr/bin/nfdump'),
('netflow_max_resolution', '50'),
('event_fields', 'evento,id_agente,estado,timestamp'), ('event_fields', 'evento,id_agente,estado,timestamp'),
('list_ACL_IPs_for_API', '127.0.0.1'), ('list_ACL_IPs_for_API', '127.0.0.1'),
('enable_pass_policy', 0), ('enable_pass_policy', 0),

View File

@ -83,9 +83,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('integria_inventory', '0'), ('integria_inventory', '0'),
('integria_url', ''), ('integria_url', ''),
('netflow_path', '/var/spool/pandora/data_in/netflow'), ('netflow_path', '/var/spool/pandora/data_in/netflow'),
('netflow_interval', '86400'), ('netflow_interval', '3600'),
('netflow_daemon', '/usr/bin/nfcapd'), ('netflow_daemon', '/usr/bin/nfcapd'),
('netflow_nfdump', '/usr/bin/nfdump'), ('netflow_nfdump', '/usr/bin/nfdump'),
('netflow_max_resolution', '50'),
('event_fields', 'evento,id_agente,estado,timestamp'), ('event_fields', 'evento,id_agente,estado,timestamp'),
('list_ACL_IPs_for_API', '127.0.0.1'), ('list_ACL_IPs_for_API', '127.0.0.1'),
('enable_pass_policy', 0), ('enable_pass_policy', 0),