diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7e345716c6..7022161cc2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,25 @@ +2012-01-24 Ramon Novoa + + * include/functions_config.php, + include/functions_netflow.php, + pandoradb.sql, + pandoradb.postgreSQL.sql, + pandoradb.oracle.sql, + operation/netflow/nf_live_view.php, + extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql, + extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql, + extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql, + godmode/agentes/module_manager_editor_prediction.php, + godmode/agentes/configurar_agente.php, + godmode/menu.php, + godmode/netflow/nf_edit_form.php: Added support for enterprise + netflow modules. + + * godmode/netflow/nf_manage.php: Moved to + godmode/setup/setup_netflow.php. + + * godmode/netflow/nf_option_form.php: Removed from repository. Not used. + 2010-01-24 Javier Lanz * godmode/massive/massive_delete_modules.php: Fixed a small entities bug. Added io_safe_output diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql index 034d782d8f..c77a6bdb95 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql @@ -4,12 +4,14 @@ CREATE TABLE IF NOT EXISTS `tnetflow_filter` ( `id_sg` int(10) unsigned NOT NULL auto_increment, - `id_name` varchar(60) NOT NULL default '0', + `id_name` varchar(600) NOT NULL default '0', `id_group` int(10), - `ip_dst` varchar(100), - `ip_src` varchar(100), - `dst_port` varchar(100), - `src_port` varchar(100), + `ip_dst` TEXT NOT NULL, + `ip_src` TEXT NOT NULL, + `dst_port` TEXT NOT NULL, + `src_port` TEXT NOT NULL, + `advanced_filter` TEXT NOT NULL, + `filter_args` TEXT NOT NULL, `aggregate` varchar(60), `output` varchar(60), PRIMARY KEY (`id_sg`) @@ -34,7 +36,7 @@ PRIMARY KEY(`id_report`) CREATE TABLE IF NOT EXISTS `tnetflow_report_content` ( `id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `id_report` INTEGER UNSIGNED NOT NULL default 0, - `id_filter` INTEGER UNSIGNED NOT NULL default 0, + `id_filter` INTEGER UNSIGNED NOT NULL default 0, `date` bigint(20) NOT NULL default '0', `period` int(11) NOT NULL default 0, `max` int (11) NOT NULL default 0, @@ -42,10 +44,10 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report_content` ( `order` int (11) NOT NULL default 0, PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES tnetflow_report(`id_report`) - ON UPDATE CASCADE ON DELETE CASCADE, + ON DELETE CASCADE, FOREIGN KEY (`id_filter`) REFERENCES tnetflow_filter(`id_sg`) ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET=utf8; +) ENGINE = InnoDB DEFAULT CHARSET=utf8 -- ----------------------------------------------------- -- Table `tusuario` diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql index 0717af406e..118aec008b 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql @@ -10,12 +10,14 @@ alter table tusuario add (disabled NUMBER(10,0) default 0 NOT NULL); CREATE TABLE tnetflow_filter ( id_sg NUMBER(10, 0) NOT NULL PRIMARY KEY, -id_name VARCHAR2(100) NOT NULL, +id_name VARCHAR2(600) NOT NULL, id_group NUMBER(10, 0), -ip_dst VARCHAR2(100), -ip_src VARCHAR2(100), -dst_port VARCHAR2(100), -src_port VARCHAR2(100), +ip_dst CLOB NOT NULL, +ip_src CLOB NOT NULL, +dst_port CLOB NOT NULL, +src_port CLOB NOT NULL, +advanced_filter CLOB NOT NULL, +filter_args CLOB NOT NULL, aggregate VARCHAR2(60), output VARCHAR2(60) ); diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql index f3b983bf35..682ec367e8 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql @@ -9,12 +9,14 @@ ALTER TABLE "tusuario" ADD COLUMN "disabled" INTEGER NOT NULL DEFAULT 0; -- ----------------------------------------------------- CREATE TABLE "tnetflow_filter" ( "id_sg" SERIAL NOT NULL PRIMARY KEY, - "id_name" varchar(60) NOT NULL default '', + "id_name" varchar(600) NOT NULL default '', "id_group" INTEGER, - "ip_dst" varchar(100), - "ip_src" varchar(100), - "dst_port" varchar(100), - "src_port" varchar(100), + "ip_dst" TEXT NOT NULL, + "ip_src" TEXT NOT NULL, + "dst_port" TEXT NOT NULL, + "src_port" TEXT NOT NULL, + "advanced_filter" TEXT NOT NULL, + "filter_args" TEXT NOT NULL, "aggregate" varchar(60), "output" varchar(60) ); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index be43f048aa..0878b34c5e 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -706,7 +706,7 @@ if ($update_module || $create_module) { $id_tag = (array) get_parameter('id_tag_selected'); $serialize_ops = (string) get_parameter('serialize_ops'); - if($prediction_module < 3) { + if($prediction_module != 3) { unset($serialize_ops); enterprise_hook('modules_delete_synthetic_operations', array($id_agent_module)); } diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index c58dba1344..08f3a7afb8 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -28,6 +28,7 @@ $row = db_get_row_sql($sql); $is_service = false; $is_synthetic = false; $is_synthetic_avg = false; +$is_netflow = false; $ops = false; if ($row !== false && is_array($row)) { $prediction_module = $row['prediction_module']; @@ -56,6 +57,10 @@ if ($row !== false && is_array($row)) { $custom_integer_1 = 0; $custom_integer_2 = 0; break; + case 4: + $is_netflow = true; + $custom_integer_2 = 0; + break; default: $prediction_module = $custom_integer_1; } @@ -79,7 +84,7 @@ $data[0] = __('Source module'); $data[0] .= ui_print_help_icon ('prediction_source_module', true); $data[1] = ''; // Services and Synthetic are an Enterprise feature. -$module_service_synthetic_selector = enterprise_hook('get_module_service_synthetic_selector', array($is_service, $is_synthetic, $is_synthetic_avg)); +$module_service_synthetic_selector = enterprise_hook('get_module_service_synthetic_selector', array($is_service, $is_synthetic, $is_synthetic_avg, $is_netflow)); if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) { $data[1] = $module_service_synthetic_selector; @@ -145,6 +150,18 @@ if ($synthetic_module_form !== ENTERPRISE_NOT_HOOK) { push_table_simple ($data, 'synthetic_module'); } +// Netflow modules are an Enterprise feature. +$netflow_module_form = enterprise_hook ('get_netflow_module_form', array($custom_integer_1)); +if ($netflow_module_form !== ENTERPRISE_NOT_HOOK) { + $data = array(); + $data[0] = ''; + $data[1] = $netflow_module_form; + + $table_simple->colspan['netflow_module_form'][1] = 3; + push_table_simple ($data, 'netflow_module'); +} + + /* Removed common useless parameter */ unset ($table_advanced->data[3]); unset ($table_advanced->data[2][2]); @@ -154,7 +171,7 @@ unset ($table_advanced->data[2][3]); $(document).ready(function() { agent_module_autocomplete ("#text_agent_name", "#id_agente", "#prediction_module"); }); diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 9141285a0c..5492602ee0 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -212,7 +212,7 @@ if (check_acl ($config['id_user'], 0, "PM")) { $sub["godmode/setup/setup_visuals"]["text"] = __('Visual styles'); $sub["godmode/setup/file_manager"]["text"] = __('File manager'); if ($config['activate_netflow']) - $sub["godmode/netflow/nf_manage"]["text"] = __('Netflow'); + $sub["godmode/setup/setup_netflow"]["text"] = __('Netflow'); if ($config['activate_gis']) $sub["godmode/setup/gis"]["text"] = __('Map conections GIS'); $sub["godmode/setup/links"]["text"] = __('Links'); diff --git a/pandora_console/godmode/netflow/nf_edit_form.php b/pandora_console/godmode/netflow/nf_edit_form.php index a2fb12d141..9f71b4e110 100644 --- a/pandora_console/godmode/netflow/nf_edit_form.php +++ b/pandora_console/godmode/netflow/nf_edit_form.php @@ -93,18 +93,22 @@ if ($update) { if ($name == '') { ui_print_error_message (__('Not updated. Blank name')); } else { - $result = db_process_sql_update ('tnetflow_filter', - array ('id_sg' => $id, - 'id_name' => $name, - 'id_group' => $assign_group, - 'aggregate' => $aggregate, - 'ip_dst' => $ip_dst, - 'ip_src' => $ip_src, - 'dst_port' => $dst_port, - 'src_port' => $src_port, - 'advanced_filter' => $advanced_filter, - 'output' => $output), - array ('id_sg' => $id)); + $values = array ('id_sg' => $id, + 'id_name' => $name, + 'id_group' => $assign_group, + 'aggregate' => $aggregate, + 'ip_dst' => $ip_dst, + 'ip_src' => $ip_src, + 'dst_port' => $dst_port, + 'src_port' => $src_port, + 'advanced_filter' => $advanced_filter, + 'output' => $output + ); + + // Save filter args + $values['filter_args'] = netflow_get_filter_arguments ($values); + + $result = db_process_sql_update ('tnetflow_filter', $values, array ('id_sg' => $id)); ui_print_result_message ($result, __('Successfully updated'), @@ -134,6 +138,9 @@ if ($create){ 'advanced_filter'=>$advanced_filter, 'output'=>$output ); + + // Save filter args + $values['filter_args'] = netflow_get_filter_arguments ($values); $id = db_process_sql_insert('tnetflow_filter', $values); if ($id === false) { diff --git a/pandora_console/godmode/netflow/nf_option_form.php b/pandora_console/godmode/netflow/nf_option_form.php deleted file mode 100644 index 1fdecece3e..0000000000 --- a/pandora_console/godmode/netflow/nf_option_form.php +++ /dev/null @@ -1,143 +0,0 @@ -' - . html_print_image ("images/edit.png", true, array ("title" => __('Option list'))) - . ''; - -//Header -ui_print_page_header (__('Netflow Options'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); - -if ($id) { - $option = netflow_options_get_options ($id); - $name = $option['id_name']; - $description = $option['description']; - $path = $option['path']; - $port = $option['port']; - -} else { - $name = ''; - $description = ''; - $path = ''; - $port = ''; -} - -if ($update) { - $name = (string) get_parameter ('name'); - $description = (int) get_parameter ('description',''); - $path = get_parameter('path',''); - $port = get_parameter('port',''); - - if ($name == '') { - ui_print_error_message (__('Not updated. Blank name')); - } else { - $result = db_process_sql_update ('tnetflow_options', - array ('id_option' => $id, - 'id_name' => $name, - 'description' => $description, - 'path' => $path, - 'port' => $port - ), - array ('id_option' => $id)); - - ui_print_result_message ($result, - __('Successfully updated'), - __('Not updated. Error updating data')); - } -} - -if ($create){ - $name = (string) get_parameter ('name'); - $description = (string) get_parameter ('description',''); - $path = get_parameter('path',''); - $port = get_parameter('port',''); - - if($name == db_get_value('id_name', 'tnetflow_options', 'id_name', $name)){ - $result = false; - } else { - $values = array ( - 'id_name'=>$name, - 'description' => $description, - 'path'=>$path, - 'port'=>$port - ); - $result = db_process_sql_insert('tnetflow_options', $values); - } - if ($result === false) - echo '

'.__ ('Error creating filter').'

'; - else - echo '

'.__ ('Option created successfully').'

'; -} - -$table->width = '80%'; -$table->border = 0; -$table->cellspacing = 3; -$table->cellpadding = 5; -$table->class = "databox_color"; -$table->style[0] = 'vertical-align: top;'; - -$table->data = array (); - -$table->data[0][0] = ''.__('Name').''; -$table->data[0][1] = html_print_input_text ('name', $name, false, 50, 80, true); - -$table->data[1][0] = ''.__('Description').''; -$table->data[1][1] = html_print_textarea ('description', 2, 65, $description, '', true); - -$table->data[2][0] = ''.__('Path').''; -//$table->data[2][1] = html_print_input_text ('path', $config['netflow_path'], false, 50, 200, true); -$table->data[2][1] = html_print_input_text ('path', $path, false, 50, 200, true); - -$table->data[3][0] = ''.__('Port').''; -$table->data[3][1] = html_print_input_text ('port', $port, false, 10, 80, true); - - -echo '
'; -html_print_table ($table); -echo '
'; -if ($id) { - html_print_input_hidden ('update', 1); - html_print_input_hidden ('id', $id); - html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"'); -} else { - html_print_input_hidden ('create', 1); - html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"'); -} -echo '
'; -echo '
'; -?> diff --git a/pandora_console/godmode/netflow/nf_manage.php b/pandora_console/godmode/setup/setup_netflow.php similarity index 78% rename from pandora_console/godmode/netflow/nf_manage.php rename to pandora_console/godmode/setup/setup_netflow.php index e775180f42..6f93fb1c42 100644 --- a/pandora_console/godmode/netflow/nf_manage.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -35,17 +35,6 @@ ui_print_page_header (__('Netflow Manager'), "images/networkmap/so_cisco_new.png $update = (bool) get_parameter ("update"); -if ($update) { - - $config['netflow_path'] = (string)get_parameter('netflow_path'); - $config['netflow_interval'] = (int)get_parameter('netflow_interval'); - $config['netflow_daemon'] = (string)get_parameter('netflow_daemon'); - - db_process_sql_update ('tconfig', array ('value' => $config['netflow_path']), array ('token' => 'netflow_path')); - db_process_sql_update ('tconfig', array ('value' => $config['netflow_interval']), array ('token' => 'netflow_interval')); - db_process_sql_update ('tconfig', array ('value' => $config['netflow_daemon']), array ('token' => 'netflow_daemon')); -} - $table->width = '70%'; $table->border = 0; $table->cellspacing = 3; @@ -68,7 +57,7 @@ html_print_table ($table); // Update button echo '
'; - html_print_input_hidden ('update', 1); + html_print_input_hidden ('update_config', 1); html_print_submit_button (__('Update'), 'upd_button', false, 'class="sub upd"'); echo '
'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 42a28edd20..efc80fb834 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -185,6 +185,9 @@ function config_update_config () { config_update_value ('timezone', (string) get_parameter ('timezone', $config['timezone'])); config_update_value ('activate_gis', (bool) get_parameter ('activate_gis', $config['activate_gis'])); config_update_value ('activate_netflow', (bool) get_parameter ('activate_netflow', $config['activate_netflow'])); + config_update_value ('netflow_path', get_parameter ('netflow_path', $config['netflow_path'])); + config_update_value ('netflow_interval', get_parameter ('netflow_interval', $config['netflow_interval'])); + config_update_value ('netflow_daemon', get_parameter ('netflow_daemon', $config['netflow_daemon'])); config_update_value ('stats_interval', get_parameter ('stats_interval', $config['stats_interval'])); config_update_value ('realtimestats', get_parameter ('realtimestats', $config['realtimestats'])); config_update_value ('event_purge', get_parameter ('event_purge', $config['event_purge'])); @@ -482,6 +485,18 @@ function config_process_config () { config_update_value ( 'activate_netflow', 0); } + if (!isset ($config['netflow_path'])) { + config_update_value ( 'netflow_path', '/var/spool/pandora/data_in/netflow'); + } + + if (!isset ($config['netflow_interval'])) { + config_update_value ( 'netflow_interval', 300); + } + + if (!isset ($config['netflow_daemon'])) { + config_update_value ( 'netflow_daemon', '/usr/bin/nfcapd'); + } + 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 f23f0cbfbb..c5330a37e3 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -448,12 +448,27 @@ function netflow_get_command ($filter) { $command .= ' -R '.$config['netflow_path']; } + // Filter options + $command .= netflow_get_filter_arguments ($filter); + + return $command; +} + +/** + * Returns the nfdump command line arguments that match the given filter. + * + * @param array filter Netflow filter. + * + * @return Command line argument string. + * + */ +function netflow_get_filter_arguments ($filter) { + // Advanced filter $filter_args = ''; if ($filter['advanced_filter'] != '') { $filter_args = preg_replace('/["\r\n]/','', io_safe_output ($filter['advanced_filter'])); - $command .= ' "(' . $filter_args . ')"'; - return $command; + return ' "(' . $filter_args . ')"'; } // Normal filter @@ -524,11 +539,10 @@ function netflow_get_command ($filter) { $filter_args .= ')'; } if ($filter_args != '') { - $filter_args .= '"'; - $command .= $filter_args; + $filter_args .= '"'; } - return $command; + return $filter_args; } diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 5f33cd8ec8..17771f382a 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -67,6 +67,10 @@ ui_print_page_header (__('Netflow live view'), "images/networkmap/so_cisco_new.p // Save user defined filter if ($save != '') { + + // Save filter args + $filter['filter_args'] = netflow_get_filter_arguments ($filter); + $filter_id = db_process_sql_insert ('tnetflow_filter', $filter); if ($filter_id === false) { $filter_id = 0; @@ -81,6 +85,9 @@ else if ($update != '' && $filter_id > 0) { $filter_copy = $filter; unset ($filter_copy['id_name']); unset ($filter_copy['id_group']); + + // Save filter args + $filter_copy['filter_args'] = netflow_get_filter_arguments ($filter_copy); $result = db_process_sql_update ('tnetflow_filter', $filter_copy, array ('id_sg' => $filter_id)); ui_print_result_message ($result, __('Filter updated successfully'), __('Error updating filter')); diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index 5b59609911..1327cb8209 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -1491,6 +1491,7 @@ ip_src CLOB NOT NULL, dst_port CLOB NOT NULL, src_port CLOB NOT NULL, advanced_filter CLOB NOT NULL, +filter_args CLOB NOT NULL, aggregate VARCHAR2(60), output VARCHAR2(60) ); diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index c5eba39c3c..a7d6cc05d4 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -1204,6 +1204,7 @@ CREATE TABLE "tnetflow_filter" ( "dst_port" TEXT NOT NULL, "src_port" TEXT NOT NULL, "advanced_filter" TEXT NOT NULL, + "filter_args" TEXT NOT NULL, "aggregate" varchar(60), "output" varchar(60) ); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 84815891fb..9d5aa1fcbf 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1295,6 +1295,7 @@ CREATE TABLE IF NOT EXISTS `tnetflow_filter` ( `dst_port` TEXT NOT NULL, `src_port` TEXT NOT NULL, `advanced_filter` TEXT NOT NULL, + `filter_args` TEXT NOT NULL, `aggregate` varchar(60), `output` varchar(60), PRIMARY KEY (`id_sg`)