Michael's blog OSS / Linux, networking and my private life

14 Dez/09 4

OpenNMS Prowl alerts

Having an iPhone user and Prowl had installed was now to my OpenNMS with Prowl for alerting couple.
Prowl because a well-described API and also provides ready-made scripts for this in various languages ​​(Perl, Python, ...) makes available, I decided for this variant.
I have used this version of Perl, is prowl.pl downloaded here .

However, there was the parameter passing (API key, application, etc.) from OpenNMS to prowl.pl some difficulties. Solution of the problem is a small wrapper that is called by OpenNMS, and in the background according to parameterized prowl.pl calls.

prowl_wrapper.pl

 # / Usr / bin / perl  } my $cmd = $prowl . " ";} My $ cmd = $ prowl."  $apikey . " -Apikey ". $ Apikey."  $application . " \" -priority=" . $priority . " -Application = \ "". $ Application. "\" Priority = ". $ Priority."  $event . " \" -notification= \" " . $msg . " \" " ; my $return = qx ( $cmd ) ; print $return ; ".. $ Event"..-Event = \ "\"-notification = \ "" $ msg "\" "; my $ return = qx ($ cmd); print $ return; 

Important here, the respective Prowl API key for the wrapper is properly adjusted, for this I used the pager email address in order to OpenNMS for each contact to be able to specify another.

Enclosed you will find the necessary configs for OpenNMS:

notificationCommands.xml

  > <command binary "true" =>
         <name> notifyProwl </ name>
         <Execute> / usr / local / bin / prowl_wrapper.pl </ execute>
         <comment> send notifications Prowl </ comment>
         > <Argument "false" streamed =>
             <switch> pemail </ switch>
         </ Argument>
         > <Argument "false" streamed =>
             <switch> subject </ switch>
         </ Argument>
     </ Command>