2022-11-03 08:39:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#set -eux
|
|
|
|
|
2022-11-03 09:48:53 +00:00
|
|
|
RECIPIENTS="saunders@openworlds.info"
|
|
|
|
#witchescauldron@openworlds.info"
|
2022-11-03 08:39:42 +00:00
|
|
|
|
|
|
|
send_mail() {
|
2022-11-03 09:48:53 +00:00
|
|
|
# Use bash's awful syntax to escape any / in the server string
|
|
|
|
SERVER=${1//\//\\\/}
|
2022-11-03 08:39:42 +00:00
|
|
|
STATUS=$2
|
|
|
|
cat mail_template \
|
2022-11-03 09:48:53 +00:00
|
|
|
| sed "s/{SERVER}/${SERVER}/g" \
|
|
|
|
| sed "s/{STATUS}/${STATUS}/g" \
|
|
|
|
| msmtp -a omn_server_watch ${RECIPIENTS}
|
2022-11-03 08:39:42 +00:00
|
|
|
}
|
|
|
|
|
2022-11-03 09:48:53 +00:00
|
|
|
URLS=(
|
|
|
|
unite.openworlds.info
|
|
|
|
openworlds.info
|
|
|
|
pad.openworlds.info
|
|
|
|
visionon.tv
|
|
|
|
)
|
|
|
|
# TODO: How to check these sensibly?
|
|
|
|
SERVICES=(
|
|
|
|
chat.openworlds.info
|
|
|
|
conference.openworlds.info
|
|
|
|
# Not much point checking the mail server
|
|
|
|
# as this script relies on it to send reports
|
|
|
|
#mail.openworlds.info
|
|
|
|
)
|
|
|
|
|
|
|
|
declare -A FLAGGED
|
|
|
|
|
|
|
|
for uri in "${URLS[@]}"; do \
|
|
|
|
full_uri="https://${uri}"
|
|
|
|
echo -n "Checking: ${full_uri} ... ";
|
|
|
|
stat="$(curl -s -o /dev/null -w "%{http_code}%{stdout}" ${full_uri})"
|
|
|
|
echo "${stat}"
|
|
|
|
|
|
|
|
if [ "${stat}" -ne "200" ]; then
|
|
|
|
FLAGGED[${full_uri}]=${stat}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in "${!FLAGGED[@]}"; do \
|
|
|
|
send_mail "${i}" "${FLAGGED[$i]}"
|
|
|
|
done
|