The other day we had a power-cut. I was forewarned, so I was able to shut down my server in time. Before I did so, I was sending messages to my team via Slack, so that they could finish up their work before the server went down. This got me thinking. I thought it would be neat to have a message automatically appearing in a Slack channel if some server of interest could not be reached anymore, so that one can investigate.
I wrote a quick and dirty Python script that checks the health of a list of hosts via a “ping” (yes, not very sophisticated). Should a ping fail, the script will sent a message to the specified Slack channel:
Save the file. Done!
Obviously Slack’s “incoming webhook” can be used for a range of other things. Pretty neat.