[PATCH] NODutils: Duplicate lines in servicechecks table for each service check

Michael Friedrich michael.friedrich at univie.ac.at
Tue Nov 3 13:18:53 CET 2009


As remarked in the other thread, the unique constraints for the table 
nagios_servicechecks is missing causing duplicate rows. This patch 
removes the KEY defines and adds an unique key just like 
nagios_hostchecks has defined too.

As I am not sure in which file you will put the ALTER statements since 
1.4b9 is out already, I'll attach those statements as is.

--------------------------

diff --git a/db/mysql.sql b/db/mysql.sql
index 3036f46..386a460 100644
--- a/db/mysql.sql
+++ b/db/mysql.sql
@@ -1004,9 +1004,7 @@ CREATE TABLE IF NOT EXISTS `nagios_servicechecks` (
   `long_output` TEXT NOT NULL default '',
   `perfdata` TEXT character set latin1 NOT NULL default '',
   PRIMARY KEY  (`servicecheck_id`),
-  KEY `instance_id` (`instance_id`),
-  KEY `service_object_id` (`service_object_id`),
-  KEY `start_time` (`start_time`)
+  UNIQUE KEY `instance_id` 
(`instance_id`,`service_object_id`,`start_time`,`start_time_usec`)
 ) ENGINE=MyISAM  COMMENT='Historical service checks';

--------------------------

ALTER table nagios_servicechecks DROP KEY instance_id;
ALTER table nagios_servicechecks DROP KEY service_object_id;
ALTER table nagios_servicechecks DROP KEY start_time;

ALTER table nagios_servicechecks ADD UNIQUE KEY `instance_id` 
(`instance_id`,`service_object_id`,`start_time`,`start_time_usec`);

--------------------------

I've tested the patch and everything works fine now - no more duplicate 
rows.

Kind regards,
Michael

-- 
DI (FH) Michael Friedrich
michael.friedrich at univie.ac.at
Tel: +43 1 4277 14359

Vienna University Computer Center
Universitaetsstrasse 7 
A-1010 Vienna, Austria  


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference




More information about the Developers mailing list