Add items to the view events

This commit is contained in:
manuel.montes 2018-07-19 18:04:50 +02:00
parent 0873d7dd1d
commit b922066a72
6 changed files with 103 additions and 0 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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;
}

View File

@ -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;
}
?>

View File

@ -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

View File

@ -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`),