Nagios/Icinga meets Nabaztag

Posted on Monday, February 15th, 2010 at 1:25 am in

Since i have my Nabaztag-Bunny i ever wanted to use it for my Icinga notifications. I’ve found a perl script on the internet. But that one just sent out a message and not used LED flashing or ear movements also provided by the Nabaztag-API.

So I’ve wrote my own notification script in PHP. You can download it here: notify-by-nabaztag.php

You can watch a video demonstrating it in action here in the following embedded Windows Media Player or at YouTube

The script is quite simple. It’s need two arguments. The first one is the message for the TTL (text-to-speech) and the second one is the “notification type”. The notification type is either the service or host state (OK, WARNING, CRITICAL, UNKNOWN, UP, DOWN, UNREACHABLE).

Depending on the notification type the bunny is flashing in a different color and moves it’s ears to another position:

OK/UP: flashing green, ears going up
WARNING: flashing yellow, both ears are moved to the front with an angle of 45┬░
CRITICAL/DOWN: flashing red, ears going down
UNKNOWN/UNREACHABLE: flashing blue, one ear to the front, one to the back, each with an angle of 45┬░

You can configure the voice which should be used inside the script. I propose to use a US/UK one because the states are in English too. I think the script should be self-explaining. If not, just leave an comment.

When you already have Nagios/Icinga up and running you should also know how to add an new notification command. Otherwise here are the basic steps (assuming you are running Icinga within /usr/local/icinga):

1. We need php-cli installed so we can run the script on the CLI. Depending on your distro run on of the following commands

aptitude install php-cli
or
yum install php-cli

2. Download the script to your libexec-Directory:

wget http://www.sperrgebiet.org/wp-content/uploads/2010/02/notify-by-nabaztag.txt -O /usr/local/icinga/libexec/notify-by-nabaztag.php

3. Add a host and service notification command. If you want a more detailed output just add it to the right position. You’ll find all available Macros at http://nagios.sourceforge.net/docs/3_0/macrolist.html

vim /usr/local/icinga/etc/objects/commands.cfg

# ‘notify-service-by-nabaztag’ command
define command{
command_name notify-service-by-nabaztag
command_line /usr/bin/php $USER1$/notify-by-nabaztag.php “Monitoring Notification: $NOTIFICATIONTYPE$ on $HOSTNAME$ (Hostalias is $HOSTALIAS$) with Service: $SERVICEDESC$. Current servicestate is $SERVICESTATE$” $SERVICESTATE$
}

# ‘notify-host-by-nabaztag’ command
define command{
command_name notify-host-by-nabaztag
command_line /usr/bin/php $USER1$/notify-by-nabaztag.php “Monitoring Notification: $NOTIFICATIONTYPE$ on $HOSTNAME$ (Hostalias is $HOSTALIAS$). Hoststate is $HOSTSTATE$” $HOSTSTATE$
}

4. I’ve created a new time period, because I don’t want that my bunny is talking to me during the night ;)

vim /usr/local/icinga/etc/objects/timeperiods.cfg

# ‘nabazhours’

define timeperiod{
timeperiod_name nabazhours
alias Where my nabaztag is active
monday 06:00-23:00
tuesday 06:00-23:00
wednesday 06:00-23:00
thursday 06:00-23:00
friday 06:00-23:00
saturday 08:00-23:00
sunday 08:00-23:00
}

5. After that a new contact is created which use the above added notification commands and the right time period

vim /usr/local/icinga/etc/objects/contacts.cfg

define contact{
contact_name nabaztag
use generic-contact
alias My Bunny
service_notification_commands notify-service-by-nabaztag
host_notification_commands notify-host-by-nabaztag
service_notification_period nabazhours
host_notification_period nabazhours
}

6. We should have enough time to run a config-check ;)

/usr/local/icinga/bin/icinga -v /usr/local/icinga/etc/icinga.cfg

7. When no errors or warnings appear reload Nagios/Icinga and wait till problem occur ;)

/etc/init.d/icinga reload

Hope everything works as expected and you’ll find this script useful. Have fun with Nagios/Icinga and your Bunny. J

You might also be interested in

6 Comments

Add your comment

  1. Karo - February 24, 2010 at 10:19 pm

    Hans, that is very very cute and I had to tweet this! Now I just have to convince my colleague to want one too:-) Take care! Karo

  2. Scott Evans - February 25, 2010 at 11:50 am

    Such a great use of this product! Oh and using Icinga make you super cool !!!

  3. hans - March 2, 2010 at 1:31 am

    Thanks folks :)

    I’ve created another video which shows Nabaztag in a “real life szenario”. On recovery and a critical state with the notify-script. And the status-script is executed in the middle of the video. See http://www.youtube.com/watch?v=kA5g_TDLuDE

  4. Network Monitoring Software - March 22, 2010 at 2:14 pm

    [...] sperrgebiet's world: Nagios/Icinga meets Nabaztag [...]

  5. chapter 7 lawyer cost - September 9, 2014 at 3:29 pm

    First of all I want to say terrific blog! I had a quick question that
    I’d like to ask if you don’t mind. I was interested to find out how
    you center yourself and clear your mind prior to writing.
    I’ve had a tough time clearing my thoughts in getting my thoughts out.
    I do enjoy writing but it just seems like the first 10 to 15 minutes are wasted just trying to figure out how
    to begin. Any recommendations or hints? Thank you!

  6. social media Stevenage - September 26, 2014 at 11:21 pm

    I believe everything omposed was very logical. But, what about this?

    what if you were to write a awesome headline? I mean, I don’t want to tell you how to
    run your blog, but what if you added a title that grabbed a person’s attention? I
    mean sperrgebiet’s world: Nagios/Icinga meets Nabaztag is kinda vanilla.
    You migtht look at Yahoo’s home page and watch
    how they create news headlines to grab viewers to click.
    You might add a video or a picture or twoo to grab people
    interested about what you’ve got to say. Just my opinion,
    it could make your possts a little bbit morre interesting.

Leave a Reply

Leave A Comment


5 + = 9

Top