Running Custom Script in ServiceNow via Opsgenie Actions
Have you ever felt constrained by the tools you use? Have there been tasks that you wanted to complete, but couldn’t because the tool at hand was not flexible? Have you ever used services that barely meet your minimum requirements? Or have you used a service that seemed to meet your needs but actually restricted you in a different way? If you answered any of these questions with “yes”, then we have good news for you. There are tools that truly adapt to your needs such as Opsgenie.
To illustrate the flexibility of Opsgenie, let's look at this use case:
Let’s say Nagios is your main infrastructure monitoring tool and ServiceNow is your main service management platform. For ease of use and accessibility, the following are likely desired functions:
To manage problems detected by Nagios as incidents within ServiceNow
To track the status of incidents and problems with your infrastructure in ServiceNow
To see the work notes added by responders working on the problem via ServiceNow
To have the incident resolved automatically in ServiceNow once the corresponding problem is solved in Nagios
Here is how Opsgenie can enable this:
Nagios detects problems and creates alerts. These alerts automatically create corresponding alerts in Opsgenie. When the right conditions are met, the Opsgenie alerts automatically trigger incident creation in ServiceNow. When the alerts are closed by Nagios, different close codes of ServiceNow are added to Opsgenie alerts as notes; then the close action is sent to ServiceNow via Opsgenie. From Opsgenie alert notes, the close code is retrieved and corresponding Close action is executed on ServiceNow incidents.
Without Opsgenie orchestrating all of these, you’d need to constantly manually check the alert statuses on Nagios or ask the operators.
Let’s see that in action, shall we?
This is the configuration in Opsgenie for close action of our Nagios integration:
This configuration can be interpreted as, when an alert is closed by Nagios, a note which says “Close Code: Solved (Permanently)” is added to the alert in Opsgenie.
This is the configuration for callback actions of our ServiceNow integration:
This configuration can be interpreted as, when an Opsgenie alert is closed, execute the “resolveWithCode” script* in ServiceNow on the corresponding incident.
Nagios creates an alert and Opsgenie gets that alert information:
Opsgenie creates an incident in ServiceNow to correspond to that alert:
Then the alert in Nagios is closed which closes the corresponding alert in Opsgenie. According to the Nagios configuration above, a note which says “Close Code: Solved (Permanently)” is added to that alert:
Closing the Opsgenie alert triggers the execution of “resolveWithCode” script in ServiceNow. This script changes the incident’s state from New to Resolved:
By orchestrating the workflows just like the one we just explored, Opsgenie keeps all your tools and teams in sync . Sign up for a free trial to experience it yourself!