I wanted a simple way to have a dashboard to show if hosts and services are alive & didn’t want to write much code and/or run up a nagios instance (or anything like that). All I care is whether it’s green or red.
I’d already been setting up HAProxy for a proxy forwarder, so I got the idea to turn on the stats page and just have a set of backends which HAProxy would check.
Sample config follows:
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 |
global daemon defaults maxconn 250 timeout connect 5s timeout client 5s timeout server 5s listen stats 0.0.0.0:2001 mode http log global timeout client 50s timeout connect 50s timeout server 50s stats enable stats hide-version stats refresh 30s stats show-node stats uri / stats auth admin:admin backend CheckMe mode tcp server s1 xxx.xxx.xxx.xxx:yy check server s2 xxx.xxx.xxx.xxx:zz check |
Make the file, then if you don’t even feel like installing haproxy, you could do a:
1 2 3 4 |
docker run -d --restart=always -d -p 2001:2001 --name stupid-simple-mon \ -v `pwd`/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro \ haproxy:1.5 |
Point your browser to http://localhost:2001/
and enter user/pass as admin
and you’re good to go. It even refreshes every 30 seconds.