#!/bin/sh
#This script will check the explorer every 10 minutes using its API.
#If getting no response or the block height doesn't change compared
#with 10 min ago, the script will restart the explorer. mhps
while true; do
block=`curl -s http://blockexplorer.nu/api/statusInfo | awk 'BEGIN{RS=",\"";FS=":"}{print $1,$2}' | grep heightInt | awk '{print $2}'`;
d=`date --utc`;
if [[ $block == "" ]]; then
echo $d Explorer not responding;
restart=1;
else
if [[ $block == $lastBlock ]]; then
echo $d Blockchain height not changing for 10 min;
restart=1;
else
echo $d Block $block;
lastBlock=$block;
restart=0;
fi;
fi;
if [[ $restart == "1" ]]; then
echo Restarting explorer;
# add code to restart the explorer
fi;
sleep 600;
done
Possible problem: when the network really couldn’t find a new block somehow in 10min the explorer will get restarted. (It’s possible to compare the explorer with alix.)
More possible problem: if this script runs on the same server where the explorer runs, it might happen that the explorer looks fine from the same server but couldn’t be accessed from outside.