Skip to content

Instantly share code, notes, and snippets.

@rljohnsn
Last active January 17, 2016 20:55
Show Gist options
  • Save rljohnsn/8529806 to your computer and use it in GitHub Desktop.
Save rljohnsn/8529806 to your computer and use it in GitHub Desktop.
OpenNMS configuration to post messages to Hipchat
<!-- Notification configuration to map a high thresh hold exceeded event to a hipchat message -->
<!-- OPENNMS_HOME/etc/notifications.xml -->
<!-- Rule can be as specific as desired. Filter using categories or service checks. -->
<!-- I'm using a category that matches the Hipchat Room name and a category -->
<!-- indicating production (EnvironmentFilter) -->
<notification name="Hipchat - High Threshold Exceeded room specific filter" status="on" writeable="yes">
<uei>uei.opennms.org/threshold/highThresholdExceeded</uei>
<description>A monitored device has reached a high threshold</description>
<rule>(IPADDR != '0.0.0.0') &amp; (catincRoomfilter) &amp; (isServiceName) &amp; (catincEnvironmentFilter)</rule>
<destinationPath>Hipchat</destinationPath>
<text-message>room_id=RoomFilter&amp;from=OpenNMS&amp;message=High+threshold+on+%nodelabel%+%parm[ds]%+reached+%parm[value]%&amp;color=yellow</text-message>
<subject>Notice #%noticeid%: High Threshold for %parm[ds]% on node %nodelabel%.</subject>
</notification>
<!-- A destination path and corresponding user need to exist -->
<!-- OPENNMS_HOME/etc/destinationPaths.xml -->
<path name="Hipchat" initial-delay="0s">
<target interval="0s">
<name>hipchat</name>
<autoNotify>on</autoNotify>
<command>hipchat</command>
</target>
</path>
<!-- User -->
<!-- OPENNMS_HOME/etc/users.xml -->
<user read-only="false">
<user-id>hipchat</user-id>
<full-name>hipchat</full-name>
<user-comments>service account to allow for hipchat room updates. notification system requires a target user or group.</user-comments>
<password salt="true">generated_from_the_UI</password>
<contact type="email" info=""/>
<contact type="pagerEmail" info=""/>
<contact type="xmppAddress" info=""/>
<contact type="microblog" info=""/>
<contact type="numericPage" info="" serviceProvider=""/>
<contact type="textPage" info="" serviceProvider=""/>
<contact type="workPhone" info=""/>
<contact type="mobilePhone" info=""/>
<contact type="homePhone" info=""/>
<duty-schedule>MoTuWeThFrSaSu0-2359</duty-schedule>
</user>
<!-- Notification command, using curl to post to hipchat API -->
<!-- OPENNMS_HOME/etc/notificationCommands.xml -->
<!-- Generate your API_KEY from hipchat.com -->
<command binary="true">
<name>hipchat</name>
<execute>/usr/bin/curl</execute>
<comment>Post a message to Hipchat using curl</comment>
<argument streamed="false">
<substitution>-d</substitution>
</argument>
<argument streamed="false">
<switch>-tm</switch>
</argument>
<argument streamed="false">
<substitution>https://api.hipchat.com/v1/rooms/message?auth_token=API_KEY&amp;format=json</substitution>
</argument>
</command>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment