Hopefully you’d read Part 2. If not you’ll need to or this wont work.
So in this part we’re going to setup the nagios stuff to set off the alert LED’s. As a little bit of background my nagios installation is on a completely separate PI to the hyperion LED’s, but I have install hyperion on this pi to make use of hyperion-remote. Yes I was being lazy I could have used other methods instead of installing the whole thing.
First my nagios installation is in ‘/usr/local/nagios’, I’m not going to go through the commands to cd and edit, if you’ve installed and configured nagios I’ll assume you can do them 🙂
This is my /usr/local/nagios/libexec/notify-hyperion.sh
#!/bin/bash STATE=$1 DURATION=23000 case $STATE in "CRITICAL") EFFECT="Red Alert" ;; "WARNING") EFFECT="Yellow Alert" ;; "OK") EFFECT="Green Alert" ;; *) ;; esac hyperion-remote -a osmc-l:19444 -d $DURATION -p 10 -e "$EFFECT" & hyperion-remote -a rasp-light:19444 -d $DURATION -p 10 -e "$EFFECT" & hyperion-remote -a webcam-pi:19444 -d $DURATION -p 10 -e "$EFFECT" &
For the nagios saavy amongst you, you’ll see I account for CRITICAL, WARNING & OK. Yes I do need to add DOWN, UNREACHABLE & UP for the host alerts
The DURATION sets how long in ms hyperion will run this effect for (best worked out in conjunction with the speed, freq & step from the hyperion config. I’ve got this just right to cut off the alert after (I think) 4 fades. I force the priority ‘-p 10’ to 10, anything else I do with hyperion generally has a priority 50, 100 or 1000 so these will take over.
The last 3 lines are 1 each for my hyperion installs, you will need to change the name’s or replace them with the IP addresses dependant upon your network configuration.
Don’t forget to make the script executable, and you can test it with ‘./notify-hyperion.sh OK’
With the above tested and working, I’ve added the following to my nagios command.cfg
# 'notify-host-by-hyperion' command definition define command{ command_name notify-host-by-hyperion command_line /usr/local/nagios/libexec/notify-hyperion.sh "$HOSTSTATE$" } # 'notify-service-by-hyperion' command definition define command{ command_name notify-service-by-hyperion command_line /usr/local/nagios/libexec/notify-hyperion.sh "$SERVICESTATE$" }
Then added the following to contacts.cfg
define contact{ contact_name nagios-hyperion alias Nagios Hyperion service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r,f host_notification_options d,u,r,f,s service_notification_commands notify-service-by-hyperion host_notification_commands notify-host-by-hyperion } define contactgroup{ contactgroup_name nagioshyperion alias Nagios Hyperion Notifications members nagios-hyperion }
For my installation I’ve then added
contact_groups nagioshyperion
To my template’s. You could add this to each service/host.
Within my setup I’ve stopped using email alerts, so changing the contacts to hyperion was fine. Within the templates I then have the notify_interval setup for 15 minutes. This means it will fire an alert to hyperion every 15 minutes. If you use email on your system too, you may not want to do this. an alternative could be changing the duration above, so that the red and yellow alerts are constant and the green run’s for a limited time before clearing down.
I did contemplate using event filters instead of contacts, so IÂ could have the emails turned back on at some point, but decided against it as I would have to check before sending a green alert that it’s not already in green or I’d just end up with green all the time.
After all of the above make sure you restart nagios for the new config to take effect.
As a side note, I was sat watching TV this evening all of a sudden my room was yellow and I thought WTF. I do have hyperion setup in my room to start the LED’s at sunset but it was still light out and shouldn’t have fired. Then it clicked NAGIOS. and yes hey presto nagios had throw this site into warning status as there were updates available. I can see it getting annoying if my ISP drops out and I end up with alerts for hours. but on the whole I’m really happy it works, all I need now is a red alert klaxon 🙂
If your interest in setting up hyperion at sunrise/sunset I’ll be writing that one up separately.