Delete Comment Automatically on resolve of an issue

Hello

is there a known script / mechanism (director way) already written which will delete the comment as soon as or may be after 1 hour of the problem is resolved.

Actually we will push Ticket Number in the comment when a problem is created. If there is a existing script which triggers as soon as a clearing event is received - that will be nice

Regards

Hi

don’t know a script what is doing this, but it should be easy to create with a bash script, a cronjob and the icinga-API action “remove-comment” and some filter

Idea: Instead of pushing the ticket number into a comment, why to acknowledge the problem with hat ticket number?
The acknowledgement will the be removed as soon as the host/services recovers.

The ticket number is pushed because we need the ticket reference number - so that when a issue is resolved in icinga - we can fire and resolve the incident as well…

Any suggestion idea - please welcome. But obviously once the ticket is resolved if the problem re-occur we need to open a new ticket if it is after long time. Or we can reopen the same ticket if problem re-occurs within lets say 1hr

you could create the comment and add your ticket id as an author.
later you can search for tickets by author and delete them.

it’s not my favourite option but it will work

a better approach would be to save the comment_name (host!service!hash) in your ticket so your ticket system knows the exact comment to delete afterwards

Not quite sure what your aim is.

  • Is it to resolve the ticket created by a problem when the host/check recovers?
  • or do you only want to delete a comment containing a ticket number when the host/check recovers?

If it is the first that (imo) should be handled by the ticket system. If there is an existing ticket for a host or service of a host, then update the status. If the system can’t handle that you would need a script that checks for the ticket number contained in the (ack) comment and then does something with it on the ticket system side. The script then should be run when a recovery notification would be sent.

If it is the second just using ack instead of a simple comment would do the trick, bc the ack gets removed on recovery.

ServiceNow provided 3 APIs

1, To create an incident
2. To resolve an incident
3. To query the status of an incident

So I have created a python script which will fire when a Service in icinga is WARNING or CRITICAL. The script will post the data in ServiceNow API and in turn ServiceNow will return with a Incident Number.

Now If I have to query the status of the incident or to resolve the incident when the icinga Service Gets Resolved to OK status I will need the INCIDENT number so that I can query the right incident or resolve the right INCIDENT in the ServiceNow API I need to pass the incident number.

Hence we need to hold the incident number somewhere from the opening of incident to the closure of incident.

I think this should be doable wit another script that you that use as a recovery notification script and an extra apply rule for just this type of notification.

  1. Have the script query the Icinga API for the host/service objects comments (host and/or service name given as parameter when calling the script.
  2. Extract the ticket number from the comment and use it to update the status or resolve the issue via the ServiceNow API.
  3. Delete only the comment containing the ticket number from the host/service object via the Icinga API.

is there a real example of such an implementation?

Yes we do have integration with servicenow