Running Custom Script in ServiceNow via OpsGenie Actions

by Ufuk Ozcelik Dec 14, 2017

opsgenie-servicenow-integration.png

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:

opsgenie1.png

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:

opsgenie2.png

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:

opsgenie3.png

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:

opsgenie4.png

 

OpsGenie creates an incident in ServiceNow to correspond to that alert:

opsgenie5.png

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:

opsgenie6.png

Closing the OpsGenie alert triggers the execution of “resolveWithCode” script in ServiceNow. This script changes the incident’s state from New to Resolved:

opsgenie7.png

 

opsgenie8.png

resolveWithCode script

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!