Last Updated: March 06, 2017
·
1.195K
· rljohnsn

OpenNMS Hipchat Notifications

We love hipchat. On our team email is considered the place where collaboration goes to die. As a result we try and funnel all our information channels into hipchat rooms. We have integrated github, codeclimate, zendesk, chef-client, knife, bugsnag, teamcity, pingdom and now OpenNMS for service alerts.

https://gist.github.com/rljohnsn/8529806

<!-- 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>

1 Response
Add your response

Hi. I stumbeled over this post while trying to set up a curl request on OpenNMS. So far i've created a new user, the destination path and the notification, but i can't find where to create the command. Could you tell me? Thx! OPENNMS_HOME/etc/notificationCommands.xml doesn't exist btw

over 1 year ago ·