Hi there!
Do you know this problem?! You have to get up at some certain time in the morning, so you set up your alarm clock to give you a friendly “rrrrrrring-rrrrring”. But you simply don’t wake up! Your alarm clock rings and rings and rings for like hours but you simply don’t hear it. Sometimes, you use the snooze button, but you cannot even remember you did it.
Well, that’s like how I feel sometimes in the morning. Bad thing, if you have some kind of meeting or appointment. Several times in the past, I sent automated e-mails to my co-workers to give me a wakeup call on my cellphone, this surprisingly always works. But it’s annoying. For me and my co-workers.
Here comes the solution:
use nagios to give you a highly sophisticated wakeup call.
Imagine, you have a linux box which is under surveillance of a nagios remote monitoring system. And imagine furthermore, this nagios system is configured to send out voice calls in cases of critical states. All you need is a new plugin (most commonly via NRPE) which tells nagios to initiate your wakeup call.
This is how I do it:
1. Add the following line to your NRPE config file on your linux box (e. g. /etc/nagios/nrpe.cfg
):
command[wakeupcall]=/usr/lib/nagios/plugins/wakeupcall
2. Create the plugin and place it on your linux box at /usr/lib/nagios/plugins/wakeupcall
#!/bin/bash # # nagios nrpe plugin to initiate a wakeup call # 2009, Thomas Gericke, thomas (at) thomasgericke (dot) de # FILE="/etc/wakeupcall/wakeupcall" if [ -e $FILE ]; then echo "Wakeupcall needed. Gonna hit ya!" exit 2 else echo "No wakeupcall needed. Sleep well." exit 0 fi
3. Restart your NRPE service on your linux box (e. g. /etc/init.d/nagios-nrpe-server restart
)
4. Set up the service check in your nagios configuration on your nagios server
I assume, you already have the host configured on your nagios system and you already are familiar with nagios’ notifications. Here’s the service check you need:
define service { use generic-service max_check_attempts 1 notification_options c service_description Wakeup Call host_name YOUR.HOST.NAME check_command check_nrpe!wakeupcall contact_groups YOUR_CONTACT_GROUP }
I hope you’re familiar with nagios’ service check templates and such stuff.
5. Reload your nagios on your nagios server (e. g. /etc/init.d/nagios reload
)
6. Create the wakeupcall config directory on your linux box (mkdir /etc/wakeupcall/
)
7. Set up a file for an at-job on your linux box (e. g. ~/add.wakeupcall
)
touch /etc/wakeupcall/wakeupcall
8. Set up an at-job on your linux box once you need to be woken up
at -f ~/add.wakeupcall 06:40
Your linux box will create /etc/wakeupcall/wakeupcall
at 6.40AM (the very next time this moment occurs), nagios will realize it and will initiate the notification. If you have configured your nagios server to send out voice calls to your cellphone, you will receive a wakeup call.
Have fun, comments are appreciated! 🙂
Disclaimer:
Once you are awake, you need to remove the file /etc/wakeupcall/wakeupcall unless you want to be woken up again and again and again and again… 🙂
Only delete the file and *not* the whole directory /etc/wakeupcall/