Sent "server down" information to Slack channel

Run a script hourly as a cronjob that checks if your servers are up and running, if not, sent message to a certain Slack channel.


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.

Slack allows the integration of “apps”. One particular intersting app is called “incoming webhook”. This allows to sent messages to a channel via a URL POST request. Great.

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:

I save the above in a file, and make the file executable. Finally, I set up a cronjob that runs the script every hour. Edit you cronfile with crontab -e and add the following line at the bottom:

Save the file. Done!

Obviously Slack’s “incoming webhook” can be used for a range of other things. Pretty neat.

Publications // latest

Genome-wide profiling of transcribed enhancers during macrophage activation. Epigenetics & Chromatin, 2017, 10:50

Distinct gut microbiome patterns associate with consensus molecular subtypes of colorectal cancer. Scientific Reports, 2017, 7(1):11590

Consensus molecular classification of colorectal cancer and association with the colonic microbiota. Diseases of the Colon & Rectum, 2017, 60(6):E90-E91 (In proceedings: Annual Meeting of the American Society of Colon and Rectal Surgeons)

News&Blog // latest

[ 20180126 | news ] PhD scholarship available in bioinformatics

[ 20171024 | news ] New publication: Epigenetics & Chromatin

[ 20170915 | news ] New publication: Sci Rep

[ 20170906 | blog ] A list of journals

[ 20170726 | news ] Invited guest lecture at the SBS, University of Auckland

Tweets // latest