diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b7329a7f30..d9beb129cb 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2012-12-12 Ramon Novoa + + * 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 * include/functions_config.php: Added configuration diff --git a/pandora_console/godmode/setup/setup_netflow.php b/pandora_console/godmode/setup/setup_netflow.php index 441ddfb6db..da63ddf52b 100644 --- a/pandora_console/godmode/setup/setup_netflow.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -52,7 +52,9 @@ $table->data[2][0] = ''.__('Daemon binary path').''; $table->data[2][1] = html_print_input_text ('netflow_daemon', $config['netflow_daemon'], false, 50, 200, true); $table->data[3][0] = ''.__('Nfdump binary path').''; $table->data[3][1] = html_print_input_text ('netflow_nfdump', $config['netflow_nfdump'], false, 50, 200, true); - +$table->data[4][0] = ''.__('Maximum chart resolution').'' . 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 '
'; html_print_table ($table); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 89d2d19c8f..95e5d4fb0a 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -297,6 +297,7 @@ function config_update_config () { config_update_value ('netflow_interval', get_parameter ('netflow_interval')); config_update_value ('netflow_daemon', get_parameter ('netflow_daemon')); config_update_value ('netflow_nfdump', get_parameter ('netflow_nfdump')); + config_update_value ('netflow_max_resolution', get_parameter ('netflow_max_resolution')); break; } @@ -558,7 +559,7 @@ function config_process_config () { } if (!isset ($config['netflow_interval'])) { - config_update_value ( 'netflow_interval', SECONDS_5MINUTES); + config_update_value ( 'netflow_interval', SECONDS_10MINUTES); } if (!isset ($config['netflow_daemon'])) { @@ -569,6 +570,10 @@ function config_process_config () { 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'])) { config_update_value ( 'auth', 'mysql'); } diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 7cfc8e9c57..172c70635f 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -352,8 +352,8 @@ function netflow_summary_table ($data) { $table->style[1] = 'border: 1px solid black;padding: 4px'; $table->data[0][0] = ''.__('Total flows').''; $table->data[0][1] = format_numeric ($data['totalflows']); - $table->data[1][0] = ''.__('Total megabytes').''; - $table->data[1][1] = format_numeric ((int)($data['totalbytes'] / 1048576)); + $table->data[1][0] = ''.__('Total bytes').''; + $table->data[1][1] = format_numeric ($data['totalbytes']); $table->data[2][0] = ''.__('Total packets').''; $table->data[2][1] = format_numeric ($data['totalpackets']); $table->data[3][0] = ''.__('Average bits per second'). ''; @@ -506,8 +506,8 @@ function netflow_get_data_from_summary ($start_date, $end_date, $interval_length } // Set a max number of intervals - if ($num_intervals > 100) { - $num_intervals = 50; + if ($num_intervals > $config['netflow_max_resolution']) { + $num_intervals = $config['netflow_max_resolution']; $interval_length = (int) ($period / $num_intervals); } @@ -623,23 +623,7 @@ $total += $values[$interval_start]['data']; continue; } - switch ($unit){ - 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; - } + $values['data'][$interval_start][$line['agg']] = $line['data']; } } } @@ -727,8 +711,12 @@ function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $ $values[$i]['data'] = $val[9] / 1024 / $interval_length; break; default: + case "bytes": $values[$i]['data'] = $val[9]; break; + case "bytespersecond": + $values[$i]['data'] = $val[9] / $interval_length; + break; } $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; break; default: + case 'bytes': $values['data'][$timestamp][$agg] = $interval_total[$agg]; break; + case 'bytespersecond': + $values['data'][$timestamp][$agg] = $interval_total[$agg] / $interval_length; + break; } $no_data = 0; @@ -1092,21 +1084,25 @@ function netflow_parse_file ($start_date, $end_date, $interval_length, $file, &$ // Calculate interval data switch ($unit) { - case 'megabytes': + case 'megabytes': $values[$timestamp]['data'] = $interval_total / 1048576; break; - case 'megabytespersecond': + case 'megabytespersecond': $values[$timestamp]['data'] = $interval_total / 1048576 / $interval_length; break; - case 'kilobytes': + case 'kilobytes': $values[$timestamp]['data'] = $interval_total / 1024; break; - case 'kilobytespersecond': + case 'kilobytespersecond': $values[$timestamp]['data'] = $interval_total / 1024 / $interval_length; break; default: + case 'bytes': $values[$timestamp]['data'] = $interval_total; break; + case 'bytespersecond': + $values[$timestamp]['data'] = $interval_total / $interval_length; + break; } $no_data = 0; @@ -1679,6 +1675,10 @@ function netflow_format_unit ($unit) { return __('kB'); case 'kilobytespersecond': return __('kB/s'); + case 'bytes': + return __('B'); + case 'bytespersecond': + return __('B/s'); default: return ''; } diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index ecb21bd9dd..207860e6fc 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -240,7 +240,7 @@ echo 'data[6][2] = ''.__('Output format').''; - $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); html_print_table ($table); diff --git a/pandora_console/pandoradb.data.oracle.sql b/pandora_console/pandoradb.data.oracle.sql index 9b942390d8..2b38127b89 100644 --- a/pandora_console/pandoradb.data.oracle.sql +++ b/pandora_console/pandoradb.data.oracle.sql @@ -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_url', ' '); 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_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 ('list_ACL_IPs_for_API', '127.0.0.1'); INSERT INTO tconfig (token, value) VALUES ('enable_pass_policy', 0); diff --git a/pandora_console/pandoradb.data.postgreSQL.sql b/pandora_console/pandoradb.data.postgreSQL.sql index 31a70f6698..7daa37ad98 100644 --- a/pandora_console/pandoradb.data.postgreSQL.sql +++ b/pandora_console/pandoradb.data.postgreSQL.sql @@ -84,9 +84,10 @@ INSERT INTO "tconfig" ("token", "value") VALUES ('integria_inventory', '0'), ('integria_url', ''), ('netflow_path', '/var/spool/pandora/data_in/netflow'), -('netflow_interval', '300'), +('netflow_interval', '3600'), ('netflow_daemon', '/usr/bin/nfcapd'), ('netflow_nfdump', '/usr/bin/nfdump'), +('netflow_max_resolution', '50'), ('event_fields', 'evento,id_agente,estado,timestamp'), ('list_ACL_IPs_for_API', '127.0.0.1'), ('enable_pass_policy', 0), diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 1fffff9d96..4ab0d840fd 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -83,9 +83,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('integria_inventory', '0'), ('integria_url', ''), ('netflow_path', '/var/spool/pandora/data_in/netflow'), -('netflow_interval', '86400'), +('netflow_interval', '3600'), ('netflow_daemon', '/usr/bin/nfcapd'), ('netflow_nfdump', '/usr/bin/nfdump'), +('netflow_max_resolution', '50'), ('event_fields', 'evento,id_agente,estado,timestamp'), ('list_ACL_IPs_for_API', '127.0.0.1'), ('enable_pass_policy', 0),