Skip to content

Instantly share code, notes, and snippets.

@tomfanning
Last active March 20, 2018 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomfanning/615512693b911da6a14fca0a20efa77b to your computer and use it in GitHub Desktop.
Save tomfanning/615512693b911da6a14fca0a20efa77b to your computer and use it in GitHub Desktop.
#!/bin/bash -e
# called by cron every minute
function postToInflux(){
curl -ss -o /dev/null --connect-timeout 5 -X POST 'https://influxdb.trlsoftware.com/write?db=database&u=user&p=pass' --data-binary "web_up,site=$1 value=$2 $(date +%s%N)"
}
declare -A sites
declare -A check
sites["site1name"]="http://url-of-site"
check["site1name"]="text to match"
sites["site2name"]="http://url-of-site2"
check["site2name"]="text to match 2"
for site in "${!sites[@]}"; do
if /root/test-web.sh ${sites[$site]} ${check[$site]} >/dev/null ; then
postToInflux $site 1
else
postToInflux $site 0
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment