blob: a5fb64d70efe9133a7c1e92179df1919403dc755 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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 -xa 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 -xa $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 -xa $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"
|