Configuring OpenNMS notifications

This is a quick howto that explains how to add NotifyMyAndroid push notifications on your OpenNMS.

It is based on the original Prowl guide available here .

Before we start, you will need:

  • Notify My Android Account (So you can get an API Key). You can register here .
  • Generate your API key on your My Account page. To get one, login with your account then go to "My Account". If you don't see an API key on the right side of the page, click on the "Generate New Key" Button and one should appear on your list.
  • Notify My Android installed on your Android device. You can get it on the Marketplace .
  • Download NMA Perl script and save it to /usr/bin/nma.pl
  • You need Perl SSL encryption package to send notifications with HTTPS. The required lib names are: Crypt::SSLeay and LWP::UserAgent On Ubuntu: apt-get install libcrypt-ssleay-perl liblwp-useragent-determined-perl. On CentOS/Fedora: yum install openssl-perl.
  • Create a script named /usr/bin/opennms-nma.pl with the following content: (Remember to replace <your-api-key> with your api key)
#!/usr/bin/perl -w

my $nma = "/usr/bin/nma.html";
my $apikey = "<your-api-key>";
my $application = "OpenNMS";
my $priority = 1;
my $event = "Alert";
my $msg = "";
 
foreach (@ARGV) {
        $msg .= $_." ";
}
 
my $cmd = $nma." -apikey ".$apikey.
" -application=\"".$application."\" -priority=".
$priority." -event=\"".$event."\" -notification=\"".$msg."\"";
 
my $return = qx( $cmd );
print $return;
  • Add the following content in $OPENNMS_HOME/etc/notificationCommands.xml :
  • <command binary="true">
      <name>notifyMyAndroid</name>
      <execute>/usr/bin/opennms-nma.pl</execute>
      <comment>send NotifyMyAndroid notifications</comment>
      <argument streamed="false">
        <switch>-subject</switch>
      </argument>
    </command>
    
  • Use the new notification command in your destination path