Hi All,

I've posted this issue previously on the users list at
http://sourceforge.net/p/opennms/mailman/message/34290617/ but didn't get a
reply. I'm hoping someone here may be able to help me determine if I'm
doing something wrong or if this is a bug that needs reporting.

Thanks, Ian.

Having a couple of issues with the HTTP notification strategy that I just
can't seem to get to the bottom of.

Here's my config from notifications.xml:

    <notification name="NodeDown" status="on" writeable="yes">
        <uei>uei.opennms.org/nodes/nodeDown</uei>
        <rule>(IPADDR IPLIKE *.*.*.*)</rule>
        <destinationPath>HTTP_Path</destinationPath>
        <text-message>All services are down on node %nodelabel%.  New
Outage records have &#xd;
been created and service level availability calculations will &#xd;
be impacted until this outage is resolved.  &#xd;
 &#xd;
Admin: %asset[admin]%  &#xd;
</text-message>
        <subject>Notice #%noticeid%: node %nodelabel% down.</subject>
        <numeric-message>111-%noticeid%</numeric-message>

        <parameter name="url" value="http://192.168.2.121:3000/api/opennms/
notify"/>
        <parameter name="timeout" value="2000"/>
        <parameter name="retries" value="1"/>

        <parameter name="post-eventid" value="%eventid%"/>
        <parameter name="post-uei" value="%uei%"/>
        <parameter name="post-source" value="%source%"/>
        <parameter name="post-time" value="%time%"/>
        <parameter name="post-nodeid" value="%nodeid%"/>
        <parameter name="post-nodelabel" value="%nodelabel%"/>
        <parameter name="post-host" value="%host%"/>
        <parameter name="post-severity" value="%severity%"/>

        <parameter name="post-admin" value="%asset[admin]%"/>
        <parameter name="post-params" value="%parm[all]%"/>
        <parameter name="post-message" value="%-tm%"/>

        <parameter name="result-match" value="(?s).*OK\s+([0-9]+).*"/>
    </notification>

Here's the config from notificationCommands.xml:

    <command binary="false">
        <name>HTTP_POST</name>

<execute>org.opennms.netmgt.notifd.HttpNotificationStrategy</execute>
        <comment>Class for sending notifications with an HTTP Post</comment>
        <argument streamed="false">
                <switch>url</switch>
        </argument>
        <argument streamed="false">
                <switch>timeout</switch>
        </argument>
        <argument streamed="false">
                <switch>retries</switch>
        </argument>
        <argument streamed="false">
                <switch>-tm</switch>
        </argument>
        <argument streamed="false">
                <switch>result-match</switch>
        </argument>
        <argument streamed="false">
                <switch>sql</switch>
        </argument>
        <argument streamed="false">
                <switch>post-eventid</switch>
        </argument>
        <argument streamed="false">
                <switch>post-uei</switch>
        </argument>
        <argument streamed="false">
                <switch>post-source</switch>
        </argument>
        <argument streamed="false">
                <switch>post-time</switch>
        </argument>
        <argument streamed="false">
                <switch>post-nodeid</switch>
        </argument>
        <argument streamed="false">
                <switch>post-nodelabel</switch>
        </argument>
        <argument streamed="false">
                <switch>post-host</switch>
        </argument>
        <argument streamed="false">
                <switch>post-severity</switch>
        </argument>
        <argument streamed="false">
                <switch>post-admin</switch>
        </argument>
        <argument streamed="false">
                <switch>post-params</switch>
        </argument>
        <argument streamed="false">
                <switch>post-message</switch>
        </argument>
    </command>

Here's what I get at the other end:

[debug] "POST" request for "api/opennms/notify" from "192.168.2.122"
[debug] Body Parameters are:
.-------------------------------------+--------------------------------------.
| Parameter                           | Value
 |
+-------------------------------------+--------------------------------------+
| admin                               | organisation_id: 4
  |
| eventid                             | 5450171
 |
| host                                | idn-be
  |
| message                             |
 |
| nodeid                              | 21
  |
| nodelabel                           | hostname
   |
| params                              | nodelabel="hostname"
   |
| severity                            | Major
 |
| source                              | OpenNMS.Poller.DefaultPollContext
 |
| time                                | Monday, 13 July 2015 07:24:18
o'clo- |
|                                     | ck BST
  |
| uei                                 | uei.opennms.org/nodes/nodeDown
  |
'-------------------------------------+--------------------------------------'

This is exactly what I'd expect from the nodeDown event. The fun starts
when the nodeDown clears:

