diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2019-10-06 04:17:15 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2019-10-06 04:17:15 +0200 |
commit | fd952ed16761afcc231f16ae566af769ae1bf929 (patch) | |
tree | 0e2c607d039eca5cd38b0715005111caff0bbc2a /service | |
parent | a46cecb394738926d5dac3c392e04825f94e5b2a (diff) | |
download | conky-fd952ed16761afcc231f16ae566af769ae1bf929.tar.gz conky-fd952ed16761afcc231f16ae566af769ae1bf929.tar.bz2 conky-fd952ed16761afcc231f16ae566af769ae1bf929.tar.xz conky-fd952ed16761afcc231f16ae566af769ae1bf929.zip |
Add monitoring of iperouter
Diffstat (limited to 'service')
-rwxr-xr-x | service/check_router.sh | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/service/check_router.sh b/service/check_router.sh new file mode 100755 index 0000000..82391aa --- /dev/null +++ b/service/check_router.sh @@ -0,0 +1,76 @@ +#! /bin/bash + +cd "$(dirname "$0")" +. opts.sh + + +www_checks=( + "https://ufo.kit.edu/dis/ tomography" + "http://ufo.kit.edu/ands/repos/openshift37/x86_64 origin" + "http://www.fossils.kit.edu coptera" + "http://www.katrin.kit.edu neutrino" + "http://katrin.kit.edu/data/astor/ wave" +# "http://user:pass@katrin.kit.edu/adei-hiu/ Advanced" +) + + +online=$(../scripts/ping.pl "$host") +healthy=$online + +# URL checks +for c in "${www_checks[@]}"; do + url=$(echo $c | awk '{ print $1 }') + check=$(echo $c | awk '{ $1=""; print $0 }' | sed -e 's/^[[:space:]]\+//') + + ret=$(curl -sSfL "$url" 2>&1) + if [ $? -ne 0 ]; then + echo "$url - $ret" + healthy=0 + elif [ -n "$check" ]; then + echo $ret | grep -iP "$check" &>/dev/null + if [ $? -ne 0 ]; then + echo "$url - specified keyword is not found" + healthy=0 + fi + fi +done + +# Katrin SSH forwaring +ret=$(echo "" | nc -N katrin.kit.edu 22) +if [ $? -ne 0 ]; then + echo "Error connecting katrin.kit.edu:22" + healthy=0 +else + echo $ret | grep SSH-2.0-OpenSSH_5.8 > /dev/null + if [ $? -ne 0 ]; then + echo "Unexpected SSH server listening on katrin.kit.edu:22. Banner: $ret" + healthy=0 + fi +fi + +# VPN check +ssh darksoft.org ping -W 2 -c 2 192.168.31.1 &> /dev/null +if [ $? -ne 0 ]; then + echo "Can't verify availability of UFO tunnel" + [ $healthy -eq 1 ] && healthy=2 +fi + +ping -W 2 -c 2 192.168.110.67 &> /dev/null +if [ $? -ne 0 ]; then + echo "Can't verify availability of KATRIN tunnel" + [ $healthy -eq 1 ] && healthy=2 +fi + +uptime=$(ssh $host uptime | sed -e 's/^[[:space:]]\+//') +up=$(echo $uptime | cut -d ' ' -f 3- | cut -d ',' -f 1 | sed -re 's/^\s*//') +load=$(echo $uptime | cut -d ' ' -f 3- | cut -d ',' -f 4- | cut -d ':' -f 2 | cut -d ',' -f 3 | sed -re 's/^\s*//') + +ret=$(ssh $host rpm -qi redhat-release | grep Version) +if [ $? -eq 0 ]; then + rel="RHEL $(echo "$ret" | cut -d ':' -f 2 | sed -e 's/^[[:space:]]\+//')" +else + rel="Unknown" +fi + +info=" \${color gray}/ $up, load $load" +echo "$online $healthy $rel $info" |