From 479ad24501c0364b9a3c5b30ddfbc16feab9aa14 Mon Sep 17 00:00:00 2001 From: Ivan Vilata-i-Balaguer Date: Wed, 27 Apr 2016 11:01:49 +0200 Subject: [PATCH] Add monitor script to check for seed node connectivity and report issues --- doc/monitor-bitsquare-sn.cron.sh | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 doc/monitor-bitsquare-sn.cron.sh diff --git a/doc/monitor-bitsquare-sn.cron.sh b/doc/monitor-bitsquare-sn.cron.sh new file mode 100755 index 0000000000..c05b9c047e --- /dev/null +++ b/doc/monitor-bitsquare-sn.cron.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# Report by email failing connections to Bitsquare seed nodes. +# +# Exit with status 2 if unreachable nodes were detected. +# +# You may drop this under ``/etc/cron.hourly``. +# Please make sure that your system can send emails. +# +# Requirements: coreutils, torify, netcat, mail. +# +# Author: Ivan Vilata-i-Balaguer + + +## BEGIN CONFIGURATION +# Email addresses to report failing nodes to, white-separated. +REPORT_TO_EMAILS=' +bsqsn@example.com +' + +# Seed node addresses to check as ONION_ADDRESS:PORT, white-separated. +# Addresses from ``SeedNodesRepository`` v0.4.4. +SEED_NODES=' +uadzuib66jupaept.onion:8000 +hbma455xxbqhcuqh.onion:8000 +wgthuiqn3aoiovbm.onion:8000 +2zxtnprnx5wqr7a3.onion:8000 +' +## END CONFIGURATION + + +failing_seed_nodes='' +for sn in $SEED_NODES; do + true | torify nc $(echo "$sn" | tr ':' ' ') > /dev/null 2>&1 + if [ $? != 0 ]; then + failing_seed_nodes="$failing_seed_nodes $sn" + fi +done + +if [ "$failing_seed_nodes" ]; then + cat <<- EOF | mail -s "Failing Bitsquare seed nodes" -- $REPORT_TO_EMAILS + The following Bitsquare seed nodes failed to accept a new connection: + + $(echo $failing_seed_nodes | tr ' ' '\n' | sed 's/^/ /') + + Please check if they have issues, thank you. + + -- + The Bitsquare seed monitor running at $(hostname -f) + EOF + exit 2 +fi