diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 6fe7b6fd93..400f25545c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,23 @@ +2013-08-27 Miguel de Dios + + * pandoradb.postgreSQL.sql, pandoradb.oracle.sql, + godmode/agentes/module_manager_editor.php, + godmode/agentes/module_manager_editor_common.php, + godmode/agentes/configurar_agente.php, + godmode/massive/massive_edit_modules.php, + godmode/modules/manage_network_components_form_common.php, + godmode/modules/manage_network_components.php, + include/functions_events.php, include/functions.php, + include/javascript/pandora_modules.js, + include/functions_network_components.php, + include/functions_modules.php, include/constants.php, pandoradb.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql: first version of + disabled unknown events for modules, now it is implemented in + modules, massive operations and components, but it is necesary in + local component, policy, api, cli, pandora server and recond task. + 2013-08-27 Miguel de Dios * index.php, include/javascript/pandora.js: fixed code style. diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql index f2b7e180df..3e064677c9 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql @@ -184,6 +184,7 @@ ALTER TABLE `tagente_modulo` ADD COLUMN `warning_inverse` tinyint(1) unsigned de ALTER TABLE `tagente_modulo` ADD COLUMN `cron_interval` varchar(100) default ''; ALTER TABLE `tagente_modulo` ADD COLUMN `max_retries` int(4) UNSIGNED NOT NULL default 0; ALTER TABLE `tagente_modulo` ADD COLUMN `id_category` int(10) NOT NULL DEFAULT '0'; +ALTER TABLE `tagente_modulo` ADD COLUMN `disabled_types_event` TEXT NOT NULL DEFAULT ''; -- Move the number of retries for web modules from plugin_pass to max_retries UPDATE `tagente_modulo` SET max_retries=plugin_pass WHERE id_modulo=7; @@ -203,6 +204,7 @@ ALTER TABLE `tnetwork_component` ADD COLUMN `warning_inverse` tinyint(1) unsigne ALTER TABLE `tnetwork_component` ADD COLUMN `max_retries` int(4) UNSIGNED NOT NULL default 0; ALTER TABLE `tnetwork_component` ADD COLUMN `id_category` int(10) NOT NULL DEFAULT '0'; ALTER TABLE `tnetwork_component` ADD COLUMN `tags` TEXT NOT NULL default ''; +ALTER TABLE `tnetwork_component` ADD COLUMN `disabled_types_event` TEXT NOT NULL DEFAULT ''; -- ---------------------------------------------------------------------- -- Table `tgraph_source` Alter table to allow negative values in weight diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql index 4e2018df13..b7ca6d12af 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql @@ -319,6 +319,7 @@ WHERE token='prominent_time'; ALTER TABLE tnetwork_component ADD (wizard_level VARCHAR2(100) default 'nowizard' NOT NULL); ALTER TABLE tnetwork_component ADD CONSTRAINT t_network_component_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','nowizard')); ALTER TABLE tnetwork_component ADD (macros CLOB default ''); +ALTER TABLE tnetwork_component ADD (disabled_types_event CLOB default ''); -- ----------------------------------------------------- @@ -330,6 +331,8 @@ ALTER TABLE tagente_modulo ADD (macros CLOB default ''); ALTER TABLE tagente_modulo ADD (quiet NUMBER(5, 0) default 0 NOT NULL); ALTER TABLE tagente_modulo ADD (cron_interval VARCHAR2(100) DEFAULT ''); ALTER TABLE tagente_modulo ADD (max_retries NUMBER(10, 0) default 0); +ALTER TABLE tagente_modulo ADD (disabled_types_event CLOB default ''); + -- Move the number of retries for web modules from plugin_pass to max_retries UPDATE tagente_modulo SET max_retries=plugin_pass WHERE id_modulo=7; diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql index 5848350386..11ded7c5e0 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql @@ -207,6 +207,7 @@ ALTER TABLE "tagente_modulo" ADD COLUMN "warning_inverse" SMALLINT NOT NULL defa ALTER TABLE "tagente_modulo" ADD COLUMN "cron_interval" varchar(100) default ''; ALTER TABLE "tagente_modulo" ADD COLUMN "max_retries" INTEGER default 0; ALTER TABLE "tagente_modulo" ADD COLUMN "id_category" INTEGER default 0; +ALTER TABLE "tagente_modulo" ADD COLUMN "disabled_types_event" TEXT default ''; -- Move the number of retries for web modules from plugin_pass to max_retries UPDATE "tagente_modulo" SET max_retries=CAST(plugin_pass AS INT) WHERE id_modulo=7; @@ -281,6 +282,13 @@ ALTER TABLE "tmensajes" ALTER COLUMN "mensaje" TYPE TEXT; ALTER TABLE "tnetwork_component" ADD COLUMN "unit" text default ''; ALTER TABLE "tnetwork_component" ADD COLUMN "max_retries" INTEGER default 0; ALTER TABLE "tnetwork_component" ADD COLUMN "id_category" INTEGER default 0; +ALTER TABLE "tnetwork_component" ADD COLUMN "critical_instructions" text default ''; +ALTER TABLE "tnetwork_component" ADD COLUMN "warning_instructions" text default ''; +ALTER TABLE "tnetwork_component" ADD COLUMN "unknown_instructions" text default ''; +ALTER TABLE "tnetwork_component" ADD COLUMN "critical_inverse" SMALLINT NOT NULL default 0; +ALTER TABLE "tnetwork_component" ADD COLUMN "warning_inverse" SMALLINT NOT NULL default 0; +ALTER TABLE "tnetwork_component" ADD COLUMN "tags" text default ''; +ALTER TABLE "tnetwork_component" ADD COLUMN "disabled_types_event" TEXT default ''; -- ----------------------------------------------------- -- Table "talert_commands" @@ -356,16 +364,6 @@ ALTER TABLE "tlayout_data" ADD COLUMN "enable_link" SMALLINT NOT NULL default 1; ALTER TABLE "tlayout_data" ADD COLUMN "id_metaconsole" INTEGER NOT NULL default 0; ALTER TABLE "tlayout_data" ALTER COLUMN "label" TEXT default ''; ------------------------------------------------------------------------- --- Table "tnetwork_component" ------------------------------------------------------------------------- -ALTER TABLE "tnetwork_component" ADD COLUMN "critical_instructions" text default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "warning_instructions" text default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "unknown_instructions" text default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "critical_inverse" SMALLINT NOT NULL default 0; -ALTER TABLE "tnetwork_component" ADD COLUMN "warning_inverse" SMALLINT NOT NULL default 0; -ALTER TABLE "tnetwork_component" ADD COLUMN "tags" text default ''; - ------------------------------------------------------------------------ -- Table "tnetwork_map" ------------------------------------------------------------------------ diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index df1b4915ab..7c6d7f3c01 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -890,6 +890,11 @@ if ($update_module || $create_module) { //LOST CODE? } + $throw_unknown_events = (bool)get_parameter('throw_unknown_events', false); + //Set the event type that can show. + $disabled_types_event = array(EVENTS_GOING_UNKNOWN => (int)!$throw_unknown_events); + $disabled_types_event = json_encode($disabled_types_event); + // Make changes in the conf file if necessary enterprise_include_once('include/functions_config_agents.php'); enterprise_hook('config_agents_write_module_in_conf', @@ -947,7 +952,8 @@ if ($update_module) { 'critical_inverse' => $critical_inverse, 'warning_inverse' => $warning_inverse, 'cron_interval' => $cron_interval, - 'id_category' => $id_category); + 'id_category' => $id_category, + 'disabled_types_event' => $disabled_types_event); if ($prediction_module == 3 && $serialize_ops == '') { $result = false; @@ -1069,7 +1075,8 @@ if ($create_module) { 'critical_inverse' => $critical_inverse, 'warning_inverse' => $warning_inverse, 'cron_interval' => $cron_interval, - 'id_category' => $id_category); + 'id_category' => $id_category, + 'disabled_types_event' => $disabled_types_event); if ($prediction_module == 3 && $serialize_ops == '') { $id_agent_module = false; diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 692260fc5e..d548b75aec 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -29,6 +29,10 @@ if (is_ajax ()) { $component = db_get_row ('tnetwork_component', 'id_nc', $id_component); + $component['throw_unknown_events'] = + !network_components_is_disable_type_event($id_component, EVENTS_GOING_UNKNOWN); + + echo json_encode ($component); return; } @@ -299,11 +303,11 @@ else { $is_function_policies = enterprise_include_once('include/functions_policies.php'); -if($is_function_policies !== ENTERPRISE_NOT_HOOK) { +if ($is_function_policies !== ENTERPRISE_NOT_HOOK) { $relink_policy = get_parameter('relink_policy', 0); $unlink_policy = get_parameter('unlink_policy', 0); - if($relink_policy) { + if ($relink_policy) { $policy_info = policies_info_module_policy($id_agent_module); $policy_id = $policy_info['id_policy']; @@ -318,7 +322,7 @@ if($is_function_policies !== ENTERPRISE_NOT_HOOK) { } } - if($unlink_policy) { + if ($unlink_policy) { $result = policies_unlink_module($id_agent_module); ui_print_result_message($result, __('Module will be unlinked in the next application')); diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 934f89261e..c68360ef40 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -343,7 +343,12 @@ if ($__code_from == 'policies') { } $table_advanced->data[4][1] = html_print_select_from_sql ('SELECT id, name FROM tserver_export ORDER BY name', 'id_export', $id_export, '', $none_text, '0', true, false, false, $disabled_export).ui_print_help_tip (__('In case you use an Export server you can link this module and export data to one these.'), true); -$table_advanced->colspan[4][1] = 4; +$table_advanced->colspan[4][1] = 2; + +$table_advanced->data[4][3] = __('Throw unknown events'); +$table_advanced->data[4][4] = html_print_checkbox('throw_unknown_events', + 1, !modules_is_disable_type_event($id_agent_module, EVENTS_GOING_UNKNOWN), true); + $table_advanced->data[5][0] = __('Unit'); $table_advanced->data[5][1] = html_print_input_text ('unit', $unit, '', 20, 65, true); diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 05b31bde05..3b19d00f44 100644 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -79,18 +79,25 @@ if ($update) { if ($module_type != 0) $condition = ' AND t2.id_tipo_modulo = '.$module_type; - $agents_ = db_get_all_rows_sql('SELECT DISTINCT(t1.id_agente) - FROM tagente t1, tagente_modulo t2 - WHERE t1.id_agente = t2.id_agente AND t2.delete_pending = 0 ' . $condition); - foreach($agents_ as $id_agent) { - $module_name = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent, 'id_tipo_modulo' => $module_type, 'delete_pending' => 0),'nombre'); + $agents_ = db_get_all_rows_sql(' + SELECT DISTINCT(t1.id_agente) + FROM tagente AS t1, tagente_modulo AS t2 + WHERE t1.id_agente = t2.id_agente + AND t2.delete_pending = 0 ' . $condition); + foreach ($agents_ as $id_agent) { + $module_name = db_get_all_rows_filter('tagente_modulo', + array('id_agente' => $id_agent, + 'id_tipo_modulo' => $module_type, + 'delete_pending' => 0), + 'nombre'); - if($module_name == false) { + if ($module_name == false) { $module_name = array(); } foreach ($module_name as $mod_name) { - $result = process_manage_edit ($mod_name['nombre'], $id_agent['id_agente']); - $count ++; + $result = process_manage_edit($mod_name['nombre'], + $id_agent['id_agente']); + $count++; $success += (int)$result; } } @@ -427,6 +434,20 @@ if (enterprise_installed()) { $table->data['edit81'][3] = html_print_select (array(MODULE_PENDING_LINK => __('Linked'), MODULE_PENDING_UNLINK => __('Unlinked')), 'policy_linked', '','', __('No change'), '', true, false, false); } +if ($table->rowspan['edit8'][0] == 2) { + $table->rowspan['edit8'][0] = $table->rowspan['edit8'][1] = 3; +} +else { + $table->rowspan['edit8'][0] = $table->rowspan['edit8'][1] = 2; +} +$table->data['edit82'][2] = __('Throw unknown events'); + +$table->data['edit82'][3] = html_print_select( + array('' => __('No change'), + '1' => __('Yes'), + '0' => __('No')), + 'throw_unknown_events','','','', '', true); + $table->data['edit10'][0] = ''.__('Critical instructions'). ''. ui_print_help_tip(__("Instructions when the status is critical"), true); $table->data['edit10'][1] = html_print_textarea ('critical_instructions', 2, 50, '', '', true); $table->colspan['edit10'][1] = 3; @@ -596,6 +617,7 @@ $(document).ready (function () { "tr#delete_table-edit12").hide (); $('input[type=checkbox]').attr('checked', false); $('input[type=checkbox]').attr('disabled', true); + $('#module_type').val(-1); $('#groups_select').val(-1); } @@ -792,7 +814,7 @@ function process_manage_edit ($module_name, $agents_select = null) { 'id_export', 'history_data', 'critical_inverse', 'warning_inverse', 'critical_instructions', 'warning_instructions', 'unknown_instructions', 'policy_linked', - 'id_category'); + 'id_category', 'disabled_types_event'); $values = array (); // Specific snmp reused fields @@ -809,11 +831,25 @@ function process_manage_edit ($module_name, $agents_select = null) { foreach ($fields as $field) { $value = get_parameter ($field, ''); - if ($value != '') { - $values[$field] = $value; + + switch ($field) { + default: + if ($value != '') { + $values[$field] = $value; + } + break; } } + $throw_unknown_events = get_parameter('throw_unknown_events', ''); + if ($throw_unknown_events !== '') { + //Set the event type that can show. + $disabled_types_event = array( + EVENTS_GOING_UNKNOWN => (int)!$throw_unknown_events); + $values['disabled_types_event'] = json_encode($disabled_types_event); + } + + if (strlen(get_parameter('history_data')) > 0) { $values['history_data'] = get_parameter('history_data'); } diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index 2c21494eae..1dec7876fe 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -113,6 +113,12 @@ $snmp3_privacy_method = (string) get_parameter('snmp3_privacy_method'); $snmp3_privacy_pass = (string) get_parameter('snmp3_privacy_pass'); $snmp3_security_level = (string) get_parameter('snmp3_security_level'); + +$throw_unknown_events = get_parameter('throw_unknown_events', false); +//Set the event type that can show. +$disabled_types_event = array(EVENTS_GOING_UNKNOWN => (int)!$throw_unknown_events); +$disabled_types_event = json_encode($disabled_types_event); + $create_component = (bool) get_parameter ('create_component'); $update_component = (bool) get_parameter ('update_component'); $delete_component = (bool) get_parameter ('delete_component'); @@ -160,7 +166,6 @@ if ($create_component) { 'name', $name); } - if ($name && !$name_check) { $id = network_components_create_network_component ($name, $type, $id_group, @@ -203,7 +208,8 @@ if ($create_component) { 'critical_inverse' => $critical_inverse, 'warning_inverse' => $warning_inverse, 'id_category' => $id_category, - 'tags' => $tags)); + 'tags' => $tags, + 'disabled_types_event' => $disabled_types_event)); } else { $id = ''; @@ -239,6 +245,7 @@ if ($update_component) { $custom_string_3 = $snmp3_security_level; //$name_check = db_get_value ('name', 'tnetwork_component', 'name', $name); } + if (!empty($name)) { $result = network_components_update_network_component ($id, array ('type' => $type, @@ -283,7 +290,8 @@ if ($update_component) { 'critical_inverse' => $critical_inverse, 'warning_inverse' => $warning_inverse, 'id_category' => $id_category, - 'tags' => $tags)); + 'tags' => $tags, + 'disabled_types_event' => $disabled_types_event)); } else { $result = ''; diff --git a/pandora_console/godmode/modules/manage_network_components_form_common.php b/pandora_console/godmode/modules/manage_network_components_form_common.php index 8b9b234ad8..cd781784f0 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_common.php +++ b/pandora_console/godmode/modules/manage_network_components_form_common.php @@ -141,7 +141,10 @@ $table->data[5][2] = __('Max. Value'); $table->data[5][3] = html_print_input_text ('max', $max, '', 5, 15, true) . ' ' . ui_print_help_tip (__('Any value over this number is discarted'), true); $table->data[6][0] = __('Unit'); $table->data[6][1] = html_print_input_text ('unit', $unit, '', 12, 25, true); -$table->data[6][2] = $table->data[6][3] = ''; + +$table->data[6][2] = __('Throw unknown events'); +$table->data[6][3] = html_print_checkbox('throw_unknown_events', 1, + !network_components_is_disable_type_event($id, EVENTS_GOING_UNKNOWN), true); $table->data[7][0] = __('Critical instructions'). ui_print_help_tip(__("Instructions when the status is critical"), true); $table->data[7][1] = html_print_textarea ('critical_instructions', 2, 65, $critical_instructions, '', true); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index d0d3010bc5..711ec3b306 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -324,4 +324,22 @@ define("MODULE_LINKED", 1); define("MODULE_PENDING_UNLINK", 10); define("MODULE_PENDING_LINK", 11); -?> +/* EVENTS */ +define("EVENTS_GOING_UNKNOWN" , 'going_unknown'); +define("EVENTS_UNKNOWN", 'unknown'); +define("EVENTS_ALERT_FIRED", 'alert_fired'); +define("EVENTS_ALERT_RECOVERED", 'alert_recovered'); +define("EVENTS_ALERT_CEASED", 'alert_ceased'); +define("EVENTS_ALERT_MANUAL_VALIDATION", 'alert_manual_validation'); +define("EVENTS_RECON_HOST_DETECTED", 'recon_host_detected'); +define("EVENTS_SYSTEM", 'system'); +define("EVENTS_ERROR", 'error'); +define("EVENTS_NEW_AGENT", 'new_agent'); +define("EVENTS_GOING_UP_WARNING", 'going_up_warning'); +define("EVENTS_GOING_UP_CRITICAL", 'going_up_critical'); +define("EVENTS_GOING_DOWN_WARNING", 'going_down_warning'); +define("EVENTS_GOING_DOWN_NORMAL", 'going_down_normal'); +define("EVENTS_GOING_DOWN_CRITICAL", 'going_down_critical'); +define("EVENTS_GOING_UP_NORMAL", 'going_up_normal'); +define("EVENTS_CONFIGURATION_CHANGE", 'configuration_change'); +?> \ No newline at end of file diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 44c558a218..8ad3d6da2a 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -659,8 +659,9 @@ function get_parameter_get ($name, $default = "") { * @return mixed Whatever was in that parameter, cleaned however */ function get_parameter_post ($name, $default = "") { - if ((isset ($_POST[$name])) && ($_POST[$name] != "")) + if ((isset ($_POST[$name])) && ($_POST[$name] != "")) { return io_safe_input ($_POST[$name]); + } return $default; } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 742f4044a1..9df17f4e21 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -21,7 +21,6 @@ enterprise_include_once ('meta/include/functions_agents_meta.php'); enterprise_include_once ('meta/include/functions_modules_meta.php'); - /** * @package Include * @subpackage Events diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 551d0148c3..4c05703943 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -23,6 +23,77 @@ include_once($config['homedir'] . "/include/functions_agents.php"); include_once($config['homedir'] . '/include/functions_users.php'); include_once($config['homedir'] . '/include/functions_tags.php'); +function modules_is_disable_type_event($id_agent_module = false, $type_event = false) { + if ($id_agent_module === false) { + switch ($type_event) { + case EVENTS_GOING_UNKNOWN: + return false; + break; + case EVENTS_UNKNOWN: + return false; + break; + case EVENTS_ALERT_FIRED: + return false; + break; + case EVENTS_ALERT_RECOVERED: + return false; + break; + case EVENTS_ALERT_CEASED: + return false; + break; + case EVENTS_ALERT_MANUAL_VALIDATION: + return false; + break; + case EVENTS_RECON_HOST_DETECTED: + return false; + break; + case EVENTS_SYSTEM: + return false; + break; + case EVENTS_ERROR: + return false; + break; + case EVENTS_NEW_AGENT: + return false; + break; + case EVENTS_GOING_UP_WARNING: + return false; + break; + case EVENTS_GOING_UP_CRITICAL: + return false; + break; + case EVENTS_GOING_DOWN_WARNING: + return false; + break; + case EVENTS_GOING_DOWN_NORMAL: + return false; + break; + case EVENTS_GOING_DOWN_CRITICAL: + return false; + break; + case EVENTS_GOING_UP_NORMAL: + return false; + break; + case EVENTS_CONFIGURATION_CHANGE: + return false; + break; + } + } + + $disabled_types_event = json_decode( + db_get_value('disabled_types_event', 'tagente_modulo', 'id_agente_modulo', $id_agent_module), true); + + if (isset($disabled_types_event[$type_event])) { + if ($disabled_types_event[$type_event]) { + return true; + } + else { + return false; + } + } + return false; +} + /** * Copy a module defined in an agent to other agent. * @@ -265,7 +336,8 @@ function modules_update_agent_module ($id, $values, $onlyNoDeletePending = false $id_agent = modules_get_agentmodule_agent($id); - $exists = (bool)db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('nombre' => $values['nombre'], 'id_agente' => $id_agent, 'id_agente_modulo' => "<>$id")); + $exists = (bool)db_get_value_filter('id_agente_modulo', + 'tagente_modulo', array('nombre' => $values['nombre'], 'id_agente' => $id_agent, 'id_agente_modulo' => "<>$id")); if ($exists) { return ERR_EXIST; @@ -351,14 +423,15 @@ function modules_create_agent_module ($id_agent, $name, $values = false, $disabl if (($tags !== false) || (empty($tags))) $return_tag = tags_insert_module_tag ($id_agent_module, $tags); - if ($return_tag === false){ + if ($return_tag === false) { db_process_sql_delete ('tagente_modulo', array ('id_agente_modulo' => $id_agent_module)); return ERR_DB; } - if (isset ($values['id_tipo_modulo']) && ($values['id_tipo_modulo'] == 21 || $values['id_tipo_modulo'] == 22 || $values['id_tipo_modulo'] == 23)) { + if (isset ($values['id_tipo_modulo']) + && ($values['id_tipo_modulo'] == 21 || $values['id_tipo_modulo'] == 22 || $values['id_tipo_modulo'] == 23)) { // Async modules start in normal status $status = AGENT_MODULE_STATUS_NORMAL; } diff --git a/pandora_console/include/functions_network_components.php b/pandora_console/include/functions_network_components.php index 13c8060455..bd6d7f0e1f 100644 --- a/pandora_console/include/functions_network_components.php +++ b/pandora_console/include/functions_network_components.php @@ -27,6 +27,79 @@ include_once ($config['homedir'] . '/include/functions_modules.php'); include_once ($config['homedir'] . '/include/functions_agents.php'); include_once ($config['homedir'] . '/include/functions_users.php'); +function network_components_is_disable_type_event($id = false, $type_event = false) { + if ($id === false) { + switch ($type_event) { + case EVENTS_GOING_UNKNOWN: + return false; + break; + case EVENTS_UNKNOWN: + return false; + break; + case EVENTS_ALERT_FIRED: + return false; + break; + case EVENTS_ALERT_RECOVERED: + return false; + break; + case EVENTS_ALERT_CEASED: + return false; + break; + case EVENTS_ALERT_MANUAL_VALIDATION: + return false; + break; + case EVENTS_RECON_HOST_DETECTED: + return false; + break; + case EVENTS_SYSTEM: + return false; + break; + case EVENTS_ERROR: + return false; + break; + case EVENTS_NEW_AGENT: + return false; + break; + case EVENTS_GOING_UP_WARNING: + return false; + break; + case EVENTS_GOING_UP_CRITICAL: + return false; + break; + case EVENTS_GOING_DOWN_WARNING: + return false; + break; + case EVENTS_GOING_DOWN_NORMAL: + return false; + break; + case EVENTS_GOING_DOWN_CRITICAL: + return false; + break; + case EVENTS_GOING_UP_NORMAL: + return false; + break; + case EVENTS_CONFIGURATION_CHANGE: + return false; + break; + } + } + + $disabled_types_event = json_decode( + db_get_value('disabled_types_event', 'tnetwork_component', + 'id_nc', $id), + true); + + if (isset($disabled_types_event[$type_event])) { + if ($disabled_types_event[$type_event]) { + return true; + } + else { + return false; + } + } + return false; +} + /** * Get a list of network components. * diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index 3f7af0fecf..6ad8b3cd0e 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -286,7 +286,7 @@ function configure_modules_form () { var tags = data["tags"]; // Reset the selection of tags (put all of them into available box) - $("#id_tag_selected option").each(function(){ + $("#id_tag_selected option").each(function() { if ($(this).attr('value') != '') { $("#id_tag_selected").find("option[value='" + $(this).attr('value') + "']").remove(); $("select[name='id_tag_available[]']").append($("").val($(this).attr('value')).html($(this).text())); @@ -349,6 +349,11 @@ function configure_modules_form () { $("input[name=active_snmp_v3]").val(1); } } + + if (data["throw_unknown_events"]) + $("input[name='throw_unknown_events']").check (); + else + $("input[name='throw_unknown_events']").uncheck (); }, "json" ); diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index ff496f7557..9bf651763c 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -247,6 +247,8 @@ CREATE TABLE tagente_modulo ( critical_inverse NUMBER(1, 0) default 0 NOT NULL, warning_inverse NUMBER(1, 0) default 0 NOT NULL, id_category NUMBER(10, 0) default 0 NOT NULL, + disabled_types_event CLOB default '', + CONSTRAINT t_agente_modulo_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','nowizard')) ); CREATE INDEX tagente_modulo_id_agente_idx ON tagente_modulo(id_agente); @@ -699,6 +701,8 @@ CREATE TABLE tnetwork_component ( warning_inverse NUMBER(1, 0) default 0 NOT NULL, id_category NUMBER(10, 0) default 0 NOT NULL, tags CLOB, + disabled_types_event CLOB default '', + CONSTRAINT t_network_component_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','nowizard')) ); diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index 87a91d6e5c..92a928709d 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -235,7 +235,8 @@ CREATE TABLE "tagente_modulo" ( "quiet" SMALLINT NOT NULL default 0, "critical_inverse" SMALLINT NOT NULL default 0, "warning_inverse" SMALLINT NOT NULL default 0, - "id_category" INTEGER NOT NULL default 0 + "id_category" INTEGER NOT NULL default 0, + "disabled_types_event" TEXT default '' ); CREATE INDEX "tagente_modulo_id_agente_idx" ON "tagente_modulo"("id_agente"); CREATE INDEX "tagente_modulo_id_tipo_modulo_idx" ON "tagente_modulo"("id_tipo_modulo"); @@ -597,7 +598,8 @@ CREATE TABLE "tnetwork_component" ( "critical_inverse" SMALLINT NOT NULL default 0, "warning_inverse" SMALLINT NOT NULL default 0, "id_category" INTEGER NOT NULL default 0, - "tags" text NOT NULL + "tags" text NOT NULL, + "disabled_types_event" TEXT default '' ); -- --------------------------------------------------------------------- diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index a90314880f..7a0e9d0a83 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -232,6 +232,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` ( `critical_inverse` tinyint(1) unsigned default '0', `warning_inverse` tinyint(1) unsigned default '0', `id_category` int(10) default 0, + `disabled_types_event` TEXT NOT NULL default '', PRIMARY KEY (`id_agente_modulo`), KEY `main_idx` (`id_agente_modulo`,`id_agente`), KEY `tam_agente` (`id_agente`), @@ -651,6 +652,7 @@ CREATE TABLE IF NOT EXISTS `tnetwork_component` ( `warning_inverse` tinyint(1) unsigned default '0', `id_category` int(10) default 0, `tags` text NOT NULL, + `disabled_types_event` TEXT NOT NULL default '', PRIMARY KEY (`id_nc`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;