From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/61644-check_apc_ups.pl.diff | 141 ++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 web/attachments/61644-check_apc_ups.pl.diff (limited to 'web/attachments/61644-check_apc_ups.pl.diff') diff --git a/web/attachments/61644-check_apc_ups.pl.diff b/web/attachments/61644-check_apc_ups.pl.diff new file mode 100644 index 0000000..3ea9a1c --- /dev/null +++ b/web/attachments/61644-check_apc_ups.pl.diff @@ -0,0 +1,141 @@ +298a +# 802 END INS +# 802 BEG DEL +# $val = `/usr/bin/snmpget $host public $oid 2> /dev/null`; +# my @test = split(/ /,$val,3); +# +# return undef unless (defined ($test[2])); +# +# if ($test[2] =~ /\(\d+\)/) { # Later versions of UCD SNMP +# ($val) = ($test[2] =~ /\((\d+)\)/); +# } elsif ($test[2] =~ /: \d+/) { +# ($val) = ($test[2] =~ /: (\d+)/); +# } else { +# $val = $test[2]; +# } +# 802 END DEL +. +297c + $val = undef; +. +286,295c +# 802 BEGIN INS + my $community="public"; + my $port="161"; + my ($session, $error) = Net::SNMP->session( + -hostname => $host, + -community => $community, + -timeout => 2, + -port => $port, + -translate => undef + ); + if (defined($session)) { + my $response=$session->get_request($oid); + if (defined($response)) { + $val=$response->{$oid}; + } else { + $val = undef; + } + $session->close; +. +277c + Output load pct above which a WARNING status will result (default: 50) +. +275c + Output load pct above which a CRITICAL status will result (default: 85) +. +242c + print "unknown\]\n"; +. +239c + print "$diagnosticsResultsVals[$data][0]\]\n"; +. +237c +print "\[Diag result: "; +. +232c + print "unknown\]"; +. +223c + print "$data\]"; +. +221c +print "\[Output load (%): "; +. +216c + print "unknown\]"; +. +213c + print "$battReplVals[$data][0]\]"; +. +211c +print "\[Battery repl: "; +. +206c + print "unknown\] "; +. +197c + print "$data\]"; +. +195c +print "\[Battery temp(C): "; +. +190c + print "unknown\]"; +. +186c + print "$battStatVals[$data][0]\]"; +. +184c + print "$battStatVals[$data][0] ($failcause)\]"; +. +178c +print "\[Battery status: "; +. +173c + print "unknown\]"; +. +164c + printf "%d:%02d:%05.2f\]", $hrs, $mins, $secs; +. +159c +print "\[Rem time: "; +. +154c + print "unknown\]"; +. +151c + print "$outputStatVals[$data][0]\]"; +. +149c +print "\[Output status: "; +. +143c +my $exitval = $ERRORS{'OK'}; +. +27a +# 801 ADD ONE +{ $^W=0; ($PROGNAME=$0) =~ s!^.*/!!; } + +. +14,16c +# 802 ADD ONE +use Net::SNMP; +use vars qw($opt_V $opt_h $opt_H $opt_T $opt_t $opt_R + $opt_r $opt_L $opt_l $PROGNAME); +#use lib utils.pm; +# 801 CHANGE ONE +use lib '/usr/local/nagios/libexec'; +. +11c +# +# DMH Custom +# 801 07-07-2003 Fix use lib statement +# Fix PROGNAME Assignment +# 802 07-07-2003 Use Net::SNMP to get the info instead of calling +# an external program. +# 803 09-11-2003 Replaced the output delimiter | with [] as +# Nagios was truncating the output and only +# displaying the first check's data. +# +. -- cgit v1.2.3-74-g34f1