Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

Table of Contents

Prerequisites

...

Adding new Notification Types to NMIS

Creating a New Notification Method Package

To add a new notification method, you will need to copy the example Perl code which is in the distribution, which should be at /usr/local/nmis8/lib/Notify/mylog.pm, this is a functional notification method.  If you wanted to add something called NetSMS you would copy that tile to NetSMS.pm, so 

Code Block
/usr/local/nmis8/lib/Notify/mylog.pm /usr/local/nmis8/lib/Notify/NetSMS.pm

Then you need to edit the file NetSMS.pm and change the following

Code Block
package Notify::mylog;

To be the package name for NetSMS, e.g.

Code Block
package Notify::NetSMS;

At this point you can run this at test it, you can do this by adding an escalation type, which will be NetSMS.

Add a New Notification to Escalations.nmis

Looking at Escalations.nmis which is in the conf directory at /usr/local/nmis8/conf/Escalations.nmis, look for the entry "default_default_default_default__"

Code Block
 'default_default_default_default__' => {
   'Event' => 'default',
   'Event_Element' => '',
   'Event_Node' => '',
   'Group' => 'default',
   'Level0' => 'syslog:localhost,json:localhost,NetSMS:Contact1',
   'Level1' => '',
   'Level10' => '',
   'Level2' => '',
   'Level3' => '',
   'Level4' => '',
   'Level5' => '',
   'Level6' => '',
   'Level7' => '',
   'Level8' => '',
   'Level9' => '',
   'Role' => 'default',
   'Type' => 'default',
   'UpNotify' => 'true'
 },

Modify the line for "Level0" and add ",NetSMS:Contact1", you will now get notifications using the code in /usr/local/nmis8/lib/Notify/NetSMS.pm, the next time you get a notification look in /tmp/mylog for the file.

Creating Your Own Notification

Now you know its working you can modify the contents of the subroutine "sendNotification" to do what you want to do, in the example it is just logging to a file, but you can put anything here Perl can do (which is alot).

You have access to the following data.

Sample Contact Details

FieldDescription

Contact

The contact ID or name

DutyTime

The on duty string for this contact

Email

The email address for this contact

Location

The location of this contact

Mobile

Mobile number can be used for SMS alerting

Pager

Pager value (does anyone still have these?)

Phone

The phone number

TimeZone

Timezone offset from GMT

Sample NMIS

...

Event Details

Depending on your system and what features you have enabled, there may be more values, but at a minimum you will have the following

FieldDescription

ack

Has the event been acknowledged or not?

details

The details associated with the event
elementThe element associated with the event, e.g. interface name
escalateWhat level is the escalation at
levelCriticality of the event
nodeThe node the event is related to.
timeThe time the event was generated
notifyWho was notified about the event.

Feedback

We would love you get your feedback, please let us know if you had any problems or would like more information at contact@opmantek.com