[icinga-users] IDOMOD Suggestion - Workaround

Marko Vainiokangas marko.vainiokangas at atea.se
Fri Mar 8 18:58:06 CET 2013


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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.icinga.org/pipermail/icinga-users/attachments/20130308/0baf5cf1/attachment.html>


More information about the icinga-users mailing list