2016-06-12 Updated script: Solarwinds 12.x appears to have deprecated the AddNote() action for the Orion.AlertStatus object so that it can't append comments to alerts for some kinds of Solarwinds objects (e.g. Hardware Sensors). Instead, you must use the AppendNote() action and the Orion.AlertActive object if you want this script to work reliably with alerts for all kinds of Solarwinds objects. To use the new script, you must make three changes in Solarwinds and in OpsGenie.
- In any Solarwinds alert action that sends updates to OpsGenie, add the line "AlertObjectID=${N=Alerting;M=AlertObjectID}&" to the POST body. Orion.AlertActive.AppendNote() requires this value.
- In OpsGenie, modify your Solarwinds integration. In the "Extra Properties" section, add an entry with the name "AlertObjectID" (no quotes) and the value "{{AlertObjectID}}" (no quotes).
- In OpsGenie, modify your Marid integration. In the "Extra Properties" section, add an entry with the name "AlertObjectID" (no quotes) and the value "{{AlertObjectID}}" (no quotes).
Description
We're using OpsGenie to notify our on-call engineers when an alert is triggered in Solarwinds. OpsGenie provides a pre-built integration tool for getting Solarwinds alerts into OpsGenie. However, they don't deliver a method for getting updates to OpsGenie alerts back into Solarwinds. I wanted the engineers to be able to manage both the OpsGenie alert and the original Solarwinds alert with a single action.
OpsGenie provides the Marid integration server free of charge. The Marid server subscribes to your OpsGenie account and is aware of any updates to your OpsGenie alert actions (close, delete, add note, acknowledge, etc.).
I created the Groovy script SolarwindsActionHandler.groovy to act on OpsGenie's Close, Acknowledge, and AddNote actions. When everything is configured, closing or acknowledging an alert in OpsGenie will acknowledge the corresponding alert in Solarwinds (since you can't manually close an alert in Solarwinds). Adding a note in OpsGenie will add a comment to the alert in Solarwinds.
Requirements
An OpsGenie account, configured to handle alerts originating from your Solarwinds server
A Marid installation on a server you manage
A Solarwinds account that can acknowledge alerts
Configure OpsGenie
Edit your Solarwinds integration. In the "Extra Properties" section, add an entry with the name "AlertObjectID" (no quotes) and the value "{{AlertObjectID}}" (no quotes).
Edit your Marid integration. In the "Extra Properties" section, add an entry with the name "AlertObjectID" (no quotes) and the value "{{AlertObjectID}}" (no quotes).
Configure Marid
Copy the attached script SolarwindsActionHandler.groovy to the /var/ops/opsgenie/marid/scripts directory on your Marid server. Correct the permissions and ownership:
chmod 775 /var/ops/opsgenie/marid/scripts/SolarwindsActionHandler.groovy
chown opsgenie:opsgenie /var/ops/opsgenie/marid/scripts/SolarwindsActionHandler.groovy
Edit /etc/opsgenie/marid/marid.conf as follows.
Find the lines beginning with:
actions.AddNote.script=
actions.Close.script=
actions.Acknowledge.script=
and change them to:
actions.AddNote.script=SolarwindsActionHandler.groovy
actions.Close.script=SolarwindsActionHandler.groovy
actions.Acknowledge.script=SolarwindsActionHandler.groovy
Add this section at the end of the file, substituting appropriate values for your Solarwinds installation:
solarwinds.url=https://<your solarwinds server IP or FQDN>:17778
solarwinds.host=<your solarwinds server IP or FQDN>
solarwinds.login=<name of Solarwinds user that can acknowledge alerts>
solarwinds.password=<password for Solarwinds user that can acknowledge alerts>
Restart Marid:
service marid restart