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.

PYTHON · CODING · SLACK · LINUX

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

MinION Sequencing of colorectal cancer tumour microbiomes – a comparison with amplicon-based and RNA-Sequencing. PLoS One, 2020, accepted.

Molecular subtyping improves prognostication of Stage 2 colorectal cancer. BMC Cancer, 2019, 19, 1155

DeePEL: Deep learning architecture to recognize p-lncRNA and e-lncRNA promoters. In proceedings: IEEE International Conference on Bioinformatics and Biomedicine, 2019, B516, accepted.

News&Blog // latest

[ 20190528 | news ] Recent funding successes.

[ 20190319 | news ] New publication: Frontiers in Immonology

[ 20190122 | news ] New publication: BMC Genomics

[ 20181230 | news ] New publication: Molecular Phylogenetics and Evolution

[ 20180703 | news ] New publication: Nature Methods

Tweets // latest