From b922066a72f39837034ccd32a5b8c7c74cb3c6e0 Mon Sep 17 00:00:00 2001 From: "manuel.montes" Date: Thu, 19 Jul 2018 18:04:50 +0200 Subject: [PATCH] Add items to the view events --- pandora_console/extras/mr/18.sql | 12 +++++ .../godmode/events/custom_events.php | 8 +++ pandora_console/include/functions_events.php | 2 + pandora_console/include/functions_modules.php | 53 +++++++++++++++++++ .../operation/events/events.build_table.php | 22 ++++++++ pandora_console/pandoradb.sql | 6 +++ 6 files changed, 103 insertions(+) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index 66963763d1..fcabc7de76 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -18,4 +18,16 @@ DROP INDEX id_policy ON `tpolicy_agents`; ALTER TABLE `tpolicy_agents` ADD COLUMN `id_node` int(10) NOT NULL DEFAULT '0'; ALTER TABLE `tpolicy_agents` ADD UNIQUE(`id_policy`, `id_agent`, `id_node`); +ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL; + +ALTER TABLE `tmetaconsole_event` ADD COLUMN `data` double(22,5) default NULL; + +ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `data` double(22,5) default NULL; + +ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0'; + +ALTER TABLE `tmetaconsole_event` ADD COLUMN `module_status` int(4) NOT NULL default '0'; + +ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `module_status` int(4) NOT NULL default '0'; + COMMIT; \ No newline at end of file diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index a356b7bc47..134cb76a72 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -121,6 +121,12 @@ if ($fields_selected[0]!='') { case 'server_name': $result = __('Server name'); break; + case 'data': + $result = __('Data'); + case 'module_status': + $result = __('Module status'); + break; + break; } $result_selected[$field_selected] = $result; } @@ -168,6 +174,8 @@ $fields_available['owner_user'] = __('Owner'); $fields_available['ack_utimestamp'] = __('ACK Timestamp'); $fields_available['instructions'] = __('Instructions'); $fields_available['server_name'] = __('Server name'); +$fields_available['data'] = __('Data'); +$fields_available['module_status'] = __('Module status'); //remove fields already selected foreach ($fields_available as $key=>$available) { diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 1348afc96b..073dd62443 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -50,6 +50,8 @@ function events_get_all_fields() { $columns['ack_utimestamp'] = __('ACK Timestamp'); $columns['instructions'] = __('Instructions'); $columns['server_name'] = __('Server name'); + $columns['data'] = __('Data'); + $columns['module_status'] = __('Module status'); return $columns; } diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 59e88d9cdf..71d98a8d2e 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -2764,4 +2764,57 @@ function force_set_module_status ($status, $id_agent_module) { array('id_agente_modulo' => $id_agent_module) ); } +function modules_get_modules_status ($mod_status_id) { + + $diferent_types = get_priorities (); + + $mod_status_desc = ''; + switch ($mod_status_id) { + case AGENT_MODULE_STATUS_NORMAL: + $mod_status_desc = __('NORMAL'); + break; + case AGENT_MODULE_STATUS_CRITICAL_BAD: + $mod_status_desc = __('CRITICAL'); + break; + case AGENT_MODULE_STATUS_WARNING: + $mod_status_desc = __('WARNING'); + break; + case AGENT_MODULE_STATUS_UNKNOWN: + $mod_status_desc = __('UNKNOWN'); + break; + case AGENT_MODULE_STATUS_NOT_INIT: + $mod_status_desc = __('NOT INIT'); + break; + case AGENT_MODULE_STATUS_ALL: + $mod_status_desc = __('ALL'); + break; + case AGENT_MODULE_STATUS_CRITICAL_ALERT: + $mod_status_desc = __('CRITICAL'); + break; + case AGENT_MODULE_STATUS_NO_DATA: + $mod_status_desc = __('NO DATA'); + break; + case AGENT_MODULE_STATUS_NORMAL_ALERT: + $mod_status_desc = __('NORMAL'); + break; + case AGENT_MODULE_STATUS_NOT_NORMAL: + $mod_status_desc = __('NOT NORMAL'); + break; + case AGENT_MODULE_STATUS_WARNING_ALERT: + $mod_status_desc = __('WARNING'); + break; + default: + if (isset($config['text_char_long'])) { + foreach ($diferent_types as $key => $type) { + if ($key == $mod_status_id) { + $mod_status_desc = ui_print_truncate_text($type, + $config['text_char_long'], false, true, false); + } + } + } + break; + } + + return $mod_status_desc; +} ?> diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index d00dbd522a..c92f0dc795 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -249,6 +249,18 @@ else { $i++; } + if (in_array('data', $show_fields)) { + $table->head[$i] = __('Data'); + $table->align[$i] = 'left'; + + $i++; + } + if (in_array('module_status', $show_fields)) { + $table->head[$i] = __('Module status'); + $table->align[$i] = 'left'; + + $i++; + } if ($i != 0 && $allow_action) { $table->head[$i] = __('Action'); $table->align[$i] = 'left'; @@ -663,6 +675,16 @@ else { $table->cellclass[count($table->data)][$i] = $myclass; $i++; } + if (in_array('data',$show_fields)) { + $data[$i] = $event["data"]; + $table->cellclass[count($table->data)][$i] = $myclass; + $i++; + } + if (in_array('module_status',$show_fields)) { + $data[$i] = modules_get_modules_status ($event["module_status"]); + $table->cellclass[count($table->data)][$i] = $myclass; + $i++; + } if ($i != 0 && $allow_action) { //Actions diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index e57502ade8..a72c2051f0 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -641,6 +641,8 @@ CREATE TABLE IF NOT EXISTS `tevento` ( `owner_user` VARCHAR(100) NOT NULL DEFAULT '', `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `custom_data` TEXT NOT NULL, + `data` double(22,5) default NULL, + `module_status` int(4) NOT NULL default '0', PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), KEY `idx_agentmodule` (`id_agentmodule`), @@ -2878,6 +2880,8 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event` ( `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `server_id` int(10) NOT NULL, `custom_data` TEXT NOT NULL DEFAULT '', + `data` double(22,5) default NULL, + `module_status` int(4) NOT NULL default '0', PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), KEY `idx_agentmodule` (`id_agentmodule`), @@ -2923,6 +2927,8 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event_history` ( `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `server_id` int(10) NOT NULL, `custom_data` TEXT NOT NULL DEFAULT '', + `data` double(22,5) default NULL, + `module_status` int(4) NOT NULL default '0', PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), KEY `idx_agentmodule` (`id_agentmodule`),