From 4bd60b4f3f541c7af734ed40043e70c888450691 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 15 Mar 2014 15:01:34 -0300 Subject: Squashed 'mod/lorea-status/' content from commit 6189193 git-subtree-dir: mod/lorea-status git-subtree-split: 6189193ac4771080871f6dab74853051f747490c --- bin/lorea_refresh_status | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 bin/lorea_refresh_status (limited to 'bin') diff --git a/bin/lorea_refresh_status b/bin/lorea_refresh_status new file mode 100755 index 000000000..bce60dc30 --- /dev/null +++ b/bin/lorea_refresh_status @@ -0,0 +1,43 @@ +#!/bin/zsh +# +## Check if hosts are up and running + +typeset -A SEEDS +typeset -a STATUS + +if [ ! -f /etc/default/lorea-status ] ; then + echo "Missing /etc/default/lorea-status configuration file. Aborted." + exit 1 +fi +source /etc/default/lorea-status + +for s in ${(k)SEEDS} ; do +# echo "$s => ${SEEDS[$s]}" + ping -c 1 -W 3 ${SEEDS[$s]} &>/dev/null + if (( $? )) ; then + STATUS+="{\"host\":\"$s\",\"ping\":0,\"running\":-1}" + else + # Host is up, check service + echo -n "ping... " +# pong=$(/usr/bin/wget -q -T 3 -O- https://$s/.ping) +# wget does not support SNI? + pong=$(/usr/bin/wget --no-check-certificate -q -T 3 -O- https://$s/.ping) + echo $pong + if [[ "pong $s" == "$pong" ]] ; then + STATUS+="{\"host\":\"$s\",\"ping\":1,\"running\":1}" + else + STATUS+="{\"host\":\"$s\",\"ping\":1,\"running\":0}" + fi + fi +done +# join array elements with a comma +OLD_IFS=$IFS +IFS=, +STATUS="{\"seeds\":${#SEEDS},\"list\":[${STATUS}]}" +IFS=$OLD_IFS + +setopt CLOBBER +pushd /var/www/status.lorea.org/pub +echo "$STATUS" > status.json.new +mv status.json.new status.json +popd -- cgit v1.2.3