20. 08. 2009 Georg Kostner NetEye, Unified Monitoring

Notificazioni Nagios sull’iPhone


Nel blog di un nostro partner della Netways in Germania ho trovato un bell’articolo su come integrare la notificazione di Nagios con il sistema di Apple Direct Push per l’ iPhone. Tramite il servizio e API di Prowl è possibile integrare la notificazione in Nagios e avere in direct Push le informazioni sull’iPhone.
Prowl è il Growl client per l’iPhone.

La descrizione completa su come integrare il direct Push per l’iPhonie in Nagios:

  1. 1. Come servizio per la comunicazione push con l’iPhone viene usato Prowl. Per poter usare questo servizio bisogna registrare un account su “Register
  2. 2. Per l’Autentificazione degli script Prowl usa un API Key. Dopo avere avuto accesso Prowl con il proprio account potete prendere la chiave nella sezione “Settings”.  Ogni iPhone deve avere un suo account con una sua key per poter integrare più contact in Nagios.
  3. Sull’iPhone bisogna installare l’applicazione Prowl iPhone dall’App Store(costi una tantum 2,39 euro). Dopo l’installazione dell’applicazione bisogna inserire la proprio login e password. Se l’applicazione funziona correttamente si può testare dal sito di Prowl nella sezione “Add A Notification” e spedirsi un messaggio Prowl di test.
  4. Adesso passiamo alla configurazione sul Nagios Server. Per prima cosa dobbiamo caricare sul server il Prowl Perl Script.
    # cd /usr/lib/nagios/plugins/eventhandler
    # wget http://prowl.weks.net/static/prowl.pl
    # chmod 755 prowl.pl
  5. Gli script necessitano di librerie Perl libwww-perl libcrypt-ssleay-perl
  6. Una volta installato lo script si può fare un test manuale:
    ./prowl.pl -apikey=”APIKEY_HERE” -application=”Nagios” -event=”Notification” -notification=”Questo é un test”
  7. Adesso passiamo all’integrazione al Nagios Server. Siccome gli account di Prowl sono per iPhone / contact potrebbe essere una buona idea memorizzare l’API Key sul contact. Per raggiungere questo obiettivo si può usare una variabile custom.
    define contact {
    contact_name gk_iPhone
    alias Georg Kostner
    service_notification_period 24×7
    host_notification_period 24×7
    service_notification_options w,u,c,r
    host_notification_options d,u,r
    service_notification_commands notify-service-by-prowl
    host_notification_commands notify-host-by-prowl
    _prowl_apikey APIKEY_HERE
    }
  8. Il prossimo passo é la definizione degli apositi commandi:
    define command {
    command_name notify-host-by-prowl
    command_line $USER2$/prowl.pl -apikey=”$_CONTACTPROWL_APIKEY$” -priority=1 -application=”Nagios” -event=”Host Notification” -notification=”$HOSTNAME$ $HOSTSTATE$ ‘$HOSTOUTPUT$'”
    }define command {
    command_name notify-service-by-prowl
    command_line $USER2$/prowl.pl -apikey=”$_CONTACTPROWL_APIKEY$” -priority=1 -application=”Nagios” -event=”Service Notification” -notification=”$HOSTNAME$ $SERVICEDESC$ $SERVICESTATE$ ‘$SERVICEOUTPUT$'”
    }

Importante é di non usare l’embedded Perl per questo script siccome non funziona correttamente. Se l’ePN viene usato allora scrivere sui commands “/usr/bin/perl -w /usr/lib/nagios/plugins/eventhandlers/prowl.pl”

Georg Kostner

Georg Kostner

Business Unit Manager at Würth Phoenix
I’m Georg, born in Bolzano in 1971. The IT has always been my true passion: my first computer was a Spectrum, maybe someone still remembers it… the first application I developed on it was the naval combat. Later on I started the implementation of ERP software using C, C++, Java, Informix, Oracle, Unix, Window. Recently I approached the Open Source technologies like Nagios, Cacti, MRTG, NagVis, OCS Inventory, GLPI, ntop with the vision to improve the working activities of the system administrators. In my free time I love hiking in the mountains, skiing, playing football as well as I like comparing different OS like Linux, Windows or Mac trying to find the potentialities and weaknesses.

Author

Georg Kostner

I’m Georg, born in Bolzano in 1971. The IT has always been my true passion: my first computer was a Spectrum, maybe someone still remembers it… the first application I developed on it was the naval combat. Later on I started the implementation of ERP software using C, C++, Java, Informix, Oracle, Unix, Window. Recently I approached the Open Source technologies like Nagios, Cacti, MRTG, NagVis, OCS Inventory, GLPI, ntop with the vision to improve the working activities of the system administrators. In my free time I love hiking in the mountains, skiing, playing football as well as I like comparing different OS like Linux, Windows or Mac trying to find the potentialities and weaknesses.

Leave a Reply

Your email address will not be published. Required fields are marked *

Archive