Hello
ServiceNow default collector use the following lines to pull the information from ICINGA
//If the poll is first time
hostEvents = this.getResult('/objects/hosts', {
"filter": "host.state==1"
});
servicesEvents = this.getResult('/objects/services', {
"filter": "host.state==0"
});
// Pulling events of delta time
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))
});
The full script I have posted earlier in ServiceNow Event Management Integration with iCinga2
Now my requirement is I want to restrict ServiceNow to pull events only from certain hostgroup. This was showed to us by icinga support via a ticket. But somehow we are not able to incorporate the restriction along with the above scripts. Any help will be really helpful
What we were told by icinga support was instead of the /object/host or /object/service
Use the following
/objects/hosts' -d '{ "filter": "group in host.groups && host.state==1", "filter_vars": { "group": "XXX-GroupHost-MB-ALL" }, "pretty": true }'
/objects/services' -d '{ "filter": "group in host.groups && host.state==0", "filter_vars": { "group": "XXX-GroupHost-MB-ALL" }, "pretty": true }'
/objects/hosts' -d '{ "filter": "group in host.groups && host.last_state_change >" + this.getIcingaTime(lastEventHost), "filter_vars": { "group": "XXX-GroupHost-MB-ALL" }, "pretty": true }'
/objects/services' -d '{ "filter": "group in host.groups && service.last_state_change>" + this.getIcingaTime(lastEventService), "filter_vars": { "group": "XXX-GroupHost-MB-ALL" }, "pretty": true }'
But somehow when we are not able to use it in the servicenow connector script.
Any help or direction will be nice. This will really help in multi-tenant models or if a company have 2 different ServiceNow and they want to create tickets for specifics only