30 September 2019

Custom Notification Methods for NMIS Events

Custom Notification Methods for NMIS Events

While working with customers who want to extend NMIS we have created various methods for notifications, making it a highly extensible Network Management System.  To support custom notification methods, the logic to initiate a notification and the method for delivering the notification has been split, so that additional notification methods can be added without having the modify the core part of NMIS.

Notification Extensibility in NMIS

What are Notifications in NMIS?

NMIS raises an event internally and then applies an escalation policy to the event, the result of this escalation policy is a notification.  A notification method can be logging, email, SMS, netsend or any number of other types.  You can write a notification method outside of NMIS core code and it will be used as required at runtime.

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, by default is 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

/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

package Notify::mylog;

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

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__”:

'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 a lot). Opmantek has developed custom notifications for customers quite often, connecting third-party software that cannot get the level of detailed  information that NMIS can, such as Service Now, and pushing notifications into their incident management platform.

Want to connect the wealth of information that NMIS can gather into your existing solution, contact us and we can show you how.