howto setup Instant messenger (IM) notifications in nagios

Recently i undertook a project to setup Instant Messenger alerts from nagios .

Nagios is highly configurable.Once we understand the elegant nature in which nagios works and get configured ,extending nagios to send IM alerts is quite childs play .Thanks to many user contributed scripts that allow you to connectto many Instant Messaging Gateways. I used a modified version of

http://nagios.sourceforge.net/download/contrib/notifications/notify_via_jabber

contributed by David Cox to the Nagios Community . For the need of a XMPP server , i installed my own private OpenFire ( http://www.igniterealtime.org/projects/openfire/index.jsp ) server . You may also try to setup accounts in public XMPP servers like http://jabber.org for this purpose. Basically the perl script connects to the jabber server you specified in the script and sends out the notification to you

Here is the configuration :

1. You have to define a command that can be used to acomplish something when there is a host/service related event. For the first timers if you are recieving email notifications from nagios;you can check your commands.cfg file to see something like notify-host-by-email command defenition!

similarly for IM alerts we define a command

==========
# This command is used to notify recipients of service problems:
# 'notify-by-jabber' command definition
define command{
command_name notify-by-jabber
command_line /usr/local/nagios/libexec/notify_via_jabber.pl $CONTACTADDRESS1$ "$HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$\r\nAdditional Info: $SERVICEOUTPUT$"
}
# This command is used to notify recipients of host problems:
# 'host-notify-by-jabber' command definition
define command{
command_name host-notify-by-jabber
command_line /usr/local/nagios/libexec/notify_via_jabber.pl $CONTACTADDRESS1$ "$NOTIFICATIONTYPE$: $HOSTNAME$ is $HOSTSTATE$\n$HOSTOUTPUT$"
}

=====================

As you can see we have called a command_line program => /usr/local/nagios/libexec/notify_via_jabber.pl

which is our perl script

Please download the following perl script from http://gnusys.net instead of the sourceforge one ;as i got it working only after having a small change in the perl script

==========

wget http://gnusys.net/downloads/notify_via_jabber.pl

==========

Find the following lines in the script and change it accordingly

==============


use constant SERVER => 'gnusys.net';
use constant PORT => 5222;
use constant USER => 'notify@gnusys.net';
use constant PASSWORD => 'd3fault';

===============

What more……….?

You need to use the notification commands somewhere.

==========================


define contact{
contact_name anoop
use generic-contact
alias Anoop
email no-email@gnusys.net
address1 no-im@gnusys.net
host_notification_commands notify-host-by-email,host-notify-by-jabber
service_notification_commands notify-by-jabber
host_notification_period 24x7
service_notification_period 24x7
service_notification_options c,r
}

===============================

Now if you are logged into no-im@gnusys.net ; you should start receiving alerts from notify@gnusys.net

If you need help setting this up contact anoop[at]gnusys.net

Share and Enjoy:
  • Digg
  • Mixx
  • del.icio.us
  • StumbleUpon
  • Facebook
  • TwitThis
  • Technorati
  • Google

Tags:

7 Responses to “howto setup Instant messenger (IM) notifications in nagios”

  1. dave Says:

    Has anyone gotten this to work using Google’s Talk service rather that installing their own jabber server?

  2. neil Says:

    hi,

    i have a question. i am getting the following error when running ./notify_via_jabber.pl:

    “Ident/Auth with server failed: 401 - ”

    my question is regarding the parameters below:
    use constant USER => ‘notify@gnusys.net’;
    use constant PASSWORD => ‘d3fault’;

    is ‘notify’ a user in openfire with the password ‘d3fault’?

    if i have a user “admin” with the password “admin”, should i set the parameters to:
    use constant USER => ‘admin@example.com’;
    use constant PASSWORD => ‘admin’;

    i’d appreciate the reply. sorry if this sounds stupid but i’m a noob with this. thanks a lot!

  3. Derek Morris Says:

    I dont get the pop up when i run this. the script shows no error but nothing gets popped up. I have tried spark and pidgin to no avail.Please help!

  4. Luke Sheldrick Says:

    Neil,

    Seen your comment, and I have encountered this problem myself, when using a similar script, originally by David Cox.

    I had modified the script to work with openfire servers, as they use a different authentication method.

    I’ve copied a copy of my script here http://luke.sheldrick.co.uk/jabbermail.pl feel free to use it.

    As for the notification account, you do not need to use the whole address, just the before @. I set up a new account on my jabber server, called system, so in my config file I have all my noficiations coming from system.

    I also changed the text in the command, to say which nagios host the alert was coming from, as I have a number of Nagios pollers, checking the same services, so useful to see where the blockage is coming from :)
    Cheers
    Luke

  5. lynx Says:

    can i use this script for yahoo messenger instead of jabber. what are the things that i need to change. Please help.

    Thanks..

  6. LaraNO Says:

    Have writing an essay assignment and don’t know the right way to move? Don’t be confused, just because the purchase essays service can aid you with your essay writing very abruptly. Hence why not to use this kind of assistance?

  7. Howto setup Instant messenger (IM) notifications in nagios | Tutorilas | Technical Tips | Articles | Interview Tips Says:

    [...] Source : http://gnusys.net/kb/index.php/2008/09/howto-setup-instant-messenger-im-notifications-in-nagios/ [...]

Leave a Reply