zeldor.biz

Linux, programming and more

Copyright © 2023
Log in

Nagios/Icinga Traffic-Light

April 13, 2011 by Igor Drobot 6 Comments

Nagios and Icinga have a lot of notification opportunities, receive status via Mail, SMS, Twitter or maybe XMPP? Sometimes is it not easy to decide what you really need and what is better for your quick reaction.

If you have more than one monitor it is easy to overlook an important mail, or your mobile phone is in silent mode and you don’t know that you get a critical notification.

If you are a webmaster and you are working a lot with your browser – there is a solution for Mozilla Firefox with terrible wake up sounds – called Nagios Checker for Mozilla Firefox:

But what is if you are a little bit geeky? You need a geeky solution!

Before I go on, I have to thank the Axxeo GmbH team, which has brought this crazy idea to life, support in the development and financing.

This traffic-light could be your problem prevention system, you will be the first who see and fix it.

Components you need to build it:
– You will need something what looks like a traffic light; I found a old signal tower (siemens/werma) in ebay with some broken leds, no problem new resistors and leds and looks like new:)
– Now you need a controller to switch the lights ; The first and easiest solution that I found was a 8-channel relay card with RS232 and USB ports.
– To run the relay card I used a 12V DC adapter
– To bring the relays to switch you need a piece of software – I used a simply C written program written by Thomas Dohl (If you buy a relay card you will get a CD with source code and some examples)
– To connect the signal tower with relay card I used my old PS2 mice cable

The hard part was to get the newest events from the monitoring system, I started with a cron-job which parsed the output from nagios3stats command, but I stuck with it. There was no useful information about the acknowledged services.
My first code worked without the ack. functions, and it was slow.

Code: This code was written by Enrico Righes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
 
NAG=10.1.100.60
NAGIOSFILE="/var/lib/nagios3/retention.dat"
STATEFILE="/tmp/nagios.state"
 
OK=0 WARN=1 CRIT=2 UNKNOWN=3
CODES=(00000100 00000010 00000001 00000110)
 
check_state()
{
    egrep "current_state=.|acknowledged=." $NAGIOSFILE | \
    (
    final=$OK IFS='='
    while read key state && read key acked; do
        [ $acked = 1 ] && continue
        [[ $final = $OK || $state = $CRIT || ($final = $UNKNOWN && $state = $WARN) ]] && final=$state
        [ $final = $CRIT ] && break
    done
 
    if [ $(<$STATEFILE) != $final ]; then
        echo $final >$STATEFILE
        ssh $NAG "/usr/sbin/relaycontrol -d /dev/ttyS0 -r 1 -s ${CODES[$final]}; beep" >/dev/null
    fi
    )
}
 
check_state
exit 0

#!/bin/bash NAG=10.1.100.60 NAGIOSFILE="/var/lib/nagios3/retention.dat" STATEFILE="/tmp/nagios.state" OK=0 WARN=1 CRIT=2 UNKNOWN=3 CODES=(00000100 00000010 00000001 00000110) check_state() { egrep "current_state=.|acknowledged=." $NAGIOSFILE | \ ( final=$OK IFS='=' while read key state && read key acked; do [ $acked = 1 ] && continue [[ $final = $OK || $state = $CRIT || ($final = $UNKNOWN && $state = $WARN) ]] && final=$state [ $final = $CRIT ] && break done if [ $(<$STATEFILE) != $final ]; then echo $final >$STATEFILE ssh $NAG "/usr/sbin/relaycontrol -d /dev/ttyS0 -r 1 -s ${CODES[$final]}; beep" >/dev/null fi ) } check_state exit 0

By the way some beep signals make the thing much funnier;)

Conclusion:
– It will really help you, be concentrated on your work and don’t miss the important events
– Nice eye catcher

Ideas for you!
– If you have a arduino board, it is the perfect solution for that
– If you want to buy a relay card, try to find a 230V one, you could switch a real traffic-light from the street.
– You can play the sounds from the Simpsons Homer: d’oh and Burns: excellent

And of course some pictures: – Click to resize!

Also you can download all photos in original size (~13.3 MB)

Filed Under: Debian, DIY, Linux, Monitoring, Networking, Ubuntu Tagged With: Icinga, Icinga Traffic-Light, Monitoring, Nagios, Nagios Traffic-Light

Categories

Archives

Tags

apache2 Apple arduino ARM Automation backup bash Cisco Cluster Corosync Database Debian Debian squeeze DIY DNS Fedora FTP Fun Icinga Ipv6 KVM Linux LVM MAC OS X Monitoring MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy Python python3 qemu RAID rsync Samba security ssh Ubuntu virtualization Windows Windows 7 Wordpress

Comments

  1. zeldor says

    July 6, 2011 at 18:05

    Thank you Thijmen! All these components costs about 45€. The universal relay card controller was very expensive, but it has enough free slots for another funky ideas;)

  2. Thijmen Stavenuiter says

    July 6, 2011 at 17:10

    How much did it cost overall? :) Looks awesom!

  3. kimsanov says

    June 8, 2011 at 23:06

    That is really cool!

Trackbacks

  1. Stopping Traffic with Icinga | Icinga says:
    January 28, 2019 at 09:25

    […] ups… the list goes on. Igor Drobot from Hannover, Germany shared his new favourite: a handmade, monitoring traffic light. Tinkering with an old LED signal tower he found on Ebay, a relay card with corresponding program […]

  2. Happy 2nd Birthday Icinga! - Icinga, IcingaDroid, Android, Fischer, Chrome, Google - Open Source Monitoring says:
    May 6, 2011 at 10:37

    […] his Icinga Chromed Status for Google Chrome, Karl Fischer IcingaDroid for Android phones, and Igor Drobot his Icinga traffic […]

  3. Stopping Traffic with Icinga - Igor, Icinga, Righes, Install, Enrico, Just - Open Source Monitoring says:
    April 28, 2011 at 10:45

    […] There are many ways you can receive your Icinga notifications- via email, SMS, Twitter, instant messaging, or desktop pop ups… the list goes on. Igor Drobot from Hannover, Germany shared his new favourite: a handmade, monitoring traffic light. […]

Leave a Reply

Your email address will not be published. Required fields are marked *