parent
f20a4344d5
commit
2c20d5bc61
|
@ -0,0 +1,3 @@
|
|||
recipients
|
||||
urls
|
||||
services
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
# Check status of a list of servers
|
||||
#
|
||||
# Any servers in URLS that yield a bad response are collated and sent via email
|
||||
# to all RECIPIENTS.
|
||||
# Any servers in urls that yield a bad response are collated and sent via email
|
||||
# to all recipients.
|
||||
# recipients are sourced from a separate file in the cwd; it is expected to
|
||||
# have a single email address per line.
|
||||
#
|
||||
# If WATCHDOG_LOG is set, all output will be redirected there.
|
||||
#
|
||||
|
@ -14,34 +16,33 @@
|
|||
|
||||
#set -eux
|
||||
|
||||
RECIPIENTS=(
|
||||
saunders@openworlds.info
|
||||
witchescauldron@openworlds.info
|
||||
)
|
||||
|
||||
URLS=(
|
||||
unite.openworlds.info
|
||||
# NOTE: [Currently down] openworlds.info
|
||||
pad.openworlds.info
|
||||
visionon.tv
|
||||
activism.openworlds.info
|
||||
campaign.openworlds.info
|
||||
#indymedia.openworlds.info
|
||||
#roadstonowhere.openworlds.info
|
||||
#indymedia.hs2rebellion.earth
|
||||
)
|
||||
# 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
|
||||
# TODO: Separate local check just for this?
|
||||
#mail.openworlds.info
|
||||
)
|
||||
|
||||
main()
|
||||
{
|
||||
local recipients_file="./recipients"
|
||||
local urls_file="./urls"
|
||||
# TODO: How to check these sensibly?
|
||||
#local services_file="./services"
|
||||
|
||||
if [ ! -f ${recipients_file} ]; then
|
||||
echo "[ERROR] Please create a file '${recipients_file}'"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f ${urls_file} ]; then
|
||||
echo "[ERROR] Please create a file '${urls_file}'"
|
||||
exit 1
|
||||
fi
|
||||
# See above TODO
|
||||
#if [ ! -f ${services_file} ]; then
|
||||
# echo "[ERROR] Please create a file '${services_file}'"
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
# Source array contents from files, ignoring commented lines
|
||||
local recipients=($(cat ${recipients_file} | sed 's/^#.*$//'))
|
||||
local urls=($(cat ${urls_file} | sed 's/^#.*$//'))
|
||||
# See above TODO
|
||||
#local services=($(cat ${services_file} | sed 's/^#.*$//'))
|
||||
|
||||
declare -A FLAGGED
|
||||
|
||||
if [ -n "${WATCHDOG_LOG}" ]; then
|
||||
|
@ -54,7 +55,7 @@ main()
|
|||
echo ">> $(date)"
|
||||
echo "== Checking:"
|
||||
|
||||
for uri in "${URLS[@]}"; do \
|
||||
for uri in "${urls[@]}"; do \
|
||||
full_uri="https://${uri}"
|
||||
echo -n " ${full_uri} ... ";
|
||||
stat="$(curl -s -o /dev/null -w "%{http_code}%{stdout}" ${full_uri})"
|
||||
|
@ -70,7 +71,7 @@ main()
|
|||
|
||||
if ((${#FLAGGED[@]} > 0)); then
|
||||
echo "== Error(s) detected. Sending mail to:"
|
||||
for rcp in ${RECIPIENTS[@]}; do
|
||||
for rcp in ${recipients[@]}; do
|
||||
echo " ${rcp}"
|
||||
done
|
||||
|
||||
|
@ -115,7 +116,7 @@ send_mail()
|
|||
|
||||
cat mail_template \
|
||||
| sed "s/{ERR_LIST}/${error_string}/g" \
|
||||
| msmtp -a omn_server_watch ${RECIPIENTS[@]} \
|
||||
| msmtp -a omn_server_watch ${recipients[@]} \
|
||||
|| echo "[ERROR] Failed to send mail!"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue