-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_room.sh
executable file
·60 lines (53 loc) · 1.62 KB
/
check_room.sh
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
#!/bin/bash
# Copyright 2019,2020 Tobias Küchel <[email protected]>
# This piece of software is licensed under:
# SPDX-License-Identifier: GPL-3.0-or-later
room=$1
## LINBO
#parallel-ssh -h /etc/hosts.$room -O "Port 2222" -O "UserKnownHostsFile ~/.ssh/linbo_hosts" -O "PubkeyAcceptedKeyTypes=+ssh-dss" -o asdf.out -e asdf.err -P uptime >/dev/null
#echo "Linux?"
#parallel-ssh -h /etc/hosts.$room -o asdf.out -e asdf.err -P uptime >/dev/null
while read host;
do
ping -c 1 -t 2 $host 2>/dev/null >/dev/null
if [ $? -eq 0 ]; then
# LINBO?
echo -n -e "\033[2K\033[100D"
echo -n "$host: "
RETlinbo=$(linbo-ssh -T -n -o "ConnectTimeout=1" $host uptime 2>/dev/null)
if [ $? -eq 255 ]; then
# Linux?
RETlinux=$(ssh -T -n -o "ConnectTimeout=1" $host cat /.linbo 2>/dev/null )
if [ $? -eq 255 ]; then
echo "neither LINBO nor Linux, not a PC?"
else
echo -n "$RETlinux, status: "
resp=$(ssh -T -n -o "ConnectTimeout=1" $host who)
if [ -z "$resp" ]; then
echo "idle: " `ssh -T -n -o "ConnectTimeout=1" $host ps aux | sort -nrk 3,3 | head -n 1 | cut -c 1-50`
else
echo $resp
fi
fi
else
echo -n "$RETlinbo, LINBO status: "
resp=$(linbo-ssh -T -n -o "ConnectTimeout=1" $host 'ps aux | grep linbo_cmd | grep -v grep')
if [ -z "$resp" ]; then
echo "idle"
fi
if echo $resp | grep initcache > /dev/null; then
echo "initcache"
fi
if echo $resp | grep sync > /dev/null; then
echo "syncing"
fi
fi
else
if [ -n "$2" -a "$2" = "--showoffline" ]; then
echo "$host: offline, maybe?"
else
echo -n "."
fi
fi
done </etc/hosts.$room
echo