aboutsummaryrefslogtreecommitdiff
path: root/mod/lorea-status/bin
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-15 15:01:34 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-15 15:01:34 -0300
commit939a44d6d08a560ba966be96b17d9038eac77f34 (patch)
tree1683cd5490a66a9cb90a8781b867e663c5a22e02 /mod/lorea-status/bin
parent991a965fcdbbcdd5ad754949a8b2bebc97b807b7 (diff)
parent4bd60b4f3f541c7af734ed40043e70c888450691 (diff)
downloadelgg-939a44d6d08a560ba966be96b17d9038eac77f34.tar.gz
elgg-939a44d6d08a560ba966be96b17d9038eac77f34.tar.bz2
Merge commit '4bd60b4f3f541c7af734ed40043e70c888450691' as 'mod/lorea-status'
Diffstat (limited to 'mod/lorea-status/bin')
-rwxr-xr-xmod/lorea-status/bin/lorea_refresh_status43
1 files changed, 43 insertions, 0 deletions
diff --git a/mod/lorea-status/bin/lorea_refresh_status b/mod/lorea-status/bin/lorea_refresh_status
new file mode 100755
index 000000000..bce60dc30
--- /dev/null
+++ b/mod/lorea-status/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