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

14 Dez/09 4

OpenNMS Prowl alerts

When I, as iPhone users also Prowl 've installed it was now a matter of my OpenNMS with Prowl for alerting couple.
As Prowl 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 were in 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 adapted for that I've 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> Prowl send notifications </ comment>
         > <Argument "false" streamed =>
             <switch> pemail </ switch>
         </ Argument>
         > <Argument "false" streamed =>
             <switch> subject </ switch>
         </ Argument>
     </ Command>