From 19fea4a864618391925a2b21d5d24279422910b9 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Fri, 10 Jun 2011 12:38:59 +0000 Subject: [PATCH] 2011-06-10 Ramon Novoa * include/functions_api.php, pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql, extras/pandoradb_migrate_v3.2_to_v4.0.sql: Added support for configuration change events (enterprise). * operation/events/events_list.php: Improved event grouping. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4430 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 +++++++++ .../extras/pandoradb_migrate_v3.2_to_v4.0.sql | 6 ++++++ pandora_console/include/functions_api.php | 2 +- pandora_console/operation/events/events_list.php | 9 ++++++--- pandora_console/pandoradb.oracle.sql | 3 ++- pandora_console/pandoradb.postgreSQL.sql | 2 +- pandora_console/pandoradb.sql | 2 +- 7 files changed, 26 insertions(+), 7 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 34ac60c94a..045d195599 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2011-06-10 Ramon Novoa + + * include/functions_api.php, pandoradb.sql, + pandoradb.postgreSQL.sql, pandoradb.oracle.sql, + extras/pandoradb_migrate_v3.2_to_v4.0.sql: Added support for + configuration change events (enterprise). + + * operation/events/events_list.php: Improved event grouping. + 2011-06-10 Javier Lanz * include/graphs/functions_fsgraph.php: Updated a deprecated function diff --git a/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql b/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql index 05183b3906..71f09949c6 100644 --- a/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql +++ b/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql @@ -107,6 +107,12 @@ ALTER TABLE ttrap ADD `severity` tinyint(4) unsigned NOT NULL default '2'; ALTER TABLE tusuario_perfil ADD `id_policy` int(10) unsigned NOT NULL default 0; +-- ----------------------------------------------------- +-- Table `tevento` +-- ----------------------------------------------------- + +ALTER TABLE `tevento` MODIFY `event_type` enum('unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change') default 'unknown'; + -- ----------------------------------------------------- -- Change the value "0000-00-00 00:00:00" that Pandora use as zero or null date value -- for the value "01-01-1970 00:00:00". diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 7dfee139e4..623e719d9a 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1195,7 +1195,7 @@ function set_new_event($trash1, $trash2, $other, $trash3) { 'alert_ceased', 'alert_manual_validation', 'recon_host_detected', 'system','error', 'new_agent', 'going_up_warning', 'going_up_critical', 'going_down_warning', - 'going_down_normal', 'going_down_critical', 'going_up_normal'); + 'going_down_normal', 'going_down_critical', 'going_up_normal','configuration_change'); if (in_array($other['data'][1], $valuesAvaliable)) { $values['event_type'] = $other['data'][1]; diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 3cc68e795b..1c17d125af 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -270,14 +270,16 @@ if ($group_rep == 0) { else { switch ($config["dbtype"]) { case "mysql": - $sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep + $sql = "SELECT *, GROUP_CONCAT(user_comment SEPARATOR '') AS user_comment, + MAX(estado) AS estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep FROM tevento WHERE 1=1 ".$sql_post." GROUP BY evento, id_agentmodule ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination; break; case "postgresql": - $sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep + $sql = "SELECT *, array_to_string(array_agg(user_comment), '') AS user_comment, + MAX(estado) AS estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep FROM tevento WHERE 1=1 ".$sql_post." GROUP BY evento, id_agentmodule @@ -290,7 +292,8 @@ else { $sql = "SELECT a.*, b.event_rep, b.timestamp_rep FROM (select * from tevento WHERE 1=1 ".$sql_post.") a, (select min(id_evento) as id_evento, to_char(evento) as evento, - id_agentmodule, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep + id_agentmodule, COUNT(*) AS event_rep, MAX(estado) AS estado, + LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep from tevento WHERE 1=1 ".$sql_post." GROUP BY to_char(evento), id_agentmodule) b diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index dbbe3b9235..f226158059 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -26,6 +26,7 @@ CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP (oracletime IN DATE DEFAULT SYSDATE) RETURN INTEGER AS unixtime INTEGER; BEGIN unixtime := (oracletime - to_date('19700101','YYYYMMDD')) * 86400; RETURN unixtime; END;; CREATE OR REPLACE FUNCTION NOW RETURN TIMESTAMP AS t_now TIMESTAMP; BEGIN SELECT LOCALTIMESTAMP INTO t_now FROM dual; RETURN t_now; END;; +CREATE AGGREGATE array_agg (anyelement) (sfunc = array_append, stype = anyarray, initcond = '{}');; CREATE TABLE taddress ( id_a NUMBER(10, 0) NOT NULL PRIMARY KEY, @@ -484,7 +485,7 @@ CREATE TABLE tevento ( criticity NUMBER(10, 0) default 0 NOT NULL, user_comment CLOB, tags CLOB NOT NULL, - CONSTRAINT tevento_event_type_cons CHECK (event_type IN ('unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal')) + CONSTRAINT tevento_event_type_cons CHECK (event_type IN ('unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change')) ); CREATE INDEX tevento_id_1_idx ON tevento(id_agente, id_evento); CREATE INDEX tevento_id_2_idx ON tevento(utimestamp, id_evento); diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index bc5f08a88d..07f7e42614 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -373,7 +373,7 @@ CREATE TABLE "tconfig_os" ( "icon_name" varchar(100) default '' ); -CREATE TYPE type_tevento_event AS ENUM ('unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal'); +CREATE TYPE type_tevento_event AS ENUM ('unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change'); CREATE TABLE "tevento" ( "id_evento" BIGSERIAL NOT NULL PRIMARY KEY, "id_agente" INTEGER NOT NULL default 0, diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f358066ec6..91e47143df 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -416,7 +416,7 @@ CREATE TABLE IF NOT EXISTS `tevento` ( `timestamp` datetime NOT NULL default '1970-01-01 00:00:00', `evento` text NOT NULL default '', `utimestamp` bigint(20) NOT NULL default '0', - `event_type` enum('unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal') default 'unknown', + `event_type` enum('unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change') default 'unknown', `id_agentmodule` int(10) NOT NULL default '0', `id_alert_am` int(10) NOT NULL default '0', `criticity` int(4) unsigned NOT NULL default '0',