Earlier I suggested that idomod could be enabled to add Changes to a different 
table regardless if it’s a statechange.. well I couldn’t just sit around and do 
nothing so I started contemplating different ways of doing this myself. From a 
perl-script that would capture plugin outputs, Reading retention.dat, a mysql 
event and since I was already fiddling in mysql, why not a trigger?

So here’s what I have done;

use icinga;

CREATE TABLE `icinga_retention` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `service_object_id` int(11) DEFAULT NULL,
  `read_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE 
CURRENT_TIM                                                                     
                                                                       ESTAMP,
  `host_name` varchar(64) DEFAULT NULL,
  `service_description` varchar(128) DEFAULT NULL,
  `long_output` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB


DELIMITER ///
CREATE TRIGGER icinga_retention_data
  BEFORE UPDATE ON icinga_servicestatus
  FOR EACH ROW
  BEGIN
    IF NEW.output <> OLD.output THEN
      INSERT INTO icinga_retention (service_object_id, host_name, 
service_description,long_output)
        select NEW.service_object_id, obj.name1, obj.name2, NEW.output
        from icinga_servicestatus status
        inner join icinga_objects obj on obj.object_id = 
status.service_object_id
        where service_object_id=NEW.service_object_id;
    END IF;
  END;
///

DELIMITER ;


Basically this will do what I want it to do so I can plot statistics with a 
reliable source. As soon as the output of the icinga_servicestatus is changed, 
an entry is created in icinga_retention with bare essentials to conserve DB 
space.

I’m no wizard with regex and stored procedures to fully automate it in mysql to 
get the proper datapoints directly into the table...so... This will do for now 😊

THought I’d share!
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
icinga-users mailing list
icinga-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/icinga-users

Reply via email to