bin bash Основной скрипт мониторинга по snmp wres tail -n res tmp cat

 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
77
#!/bin/bash
#Основной скрипт мониторинга по snmp
#v 0.4
wres(){
tail -n 2 res > tmp && cat tmp > res && echo $1 >> res && rm tmp
}
wget --http-user --http-password http://site/list.php -O prep_list -o /dev/null
for SERVER in `cat commented`
do
cat prep_list | grep -v $SERVER > temp && cat temp > prep_list
done
rm temp
cat prep_list > _list
rm prep_list
cat anotherservers >> _list
LINES=`cat _list | grep -v "#" | sort | uniq | grep '.' | wc -l`
rm log
rm _log
for UNIC in `cat _list | grep -v "#" | awk '{print($2)}' | sort | uniq`
do
for IP in `cat _list | grep -v "#" | grep $UNIC | sort | uniq | awk '{print($1)}'`
do
snmpstatus -c $UNIC -v 1 -L e $IP > servers/log.$IP 2>&1
done
done
cat servers/log.* >> _log
rm servers/log.*
cat _log | grep -v "Timeout" | grep "UDP" > log
cat _log | grep "Timeout"
DONE=`cat log | wc -l`
RES=$(($LINES-$DONE))
if [ "$RES" = "0" ];
then wres 0
else wres 1
fi
for NUM in `cat res`
do
I=$(($I+$NUM))
done
ZZ=`cat res | tail -n 1`
if [ "$ZZ" != "0" ]
then
if [ "$I" = "3" ];
then mplayer /home/v2nek/monit/Dance.mp3
#then echo "shit..."
else echo "Hmmm.."
fi
else echo "Its ok"
fi