blob: bfdbbc7d2166133ec77e4946065bd91fa7541f2d (
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
|
#!/bin/bash
. settings
logger -t sublab-updater starting status update
insertstatus() {
local ec=$?
local status
if [ $ec -eq 0 ]; then
status=online
else
status=offline
fi
cp ${WEBPATH}/csstemplate/${status}.${1}.status.css ${WEBPATH}/public/css/${1}.status.css.new
mv -f ${WEBPATH}/public/css/${1}.status.css.new ${WEBPATH}/public/css/${1}.status.css
return $ec
}
apistatus() {
[ -d "${WEBPATH}/public/api" ] || mkdir -p "${WEBPATH}/public/api"
if [ "`cat \"${WEBPATH}/public/api/status\" 2>/dev/null`" != "$1" ]; then
wget -q http://127.0.0.1:8042/send -O /dev/null "--post-data=message=sublab status is now: $1"
fi
echo $1 > "${WEBPATH}/public/api/status"
}
# Ping Taifun
ping -q -c 2 -W 1 172.22.83.5 &> /dev/null
insertstatus taifun
global_state=$?
# Ping Trieste
ping -q -c 2 -W 1 172.22.80.4 &> /dev/null
insertstatus trieste
# Ping Nautilus
ping -q -c 2 -W 1 172.22.80.7 &> /dev/null
insertstatus nautilus
there_state=$?
if [ $global_state -eq 0 ]; then
if [ $there_state -eq 0 ]; then
apistatus open
else
apistatus closed
fi
else
apistatus unknown
fi
exit 0
|