[debug] "POST" request for "api/opennms/notify" from "192.168.2.122"
[debug] Body Parameters are:
.-------------------------------------+--------------------------------------.
| Parameter                           |
Value                                |
+-------------------------------------+--------------------------------------+
| admin                               | organisation_id:
4                   |
| eventid                             |
5450171                              |
| host                                |
idn-be                               |
| message
|                                      |
| nodeid                              |
21                                   |
| nodelabel                           | hostname
                   |
| params
|                                      |
| severity                            |
6                                    |
| source                              |
OpenNMS.Poller.DefaultPollContext    |
| time                                | Monday, 13 July 2015 00:00:00
o'clo- |
|                                     | ck
BST                               |
| uei                                 | uei.opennms.org/nodes/nodeDown
|
'-------------------------------------+--------------------------------------'

So the odd behaviour is:

   - Severity is 6
   - The time is midnight this morning (whatever the day is)
   - The fact that is is a RESOLVED event doesn't get passed through

On having a dig through the debug logging for notifd I can see:

2015-07-13 07:26:46,059 DEBUG [Notifd:BroadcastEventProcessor-Thread]
o.o.n.n.BroadcastEventProcessor: Sending RESOLVED:  notification to userID
= admin for notice ID 1694
2015-07-13 07:26:46,060 DEBUG [Notifd:BroadcastEventProcessor-Thread]
o.o.n.n.NoticeQueue: autoNotify task queued
2015-07-13 07:26:46,721 DEBUG [Thread-1024] o.o.n.n.NotificationTask: Class
created is: class org.opennms.netmgt.config.notificationCommands.Command
2015-07-13 07:26:46,722 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: url null 'http://192.168.2.121:3000/api/opennms/notify' false
2015-07-13 07:26:46,722 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: timeout null '2000' false
2015-07-13 07:26:46,723 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: retries null '1' false
2015-07-13 07:26:46,723 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: -tm null 'RESOLVED: All services are down on node hostname.  New
Outage records have
been created and service level availability calculations will
be impacted until this outage is resolved.

Admin: organisation_id: 4
' false
2015-07-13 07:26:46,723 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: result-match null '(?s).*OK\s+([0-9]+).*' false
2015-07-13 07:26:46,724 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: sql null '' false
2015-07-13 07:26:46,724 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-eventid null '5450171' false
2015-07-13 07:26:46,724 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-uei null 'uei.opennms.org/nodes/nodeDown' false
2015-07-13 07:26:46,724 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-source null 'OpenNMS.Poller.DefaultPollContext' false
2015-07-13 07:26:46,725 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-time null 'Monday, 13 July 2015 00:00:00 o'clock BST' false
2015-07-13 07:26:46,725 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-nodeid null '21' false
2015-07-13 07:26:46,725 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-nodelabel null 'hostname' false
2015-07-13 07:26:46,726 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-host null 'idn-be' false
2015-07-13 07:26:46,726 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-severity null '6' false
2015-07-13 07:26:46,726 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-admin null 'organisation_id: 4' false
2015-07-13 07:26:46,727 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-params null '' false
2015-07-13 07:26:46,727 DEBUG [Thread-1024] o.o.n.n.NotificationTask:
argument: post-message null '' false
2015-07-13 07:26:46,727 DEBUG [Thread-1024] o.o.n.n.ClassExecutor: Going
for the class instance: org.opennms.netmgt.notifd.HttpNotificationStrategy
I *think* that the text message (-tm) which has the 'RESOLVED: ' text added
isn't available to the notification? I've tried as many different
combinations of variables as I can think of to try and get the text but
none seem to give me what I expect.

My questions are:

   - Are the severity and time issues bugs or am I missing something
   blatantly obvious that means this isn't doing what I expect?
   - Is the message text available in the notification and I've just not
   found the right variable name?
   - Is this all expected behaviour and I should go hide back under my
   rock? :)

Research and discussion on IRC have led me to:

http://www.opennms.org/wiki/Event_Configuration_How-To
http://www.opennms.org/wiki/Notification_enhancement - which doesn't list a
variable for the text message
https://github.com/OpenNMS/opennms/blob/master/features/events/daemon/src/main/java/org/opennms/netmgt/eventd/AbstractEventUtil.java
- which doesn't seem to make the text message variable available.

If the text message is available then I can check it for 'RESOLVED: ' or
alternatively if the severity is the expected Cleared (see http
://www.opennms.org/wiki/Severity) then that would also work for me.

In the mean time, I'll disable autoNotify and create two events, one for
the down and one for the up and map them back together at the other end.

-- 
Ian Norton
------------------------------------------------------------------------------
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-devel mailing list

To *unsubscribe* or change your subscription options, see the bottom of this 
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel

Reply via email to