Hello
Icinga2 has out of box script to integrate with ServiceNow event management. Not sure who wrote the script (ServiceNow or Icinga2 team) but it works OK.
What I found (may be wrong) would have been great if the custom data fields attached to a particular host / service is also sent along with the alert. The benefit of it would have been a great way to manage alert / ticket handling. Also the custom fields would have given a better way of doing event correlation.
Question : How do we expose the custom Data fields along with the alerts of a particular single service which has been updated with lets say field like “Application Name” and “Resolver Group”
Snippet Code which is pulling host and service alerts
try {
// On the initial itteration of the script(this mean when we don't have
// anything in 'last_event' parameter) we are collecting all the hosts which are in
// DOWN state and all the services which belongs to hosts in UP states.
// On every other itteration(where we have last_event time) we are collecting all the
// hosts and services which has been changed. The collecting time starts from the last
// biggest time from the events(this is retrieved from last_event parameter)
if (LAST_EVENT == 0) {
ms.log(SOURCE + ": INITIAL RUN");
isInitialized = false;
hostEvents = this.getResult('/objects/hosts', {
"filter": "host.state==1"
});
// Because we need to store last event time per type,
// if we don't have any events for the current type on the Initial run
// of the script, we are setting the current time as last event time,
// so we'll have what to split on the next iteration
// (this is done only on the INITIAL run for the script)
if (hostEvents.length <= 0) {
lastEventHost = new Date().getTime();
}
servicesEvents = this.getResult('/objects/services', {
"filter": "host.state==0"
});
// Because we need to store last event time per type,
// if we don't have any events for the current type on the Initial run
// of the script, we are setting the current time as last event time,
// so we'll have what to split on the next iteration
// (this is done only on the INITIAL run for the script)
if (servicesEvents.length <= 0) {
lastEventService = new Date().getTime();
}
} else {
lastEventHost = parseFloat(splittedLastEventSignature[0]);
lastEventService = parseFloat(splittedLastEventSignature[1]);
hostEvents = this.getResult('/objects/hosts', {
"filter": ("host.last_state_change>" + this.getIcingaTime(lastEventHost))
});
servicesEvents = this.getResult('/objects/services', {
"filter": ("service.last_state_change>" + this.getIcingaTime(lastEventService))
});
}