summaryrefslogtreecommitdiffstats
path: root/web/attachments/149868-nagiosplug-check_snmp_mgeups.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/149868-nagiosplug-check_snmp_mgeups.patch')
-rw-r--r--web/attachments/149868-nagiosplug-check_snmp_mgeups.patch301
1 files changed, 301 insertions, 0 deletions
diff --git a/web/attachments/149868-nagiosplug-check_snmp_mgeups.patch b/web/attachments/149868-nagiosplug-check_snmp_mgeups.patch
new file mode 100644
index 0000000..c06bce7
--- /dev/null
+++ b/web/attachments/149868-nagiosplug-check_snmp_mgeups.patch
@@ -0,0 +1,301 @@
1diff -Nru nagiosplug/plugins-scripts/check_snmp_mgeups.pl nagiosplug-check_snmp_mgeups/plugins-scripts/check_snmp_mgeups.pl
2--- nagiosplug/plugins-scripts/check_snmp_mgeups.pl 1970-01-01 01:00:00.000000000 +0100
3+++ nagiosplug-check_snmp_mgeups/plugins-scripts/check_snmp_mgeups.pl 2005-09-21 13:51:12.000000000 +0200
4@@ -0,0 +1,271 @@
5+#!/usr/bin/perl
6+
7+#-----------------------------------------------------------------
8+#Copyright 2005 Ignacio Barrientos <chipi@criptonita.com>
9+#
10+#This perl script query an UM_LINK unit via SNMP and grab some
11+#useful information applied to determine the status of the UPS
12+#to send it to Nagios.
13+#
14+#Thanks to José Beites, who gave me access to a MGE COMET S31 UPS
15+#and UM-LINK unit.
16+#
17+#Thanks to check_snmp_apcups.pl
18+#
19+#This program is free software; you can redistribute it or modify
20+#it under the terms of the GNU General Public License
21+#-----------------------------------------------------------------
22+
23+# READ CAREFULLY BEFORE USE THIS SCRIPT:
24+#
25+# Please execute the script before use it with Nagios to test
26+# if the oid's are OK, a message will be printed if there are
27+# some problems with the oid's configuration.
28+#
29+# Thank you.
30+
31+
32+use Net::SNMP;
33+use Getopt::Std;
34+
35+$script_name = "check_snmp_mgeups";
36+$script_version = "0.1";
37+
38+## CONNECTION STUFF ##
39+$ipaddress = ""; # there is not default ip address, sorry
40+$version = 1; # SNMP version, old UM_LINK hw works with version 1!!.
41+$timeout = 2; # SNMP query timeout
42+$defaultcommunity = "public"; # Default community string
43+
44+$warn_batt_level = 20; # battery level (%) that set a WARNING status.
45+$crit_batt_level = 10; # battery level (%) that set a CRITICAL status.
46+$warn_temp = 30; # temperature (degrees) that set a WARNING status.
47+$warn_overload = 70; # output overload (%) that set WARNING status.
48+
49+##################################################
50+## ##
51+## DONT CHANGE NOTHING UNDER THIS LINE ##
52+## ##
53+##################################################
54+
55+## INTERESTING DEFINES ##
56+my $OK = 0;
57+my $WARNING = 1;
58+my $CRITICAL = 2;
59+
60+## RETURN INFO VARIABLES ##
61+$status = $OK;
62+$returnstring = "";
63+
64+## OID LIST ##
65+$oid_ups_model = ".1.3.6.1.4.1.705.1.1.1.0";
66+
67+$oid_internal_temp = ".1.3.6.1.4.1.705.1.5.7.0"; # degrees
68+
69+$oid_battery_porcentage = ".1.3.6.1.4.1.705.1.5.2.0";
70+$oid_battery_fault = ".1.3.6.1.4.1.705.1.5.9.0"; # 1 yes, 2 no
71+
72+$oid_input_outage = ".1.3.6.1.4.1.705.1.6.4.0"; # 1: ok, 2: voltage out tolerance, 3: freq out tolerance, 4: no voltage.
73+
74+$oid_output_overload = ".1.3.6.1.4.1.705.1.7.2.1.4.1"; # %
75+$oid_output_on_bypass = ".1.3.6.1.4.1.705.1.7.3.0"; # 1: yes, 2: no
76+
77+## NOT USED ##
78+# $oid_battery_voltage = ".1.3.6.1.4.1.705.1.5.5.0"; # dV
79+# $oid_input_voltage = ".1.3.6.1.4.1.705.1.6.2.1.2.1"; # dV
80+# $oid_output_voltage = ".1.3.6.1.4.1.705.1.7.2.1.2.1"; # dV
81+
82+$oid_generic = $oid_ups_model;
83+
84+## PERSONALIZED DATA VARIABLES ##
85+$temp = 0;
86+
87+$batt_level = 0;
88+$batt_fault = 0;
89+
90+$in_outage = 0;
91+
92+$out_overload = 0;
93+$out_bypass = 0;
94+
95+## FETCHING ARGS STUFF ##
96+if (@ARGV < 1) {
97+ print "\nERROR: Too few arguments\n";
98+ usage();
99+}
100+
101+getopts("h:H:C:w:c:");
102+
103+if ($opt_h)
104+{
105+ usage();
106+ exit(0);
107+}
108+
109+$ipaddress = $opt_H;
110+
111+if ($opt_C)
112+{
113+ $defaultcommunity = $opt_C;
114+}
115+
116+## MAKING SNMP CONNECTION ##
117+my ($s, $e) = Net::SNMP->session(
118+ -community => $defaultcommunity,
119+ -hostname => $ipaddress,
120+ -version => $version,
121+ -timeout => $timeout,
122+);
123+
124+## TESTING SNMP CONNECTION WITH A GENERIC QUERY ##
125+if (!defined($s->get_request($oid_generic)))
126+{
127+ $returnstring = "SNMP server not responding, host down?";
128+ $status = $CRITICAL;
129+}
130+else
131+{
132+ ## DOING ALL WORK ##
133+ main();
134+}
135+
136+## CONNECTION TO /DEV/NULL ##
137+$s->close();
138+
139+## STUDYING THE OUTPUT ##
140+if ($status == $OK)
141+{
142+ $returnstring = "- No problems.";
143+ print "Status is OK $returnstring\n";
144+}
145+elsif ($status == $WARNING)
146+{
147+ print "Status is a WARNING level $returnstring\n";
148+}
149+elsif ($status == $CRITICAL)
150+{
151+ print "Status is CRITICAL $returnstring\n";
152+}
153+
154+## GOOD BYE ##
155+exit $status;
156+
157+##
158+## getinfo: make a snmp query with OID (arg0) and put it in arg1.
159+
160+sub getinfo
161+{
162+ if(!defined($s->get_request(@_[0])))
163+ {
164+ print "OID ";
165+ print @_[0];
166+ print " not exists, and can't be checked, skipping\n";
167+ $_[1] = undef;
168+ return;
169+ }
170+
171+ foreach ($s->var_bind_names()) {
172+ $_[1] = $s->var_bind_list()->{$_};
173+ }
174+}
175+
176+##
177+## main: all queries and sets
178+
179+sub main
180+{
181+
182+ ## GETTING DATA ##
183+
184+ getinfo($oid_internal_temp,$temp);
185+ getinfo($oid_battery_porcentage,$batt_level);
186+ getinfo($oid_battery_fault,$batt_fault);
187+ getinfo($oid_input_outage,$in_outage);
188+ getinfo($oid_output_overload,$out_overload);
189+ getinfo($oid_output_on_bypass,$out_bypass);
190+
191+ ## STUDYING STATUS LEVEL LOOKING SOME ISSUES ##
192+
193+ ## THINGS CAN CHANGE STATUS TO: WARNING ##
194+
195+ if( defined($batt_level) && ($batt_level < $warn_batt_level) )
196+ {
197+ $status = $WARNING;
198+ $returnstring = " - Battery level is under ";
199+ $returnstring = "$returnstring$warn_batt_level";
200+ $returnstring = "$returnstring%.";
201+ }
202+
203+ if( defined($temp) && ($temp > $warn_temp) )
204+ {
205+ $status = $WARNING;
206+ $returnstring = "$returnstring - Max temperature exceeded";
207+ }
208+
209+ if( defined($out_overload) && ($out_overload > $warn_overload) )
210+ {
211+ $status = $WARNING;
212+ $returnstring = "$returnstring - Output overloaded";
213+ }
214+
215+ ## THINGS CAN CHANGE STATUS TO: CRITICAL ##
216+
217+ if( defined($batt_level) && ($batt_level < $crit_batt_level) )
218+ {
219+ $status = $CRITICAL;
220+ $returnstring = " - Battery level is under ";
221+ $returnstring = "$returnstring$crit_batt_level";
222+ $returnstring = "$returnstring%.";
223+ }
224+
225+ if( defined($batt_fault) && ($batt_fault eq 1) )
226+ {
227+ $status = $CRITICAL;
228+ $returnstring = "$returnstring - Battery fail";
229+ }
230+
231+ if( defined($in_outage) && (! $in_outage eq 1) )
232+ {
233+ $status = $CRITICAL;
234+ $returnstring = "$returnstring - AC input fail";
235+ }
236+
237+ if( defined($out_bypass) && ($out_bypass eq 1) )
238+ {
239+ $status = $CRITICAL;
240+ $returnstring = "$returnstring - System in BY PASS mode";
241+ }
242+
243+}
244+
245+##
246+## usage: self explaining
247+
248+sub usage {
249+ print << "USAGE";
250+
251+-----------------------------------------------------------------
252+$script_name v$script_version
253+
254+Monitors MGE UPS via SNMP v1.
255+
256+Usage: $script_name -H <hostname> [-C <community>]
257+
258+Options: -H Hostname or IP address
259+ -C Community (default is public)
260+
261+-----------------------------------------------------------------
262+Copyright 2005 Ignacio Barrientos <chipi\@criptonita.com>
263+
264+Thanks to José Beites, who gave me access to a MGE COMET S31 UPS
265+and UM-LINK unit.
266+
267+Thanks to check_snmp_apcups.pl
268+
269+This program is free software; you can redistribute it or modify
270+it under the terms of the GNU General Public License
271+-----------------------------------------------------------------
272+
273+USAGE
274+ exit 1;
275+}
276diff -Nru nagiosplug/plugins-scripts/Makefile.am nagiosplug-check_snmp_mgeups/plugins-scripts/Makefile.am
277--- nagiosplug/plugins-scripts/Makefile.am 2003-07-02 17:01:22.000000000 +0200
278+++ nagiosplug-check_snmp_mgeups/plugins-scripts/Makefile.am 2005-09-21 13:56:57.000000000 +0200
279@@ -7,12 +7,12 @@
280 libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \
281 check_log check_ntp check_oracle check_rpc check_sensors check_wave \
282 check_ifstatus check_ifoperstatus check_mailq check_file_age \
283- utils.sh utils.pm
284+ check_snmp_mgeups utils.sh utils.pm
285
286 EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \
287 check_log.sh check_ntp.pl check_oracle.sh check_rpc.pl check_sensors.sh \
288 check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \
289- utils.sh.in utils.pm.in t
290+ check_snmp_mgeups.pl utils.sh.in utils.pm.in t
291
292 TESTS_ENVIRONMENT=perl -I $(top_builddir) -I $(top_srcdir)
293
294diff -Nru nagiosplug/THANKS.in nagiosplug-check_snmp_mgeups/THANKS.in
295--- nagiosplug/THANKS.in 2005-09-19 12:58:24.000000000 +0200
296+++ nagiosplug-check_snmp_mgeups/THANKS.in 2005-09-21 13:55:43.000000000 +0200
297@@ -166,3 +166,4 @@
298 Sascha Runschke
299 Ronald Tin
300 Chester Hosey
301+Ignacio Barrientos