-
-
Save tzarskyz/6822198 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# GeekTool script to display status of websites you monitor. See http://projects.tynsoe.org/en/geektool/ | |
# Displays name of site if there's no error. Adds "!!!!" in front of unavailable site. | |
# Sends an email when a site is unavailable. | |
ARRAY=( | |
'awebsite.com' | |
'anotherwebsite.com' | |
'onemore.com' | |
) | |
ELEMENTS=${#ARRAY[@]} | |
function check { | |
STATUS=$? | |
case $STATUS in | |
6) | |
update "Unable to resolve host." $1 | |
;; | |
7) | |
update "Failed to connect to host." $1 | |
;; | |
18) | |
update "Partial file. Only a part of the file was transferred." $1 | |
;; | |
77) | |
update "Problem with reading the SSL CA cert (path? access rights?)." $1 | |
;; | |
78) | |
update "The resource referenced in the URL does not exist." $1 | |
;; | |
0) | |
echo " " $1 | |
;; | |
*) | |
echo " " $STATUS $1 | |
;; | |
esac | |
} | |
function update { | |
# send error via email | |
echo $1 | mail -c [email protected] -s "Website Error: $2" [email protected] | |
# update GeekTool display | |
echo "!!!!" $2 | |
} | |
for ((i=0;i<$ELEMENTS;i++)); do | |
curl -s -o "/dev/null" ${ARRAY[$i]} | |
check ${ARRAY[${i}]} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment