Nagios jabber notification

Nagios can be configured to send notifications by various ways email “the default notification for Nagios”, sms and jabber …
It’s very flexible enough to let you develop reel solutions.
In this tutorial we will focus on how to configure nagios to send notification to your jabber account using twisted.

First install python-twisted interface.
On Debian and derive like Ubuntu use apt like this:
$ sudo apt-get install python-twisted

You can check twisted website for more informations :

Later, append to contacts_nagios2.cfg the notifications method notify-host-by-jabber and notify-service-by-jabber
Also, set up a new paramter address1 that must contain your(s) jabber account.

$ sudo vim /etc/nagios3/conf.d/contacts_nagios2.cfg
define contact{
contact_name root
alias Root
service_notification_period 24×7
host_notification_period 24×7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-email,notify-service-by-jabber
host_notification_commands notify-host-by-email,notify-host-by-jabber
pager +212669119530

And let’s define the command that will be interpreted when nagios call notify-host-by-jabber and notify-service-by-jabber
So change /home/mezgani/script/ by the path of your python bot, the output of the command will be redirected
to the log file /var/log/nagios3/jabber.log
Add the following to your /etc/nagios3/commands.cfg.

$ sudo vim /etc/nagios3/commands.cfg

# ‘notify-host-by-jabber’ command definition
define command{
command_name notify-host-by-jabber
command_line /home/mezgani/script/ “$CONTACTADDRESS1$” “$NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” > /var/log/nagios3/jabber.log

# ‘notify-service-by-jabber’ command definition
define command{
command_name notify-service-by-jabber
command_line /home/mezgani/script/ “$CONTACTADDRESS1$” “$NOTIFICATIONTYPE$ : $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)” > /var/log/nagios3/jabber.log

Well, here i define the jabber bot named fdbot, it is a python script based on twisted framework that transforms your message to a valid jabber message.
You can choose your script language it can be done with perl using ‘Net::XMPP’, with ruby using ‘xmpp4r’, and others.
my choise of python was just for my need to learn twisted framework.

You can Get fdbot by git like:
$ git clone git://
set up the undefined variables in the script.

and restart nagios:
$ sudo /etc/init.d/nagios3 restart

The source code at Github. Go visit the Github project page for fdbot.


Author: Ali MEZGANI

My name is MEZGANI Ali. I was born back in 1978 in Rabat Morocco. My interests are Debian Linux , programming , science and music.

6 thoughts on “Nagios jabber notification”

  1. Do you know if it’s possible to have usernames with the ‘at’ sign in them as well (in addition to having the server name)? I keep getting “twisted.words.protocols.jabber.jid.InvalidFormat: Invalid character in hostname”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s