Last active
March 20, 2018 17:13
-
-
Save tomfanning/615512693b911da6a14fca0a20efa77b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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