diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9f2952fea5..b462243586 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2013-03-19 Ramon Novoa + + * 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: Updated and fixed + some column types. + + * include/functions_alerts.php, + pandoradb.sql, + pandoradb.postgreSQL.sql, + pandoradb.oracle.sql: Added support for on-demand module status + calculations. + 2013-03-18 Junichi Satoh * include/help/ja/help_performance.php, 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 d202f3e161..9d022ac8c3 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 @@ -65,6 +65,8 @@ ALTER TABLE `tagente` ADD COLUMN `unknown_count` bigint(20) NOT NULL default '0' ALTER TABLE `tagente` ADD COLUMN `notinit_count` bigint(20) NOT NULL default '0'; ALTER TABLE `tagente` ADD COLUMN `total_count` bigint(20) NOT NULL default '0'; ALTER TABLE `tagente` ADD COLUMN `fired_count` bigint(20) NOT NULL default '0'; +ALTER TABLE `tagente` ADD COLUMN `update_module_count` tinyint(1) NOT NULL DEFAULT '0'; +ALTER TABLE `tagente` ADD COLUMN `update_alert_count` tinyint(1) NOT NULL DEFAULT '0'; -- --------------------------------------------------------------------- -- Table `talert_special_days` @@ -372,31 +374,31 @@ CREATE TABLE IF NOT EXISTS `tevent_response` ( -- ---------------------------------------------------------------------- -- Table `talert_actions` -- ---------------------------------------------------------------------- -ALTER TABLE `talert_actions` ADD COLUMN `field4` TEXT NOT NULL; -ALTER TABLE `talert_actions` ADD COLUMN `field5` TEXT NOT NULL; -ALTER TABLE `talert_actions` ADD COLUMN `field6` TEXT NOT NULL; -ALTER TABLE `talert_actions` ADD COLUMN `field7` TEXT NOT NULL; -ALTER TABLE `talert_actions` ADD COLUMN `field8` TEXT NOT NULL; -ALTER TABLE `talert_actions` ADD COLUMN `field9` TEXT NOT NULL; -ALTER TABLE `talert_actions` ADD COLUMN `field10` TEXT NOT NULL; +ALTER TABLE `talert_actions` ADD COLUMN `field4` TEXT; +ALTER TABLE `talert_actions` ADD COLUMN `field5` TEXT; +ALTER TABLE `talert_actions` ADD COLUMN `field6` TEXT; +ALTER TABLE `talert_actions` ADD COLUMN `field7` TEXT; +ALTER TABLE `talert_actions` ADD COLUMN `field8` TEXT; +ALTER TABLE `talert_actions` ADD COLUMN `field9` TEXT; +ALTER TABLE `talert_actions` ADD COLUMN `field10` TEXT; -- ---------------------------------------------------------------------- -- Table `talert_templates` -- ---------------------------------------------------------------------- -ALTER TABLE `talert_templates` ADD COLUMN `field4` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field5` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field6` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field7` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field8` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field9` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field10` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field4_recovery` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field5_recovery` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field6_recovery` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field7_recovery` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field8_recovery` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field9_recovery` TEXT NOT NULL; -ALTER TABLE `talert_templates` ADD COLUMN `field10_recovery` TEXT NOT NULL; +ALTER TABLE `talert_templates` ADD COLUMN `field4` TEXT; +ALTER TABLE `talert_templates` ADD COLUMN `field5` TEXT; +ALTER TABLE `talert_templates` ADD COLUMN `field6` TEXT; +ALTER TABLE `talert_templates` ADD COLUMN `field7` TEXT; +ALTER TABLE `talert_templates` ADD COLUMN `field8` TEXT; +ALTER TABLE `talert_templates` ADD COLUMN `field9` TEXT; +ALTER TABLE `talert_templates` ADD COLUMN `field10` TEXT; +ALTER TABLE `talert_templates` ADD COLUMN `field4_recovery`; +ALTER TABLE `talert_templates` ADD COLUMN `field5_recovery`; +ALTER TABLE `talert_templates` ADD COLUMN `field6_recovery`; +ALTER TABLE `talert_templates` ADD COLUMN `field7_recovery`; +ALTER TABLE `talert_templates` ADD COLUMN `field8_recovery`; +ALTER TABLE `talert_templates` ADD COLUMN `field9_recovery`; +ALTER TABLE `talert_templates` ADD COLUMN `field10_recovery`; -- ---------------------------------------------------------------------- -- Table `talert_commands` @@ -443,13 +445,13 @@ ALTER TABLE `ttag` ADD COLUMN `email` text NULL; -- --------------------------------------------------------------------- -- Add more fields in snmp alerts (05/03/13) -- --------------------------------------------------------------------- -ALTER TABLE `talert_snmp` ADD COLUMN `al_field4` text NOT NULL; -ALTER TABLE `talert_snmp` ADD COLUMN `al_field5` text NOT NULL; -ALTER TABLE `talert_snmp` ADD COLUMN `al_field6` text NOT NULL; -ALTER TABLE `talert_snmp` ADD COLUMN `al_field7` text NOT NULL; -ALTER TABLE `talert_snmp` ADD COLUMN `al_field8` text NOT NULL; -ALTER TABLE `talert_snmp` ADD COLUMN `al_field9` text NOT NULL; -ALTER TABLE `talert_snmp` ADD COLUMN `al_field10` text NOT NULL; +ALTER TABLE `talert_snmp` ADD COLUMN `al_field4` text; +ALTER TABLE `talert_snmp` ADD COLUMN `al_field5` text; +ALTER TABLE `talert_snmp` ADD COLUMN `al_field6` text; +ALTER TABLE `talert_snmp` ADD COLUMN `al_field7` text; +ALTER TABLE `talert_snmp` ADD COLUMN `al_field8` text; +ALTER TABLE `talert_snmp` ADD COLUMN `al_field9` text; +ALTER TABLE `talert_snmp` ADD COLUMN `al_field10` text; -- --------------------------------------------------------------------- -- --------------------------------------------------------------------- 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 a66f845289..5b3a09c7ab 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 @@ -86,6 +86,8 @@ ALTER TABLE tagente ADD (unknown_count NUMBER(20, 0) default 0 NOT NULL); ALTER TABLE tagente ADD (notinit_count NUMBER(20, 0) default 0 NOT NULL); ALTER TABLE tagente ADD (total_count NUMBER(20, 0) default 0 NOT NULL); ALTER TABLE tagente ADD (fired_count NUMBER(20, 0) default 0 NOT NULL); +ALTER TABLE tagente ADD (update_module_count NUMBER(5, 0) default 0 NOT NULL); +ALTER TABLE tagente ADD (update_alert_count NUMBER(5, 0) default 0 NOT NULL); -- ----------------------------------------------------- -- Table talert_special_days @@ -403,13 +405,13 @@ CREATE SEQUENCE tevent_response_s INCREMENT BY 1 START WITH 1; -- ---------------------------------------------------------------------- -- Table talert_actions -- ---------------------------------------------------------------------- -ALTER TABLE talert_actions ADD (field4 CLOB NOT NULL; -ALTER TABLE talert_actions ADD (field5 CLOB NOT NULL; -ALTER TABLE talert_actions ADD (field6 CLOB NOT NULL; -ALTER TABLE talert_actions ADD (field7 CLOB NOT NULL; -ALTER TABLE talert_actions ADD (field8 CLOB NOT NULL; -ALTER TABLE talert_actions ADD (field9 CLOB NOT NULL; -ALTER TABLE talert_actions ADD (field10 CLOB NOT NULL; +ALTER TABLE talert_actions ADD (field4 CLOB default ''); +ALTER TABLE talert_actions ADD (field5 CLOB default ''); +ALTER TABLE talert_actions ADD (field6 CLOB default ''); +ALTER TABLE talert_actions ADD (field7 CLOB default ''); +ALTER TABLE talert_actions ADD (field8 CLOB default ''); +ALTER TABLE talert_actions ADD (field9 CLOB default ''); +ALTER TABLE talert_actions ADD (field10 CLOB default ''); -- ---------------------------------------------------------------------- -- Table talert_templates 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 99ea7536d7..c5b3ea2bf2 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 @@ -80,6 +80,8 @@ ALTER TABLE "tagente" ADD COLUMN "unknown_count" INTEGER NOT NULL default 0; ALTER TABLE "tagente" ADD COLUMN "notinit_count" INTEGER NOT NULL default 0; ALTER TABLE "tagente" ADD COLUMN "total_count" INTEGER NOT NULL default 0; ALTER TABLE "tagente" ADD COLUMN "fired_count" INTEGER NOT NULL default 0; +ALTER TABLE "tagente" ADD COLUMN "update_module_count" SMALLINT NOT NULL default 0; +ALTER TABLE "tagente" ADD COLUMN "update_alert_count" SMALLINT NOT NULL default 0; -- ----------------------------------------------------- -- Table "talert_special_days" @@ -394,31 +396,31 @@ CREATE TABLE IF NOT EXISTS "tevent_response" ( -- ---------------------------------------------------------------------- -- Table "talert_actions" -- ---------------------------------------------------------------------- -ALTER TABLE "talert_actions" ADD COLUMN "field4" TEXT NOT NULL; -ALTER TABLE "talert_actions" ADD COLUMN "field5" TEXT NOT NULL; -ALTER TABLE "talert_actions" ADD COLUMN "field6" TEXT NOT NULL; -ALTER TABLE "talert_actions" ADD COLUMN "field7" TEXT NOT NULL; -ALTER TABLE "talert_actions" ADD COLUMN "field8" TEXT NOT NULL; -ALTER TABLE "talert_actions" ADD COLUMN "field9" TEXT NOT NULL; -ALTER TABLE "talert_actions" ADD COLUMN "field10" TEXT NOT NULL; +ALTER TABLE "talert_actions" ADD COLUMN "field4" TEXT; +ALTER TABLE "talert_actions" ADD COLUMN "field5" TEXT; +ALTER TABLE "talert_actions" ADD COLUMN "field6" TEXT; +ALTER TABLE "talert_actions" ADD COLUMN "field7" TEXT; +ALTER TABLE "talert_actions" ADD COLUMN "field8" TEXT; +ALTER TABLE "talert_actions" ADD COLUMN "field9" TEXT; +ALTER TABLE "talert_actions" ADD COLUMN "field10" TEXT; -- ---------------------------------------------------------------------- -- Table "talert_templates" -- ---------------------------------------------------------------------- -ALTER TABLE "talert_templates" ADD COLUMN "field4" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field5" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field6" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field7" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field8" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field9" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field10" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field4_recovery" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field5_recovery" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field6_recovery" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field7_recovery" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field8_recovery" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field9_recovery" TEXT NOT NULL; -ALTER TABLE "talert_templates" ADD COLUMN "field10_recovery" TEXT NOT NULL; +ALTER TABLE "talert_templates" ADD COLUMN "field4" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field5" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field6" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field7" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field8" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field9" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field10" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field4_recovery" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field5_recovery" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field6_recovery" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field7_recovery" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field8_recovery" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field9_recovery" TEXT; +ALTER TABLE "talert_templates" ADD COLUMN "field10_recovery" TEXT; -- ---------------------------------------------------------------------- -- Table "talert_commands" @@ -464,13 +466,13 @@ ALTER TABLE "ttag" ADD COLUMN "email" TEXT NULL; -- --------------------------------------------------------------------- -- Add more fields in snmp alerts (05/03/13) -- --------------------------------------------------------------------- -ALTER TABLE "talert_snmp" ADD COLUMN "al_field4" TEXT NULL; -ALTER TABLE "talert_snmp" ADD COLUMN "al_field5" TEXT NULL; -ALTER TABLE "talert_snmp" ADD COLUMN "al_field6" TEXT NULL; -ALTER TABLE "talert_snmp" ADD COLUMN "al_field7" TEXT NULL; -ALTER TABLE "talert_snmp" ADD COLUMN "al_field8" TEXT NULL; -ALTER TABLE "talert_snmp" ADD COLUMN "al_field9" TEXT NULL; -ALTER TABLE "talert_snmp" ADD COLUMN "al_field10" TEXT NULL; +ALTER TABLE "talert_snmp" ADD COLUMN "al_field4" TEXT; +ALTER TABLE "talert_snmp" ADD COLUMN "al_field5" TEXT; +ALTER TABLE "talert_snmp" ADD COLUMN "al_field6" TEXT; +ALTER TABLE "talert_snmp" ADD COLUMN "al_field7" TEXT; +ALTER TABLE "talert_snmp" ADD COLUMN "al_field8" TEXT; +ALTER TABLE "talert_snmp" ADD COLUMN "al_field9" TEXT; +ALTER TABLE "talert_snmp" ADD COLUMN "al_field10" TEXT; -- --------------------------------------------------------------------- -- --------------------------------------------------------------------- diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index ad0534896c..e0e73dfdc2 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -886,16 +886,7 @@ function alerts_delete_alert_agent_module ($id_alert_agent_module, $filter = fal it is automatily because the data base this table have a foreing key and delete on cascade. */ - if (@db_process_sql_delete ('talert_template_modules', $filter) !== false) { - // If there are fired alert modules, update counts - if($fired_alert_modules !== false) { - foreach($fired_alert_modules as $fam) { - $agent_id = modules_get_agentmodule_agent($fam['id_agent_module']); - - db_process_sql(sprintf('UPDATE tagente SET fired_count=fired_count-%d WHERE id_agente = %d', $fam['alerts'], $agent_id)); - } - } - + if (@db_process_sql_delete ('talert_template_modules', $filter) !== false) { return true; } @@ -1180,7 +1171,7 @@ function alerts_validate_alert_agent_module ($id_alert_agent_module, $noACLs = f if ($result > 0) { // Update fired alert count on the agent - db_process_sql(sprintf('UPDATE tagente SET fired_count=fired_count-1 WHERE id_agente = %d', $agent_id)); + db_process_sql(sprintf('UPDATE tagente SET update_alert_count=1 WHERE id_agente = %d', $agent_id)); events_create_event ("Manual validation of alert for ". alerts_get_alert_template_description ($alert["id_alert_template"]), diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index d1ce9b3075..880f94557f 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -86,7 +86,9 @@ CREATE TABLE tagente ( unknown_count NUMBER(20, 0) default 0 NOT NULL, notinit_count NUMBER(20, 0) default 0 NOT NULL, total_count NUMBER(20, 0) default 0 NOT NULL, - fired_count NUMBER(20, 0) default 0 NOT NULL + fired_count NUMBER(20, 0) default 0 NOT NULL, + update_module_count NUMBER(5, 0) default 0 NOT NULL + update_alert_count NUMBER(5, 0) default 0 NOT NULL ); CREATE INDEX tagente_nombre_idx ON tagente(nombre); CREATE INDEX tagente_direccion_idx ON tagente(direccion); diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index d9725d7223..fc84667311 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -85,6 +85,8 @@ CREATE TABLE "tagente" ( "notinit_count" INTEGER NOT NULL default 0, "total_count" INTEGER NOT NULL default 0, "fired_count" INTEGER NOT NULL default 0 + "update_module_count" SMALLINT NOT NULL DEFAULT 1, + "update_alert_count" SMALLINT NOT NULL DEFAULT 1, ); CREATE INDEX "tagente_nombre_idx" ON "tagente"("nombre"); CREATE INDEX "tagente_direccion_idx" ON "tagente"("direccion"); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index beb9b869c3..f72f0cb6a2 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -78,6 +78,8 @@ CREATE TABLE IF NOT EXISTS `tagente` ( `notinit_count` bigint(20) NOT NULL default '0', `total_count` bigint(20) NOT NULL default '0', `fired_count` bigint(20) NOT NULL default '0', + `update_module_count` tinyint(1) NOT NULL default '0', + `update_alert_count` tinyint(1) NOT NULL default '0', PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`), KEY `direccion` (`direccion`),