-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheckdigitsl.sh
executable file
·63 lines (37 loc) · 1.07 KB
/
checkdigitsl.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
61
62
63
#!/usr/bin/env bash
# show status of all digits in a line suitable for logging
# line starts with time followed by one letter per digit in order
# .=Good,P=ping ailed, H=Host lookup failed
# timestamp
##printf $(date "+%4y%2m%2d %2H%2M ")
printf $(date "+%k%M ")
# top row...
for h in {1..12}; do
if addr=$(getent hosts $(printf "h%02d" $h)); then
ip=$(echo $addr | awk '{ print $1 }')
if ping -c 1 $ip >/dev/null; then
printf "."
else
printf "P"
fi
else
printf "H"
fi
done
# bottom rows...
for r in {0..4}; do
for c in {0..11}; do
m=$(((r*12)+c))
if addr=$(getent hosts $(printf "m%02d" $m)); then
ip=$(echo $addr | awk '{ print $1 }')
if ping -c 1 $ip >/dev/null; then
printf "."
else
printf "P"
fi
else
printf "H"
fi
done
done
printf "\n"