Previously, I wrote a small article describing how my cloud based server logs from Logentries were sending alerts to my phone via SMS. This time, for fun, I have taken it one step further and now an alert from Logentries triggers the lights in my home to flash red when there is an issue on our servers. This could easily be done in an office as well.

One of Logentries’ features I use often is an alerting system that notices when an issue occurs notifies us. This notification makes a HTTP call and which is the underpinning of how I configured Logentries to trigger a red flashing sequence on the lights in my home.

First, an overview of the topology:

Topology

 

How It Works

  1. My web server is hosting the production website. I just indicated it as a single machine, but in reality it is multiple frontend web servers behind an Amazon Elastic Load Balancer. They are continually piping their logs to the Logentries service.
  2. Logentries receive all these logs, storing and processing them. I have set up an alarm there which notices if a particular log entry matches a certain criteria and if so, makes a web service call via HTTP POST to the Parsing server.
  3. The Parsing server receives this HTTP call. In reality it is not a dedicated server, it’s shared for other uses as this part is rarely used. Its purpose is to translate the HTTP post from Logentries into the particular call via UDP which is required for the lights to be activated and controlled. The parsing server receives the Logentries call, interprets it and sends the respective UDP call to the house.
  4. The Wi-Fi router in the house receives the UDP datagram. A hole on a particular port has been punched through the firewall to facilitate this. Also, the use of dynamic DNS was required for the parsing server to know the IP address of the house router. So, the UDP signal passes through the Wi-Fi router and is directed to the LED light’s Wi-Fi bridge, which is on a static assigned IP within the house.
  5. The Wi-Fi bridge receives the UDP call and sends a 2.4GHz signal to the respective LED bulb in the house.
  6. The LED bulbs in the ceiling receive the signal and turn on, flash red and off 3 times to signify the alert. Then I hop off the couch and spring into superhero-sysadmin mode.

Check out this video to see this process in action:

 

More Detailed Instructions

The screenshot below shows how to create an alarm in Logentries and for the action, set it to “POST me a notification” to the URL of the parsing server.

Logentries_Screenshot

 

The code for the parsing server was written in ASP.NET C#. It could of course be written in whatever your favourite language is for getting machines to do your bidding. I am including the whole thing as a zip file download, but the important bits are shown below:

Equipment used:

  1. Internet connected lightbulbs
  2. Wi-Fi to bulbs bridge (comes free with the light bulbs)
  3. Regular web server (referred to as parsing server above).
  4. Home router: Nothing fancy but you will need to be able to open a port on it.
WordPress Backup