-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_ricoh_toners
199 lines (184 loc) · 4.76 KB
/
check_ricoh_toners
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#! /bin/bash
#
# Original Script
# Nagios-Plugin zum überprüfen von Verbrauchsmaterialien in HP Druckern
# Last Modified: 20-10-2006
#
# Modified by Lee Kilcullen
# Date: 14-05-2008
# Paths to commands used in this script. These
# may have to be modified to match your system setup.
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 -OM OID-Max -OC OID-Cur -w Warn in % -c Critical in % -t Toner OID -C community string"
echo "Usage: $PROGNAME --help"
echo "Usage: $PROGNAME --version"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "Überprüfe Verbrauchsmaterial von HP-Druckern"
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
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
--version)
print_revision $PROGNAME $VERSION
exit $STATE_OK
;;
-V)
print_revision $PROGNAME $VERSION
exit $STATE_OK
;;
--host)
host=$2
shift
;;
-H)
host=$2
shift
;;
--oidmax)
oidmax=$2
shift
;;
-OM)
oidmax=$2
shift
;;
--oidcur)
oidcur=$2
shift
;;
-OC)
oidcur=$2
shift
;;
-CL)
oidclass=$2
shift
;;
--warn)
warn=$2
shift
;;
-w)
warn=$2
shift
;;
--current)
critical=$2
shift
;;
-c)
critical=$2
shift
;;
-x)
exitstatus=$2
shift
;;
--exitstatus)
exitstatus=$2
shift
;;
-p)
oidpag=$2
shift
;;
-C)
comm=$2
shift
;;
-v)
vendor=$2
shift
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
#get type of class
class=`/usr/bin/snmpget -O Uvqs -v 1 -c $comm $host $oidclass`
#get vendor of toner
ven=`/usr/bin/snmpget -O Uvqs -v 1 -c $comm $host $vendor`
#get current amount of toner
rem=`/usr/bin/snmpget -O Uvbqs -v 1 -c $comm $host $oidcur`
if [[ $class = 3 ]]; then #Toner
if [[ $rem = -1 ]]; then
exitstatus=2
echo "Critical - $ven tauschen | $ven=0%"
elif [[ $rem = 0 ]]; then
exitstatus=2
echo "Critical - $ven tauschen | $ven=0%"
elif [[ $rem = -100 ]]; then
exitstatus=1
echo "WARNING - $ven bestellen | $ven=10%"
elif [[ $rem -gt $warn ]]; then
echo "OK - $ven $rem% | $ven=$rem%"
exitstatus=0
else
exitstatus=3
echo "Class:$class, Wert:$rem, Typ:$ven Unknown - I see dead people - Something is wrong"
fi
elif [[ $class = 4 ]]; then #Resttoner
if [[ $rem = -1 ]]; then
exitstatus=2
echo "Critical - $ven tauschen | $ven=100%"
elif [[ $rem = -100 ]]; then
exitstatus=1
echo "WARNING - $ven bestellen | $ven=90%"
elif [[ $rem -lt 80 ]]; then
echo "OK - $ven $rem% | $ven=$rem%"
exitstatus=0
else
exitstatus=3
echo "Class:$class, Wert:$rem, Typ:$ven Unknown - I see dead people - Something is wrong"
fi
else
exitstatus=3
echo "Class:$class, Wert:$rem, Typ:$ven Unknown - I see dead people - Something is wrong"
fi
# if [[ $rem = -1 ]]; then
# exitstatus=2
# echo "Critical - $ven tauschen"
# elif [[ $rem = -2 ]]; then
# exitstatus=1
# echo "WARNING - $ven bestellen"
# elif [[ $rem = -3 ]]; then
# echo "OK - $ven voll"
# exitstatus=0
# else
# exitstatus=3
# echo "Unknown - I see dead people - Something is wrong"
# fi
exit $exitstatus