-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_snmp_temp
165 lines (144 loc) · 3.85 KB
/
check_snmp_temp
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#! /bin/bash
# substring-extraction.sh
#
PATH="/usr/local/nagios/"
SNMPGET="/usr/bin/snmpget"
EXPR="/usr/bin/expr"
PROGNAME=`/usr/bin/basename $0`
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1.4 $' | /bin/sed -e 's/[^0-9.]//g'`
. $PROGPATH/utils.sh
print_usage() {
echo "Usage: $PROGNAME -H Host -o OID -n name -w Warn in Grad -c Critical in Grad"
echo "Usage: $PROGNAME --help"
echo "Usage: $PROGNAME --version"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "Temperatur via SNMP auslesen"
echo ""
support
}
# Make sure the correct number of command line
# arguments have been supplied
if [ $# -lt 1 ]; then
print_usage
exit $STATE_UNKNOWN
fi
# Grab the command line arguments
exitstatus=$STATE_WARNING #default
while test -n "$1"; do
case "$1" in
--version)
print_revision $PROGNAME $VERSION
exit $STATE_OK
;;
-V)
print_revision $PROGNAME $VERSION
exit $STATE_OK
;;
--warn)
warn=$2
shift
;;
-w)
warn=$2
shift
;;
--critical)
critical=$2
shift
;;
-c)
critical=$2
shift
;;
--name)
name=$2
shift
;;
-n)
name=$2
shift
;;
--temp_oid)
temp_oid=$2
shift
;;
-o)
temp_oid=$2
shift
;;
--host)
host=$2
shift
;;
-H)
host=$2
shift
;;
-x)
exitstatus=$2
shift
;;
--exitstatus)
exitstatus=$2
shift
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
comm=public
#temp_oid=.1.3.6.1.4.1.5040.1.2.18.1.3.1.1.1
#dl_oid=".1.3.6.1.4.1.17587.2.1.1.19.0"
#dl=" 3,51"
#rdl_oid=".1.3.6.1.4.1.17587.2.1.2.3.0"
# #Laser Name
# laser=`/usr/bin/snmpget -O avq -v 1 -c $comm $host $laser_oid`
temp_str=`/usr/bin/snmpget -O avq -v 1 -c $comm $host $temp_oid`
# #RDL
# rdl=`/usr/bin/snmpget -O avq -v 1 -c $comm $host $rdl_oid`
# echo Ausgabe1 $temp_oid, $temp_str ,$warn, $critical
warn_int=$(echo $warn *10 | /usr/bin/bc -l)
critical_int=$(echo $critical *10 | /usr/bin/bc -l)
temp_int=$(echo $temp_str|/bin/sed 's/,//g'|/bin/sed 's/"//g')
temp_pnp=$(echo $temp_str|/bin/sed 's/ //g'|/bin/sed 's/"//g')
# echo $temp_int
temp_ausg=$(echo "scale=1; $temp_int /10" |/usr/bin/bc -l)
# echo $temp_2
temp_grad=${temp_str:1:4}
#|sed 's/"//g'|sed 's/ //g'
#temp_int=CInt(i)
#temp_int=$temp_str(sed 's/"//g')
#temp_2=0
#temp_2=${temp_str:6:1}
#temp_3=$temp_1.$temp_2
#echo Ausgabe3 $temp_str, $temp_int, $temp_1, $temp_2, $temp_3, $temp
# lt=lower than, le=lower or equal
#temp_int, warn_int und critical_int sind die 10fachen Werte
#temp_ausg = .
#temp_pnp = ,
if [[ $temp_int -ge $critical_int ]]; then
exitstatus=2
echo "Critical - $name $temp_ausg Grad | Temperatur=$temp_ausg;$warn;$critical"
elif [[ $temp_int -ge $warn_int ]]; then
exitstatus=1
echo "WARNING - $name $temp_ausg Grad | Temperatur=$temp_ausg;$warn;$critical"
elif [[ $temp_int -lt $warn_int ]]; then
echo "OK - $name $temp_ausg Grad | Temperatur=$temp_ausg;$warn;$critical"
exitstatus=0
else
exitstatus=3
echo "Unknown - I see dead people - Something is wrong"
fi
#echo $dl,$exitstatus
exit $exitstatus