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:
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
Leave a Reply