#Crontab

1 post tagged Crontab

Prowl: check server status (using ping)

· Apple, Linux, Networking, Software

Yesterday I’ve start using Prowl, as I heard good comments about it. And one of the things I want it to check, are my server statuses. I made a quick script using bash and crontab to check every 10 min if it replies on ping. Per server, I created “host.domain.tld.sh” (e.g. zero.rootspirit.com.sh), and added this in the file:

#!/bin/bash
KEY=YourApiKey
HOST=zero.rootspirit.com
ping -c 1 $HOST   &>/dev/null
if [ $? -ne 0 ] ; then
curl -k -s "https://prowl.weks.net/publicapi/add?apikey=$KEY&application=Server%20Connectivity%20Failure&event=&description=$HOST&priority=2"
fi

Of course, change KEY to your API key, HOST to the IP or DNS of the server it should ping. Also, make sure, that when pinging on your host where you’ll run the bash script on, a non-existing domain actually returns: