WEBSITE MONITOR

Picture of monitor device I run a number of websites on different IP addresses and it's useful to be able to monitor them remotely. In this particular situation I have five IP addresses, four of which are currently in use. I built a monitor, based on the ESP8266, that displays the website status and also supports a webpage that I can access from anywhere over my VPN.

The device connects to the building's WiFi and has status LEDs for its WiFi connection and for the ADSL (broadband) service. The LEDs show red when the connection or service is not available and green when everything is working as expected. In the image here, website 41 is not configured so to avoid the LED showing red (not available) it is set to off.

Each website has its own criterion for whether it's operational or not. Simple websites may be said to be available if the homepage is accessible. On the other hand two of my websites, a primary and a backup, show the mains frequency in Great Britain and for those there are different criteria:

  1. are the websites responding with valid data
  2. are they giving results that are within 0.05Hz of each other

For your websites, you will need to decide the criteria that indicate an operational website.

BASIC TESTS

The monitor performs a number of actions when it runs:

  1. it tries to connect to one of a number of pre-programmed WiFi APs and shows flashing green while it does so. When it connects to an AP it shows a steady green LED. If no connection is possible, then it shows red.
  2. Once connected, it checks that it can ping 8.8.8.8, showing green if it can - and that means the ADSL is working and it has access to the Internet - and red otherwise. 8.8.8.8 is a Google DNS server so is likely to be both available and unchanging.
  3. for each website, the monitor runs through tests that are appropriate for each, as explained above, and then shows a green or red LED to indicate success or a possible problem.

WEB INTERFACE

Picture of webpage When the monitor has completed the checks, it looks for any incoming HTTP requests. Any request triggers the same webpage, which is created on-the-fly, and contains the usual HTML rubric, CSS style information and a self contained SVG image that represents the physical front panel.

The webpage is self-contained but does refer to two other resources on a separate server: a TTF file and a background JPG image. If these are not available, the page degrades gracefully to a standard font and plain background. At some point I shall put both these resources on the ESP8266 so that no external server is required.

HARDWARE CONSIDERATIONS

The ESP8266 does not have enough GPIO pins to drive seven LEDs in bi-colour mode - 14 pins required - so I used the Microchip MCP23017 16-Bit I/O Expander with I2C interface. For more information on how to add the library for this chip, please see this page.

When you define the base starting address for the 16 pins, the pins will be assigned sequential addresses that map to GPA0 to GPA7 then GPB0 to GBP7. So, for example, GPB1 will have an address that is base+9. Also note that the A and B banks are not organised as you might expect with regard to pin numbers.

Microchip MCP23017 address structure