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. --- .../66456-nagios-plugins-1.3.1-check-apc-ups.patch | 220 +++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 web/attachments/66456-nagios-plugins-1.3.1-check-apc-ups.patch (limited to 'web/attachments/66456-nagios-plugins-1.3.1-check-apc-ups.patch') diff --git a/web/attachments/66456-nagios-plugins-1.3.1-check-apc-ups.patch b/web/attachments/66456-nagios-plugins-1.3.1-check-apc-ups.patch new file mode 100644 index 0000000..ec5f72b --- /dev/null +++ b/web/attachments/66456-nagios-plugins-1.3.1-check-apc-ups.patch @@ -0,0 +1,220 @@ +diff -ruN nagios-plugins-1.3.1/contrib/check_apc_ups.pl nagios-plugins-1.3.1-new/contrib/check_apc_ups.pl +--- nagios-plugins-1.3.1/contrib/check_apc_ups.pl 2002-08-14 20:02:31.000000000 +0100 ++++ nagios-plugins-1.3.1-new/contrib/check_apc_ups.pl 2003-07-14 18:39:57.000000000 +0100 +@@ -9,11 +9,19 @@ + # remaining: hh:mm:ss" if all is well, and a list of specific problems + # if something is broken. + ++BEGIN { ++ if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { ++ $runtimedir = $1; ++ $PROGNAME = $2; ++ } ++} ++ ++require 5.004; ++use POSIX; + use strict; + use Getopt::Long; +-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; ++use vars qw($opt_V $opt_h $opt_H $opt_T $opt_t $opt_R $opt_r $opt_L $opt_l $community $PROGNAME); ++use lib $main::runtimedir; + use utils qw(%ERRORS &print_revision &support &usage); + + sub print_help (); +@@ -24,18 +32,24 @@ + $ENV{'PATH'}=''; + $ENV{'BASH_ENV'}=''; + $ENV{'ENV'}=''; ++$ENV{'CDPATH'}=''; + +-Getopt::Long::Configure('bundling'); ++my $verbose = 0; ++$community="public"; ++ ++Getopt::Long::Configure('no_ignore_case'); + GetOptions +- ("V" => \$opt_V, "version" => \$opt_V, +- "h" => \$opt_h, "help" => \$opt_h, +- "T=s" => \$opt_T, "temp-critical" => \$opt_T, +- "t=s" => \$opt_t, "temp-warning" => \$opt_t, +- "R=s" => \$opt_R, "runtime-critical" => \$opt_R, +- "r=s" => \$opt_r, "runtime-warning" => \$opt_r, +- "L=s" => \$opt_L, "load-critical" => \$opt_L, +- "l=s" => \$opt_l, "load-warning" => \$opt_l, +- "H=s" => \$opt_H, "hostname=s" => \$opt_H); ++ ("V|version" => \$opt_V, ++ "h|help" => \$opt_h, ++ "T|temp-critical:i" => \$opt_T, ++ "t|temp-warning:i" => \$opt_t, ++ "R|runtime-critical:i" => \$opt_R, ++ "r|runtime-warning:i" => \$opt_r, ++ "L|load-critical:i" => \$opt_L, ++ "l|load-warning:i" => \$opt_l, ++ "H|hostname=s" => \$opt_H, ++ "C|community=s" => \$community, ++ "v|verbose:+" => \$verbose); + + if ($opt_V) { + print_revision($PROGNAME,'$Revision: 1.2 $'); +@@ -51,7 +65,7 @@ + # Defaults + + $opt_R *= 60 * 100 if (defined $opt_R); # Convert minutes to secs/100 +-$opt_r *= 60 * 100 if (defined $opt_R); ++$opt_r *= 60 * 100 if (defined $opt_r); + + my $tempcrit = $opt_T || 60; + my $tempwarn = $opt_t || 40; +@@ -140,7 +154,8 @@ + [ "testInProgress", $ERRORS{'OK'} ], # 4 + ); + +-my $exitval = $ERRORS{'UNKNOWN'}; ++my $sep = ", "; ++my $exitval = $ERRORS{'OK'}; + my $data; + my $onbattery = 3; + +@@ -148,10 +163,10 @@ + + print "Output status: "; + if (defined ($data) && defined ($outputStatVals[$data][0])) { +- print "$outputStatVals[$data][0] | "; ++ print "$outputStatVals[$data][0]$sep"; + escalate_exitval($outputStatVals[$data][1]); + } else { +- print "unknown | "; ++ print "unknown$sep"; + } + + $data = get_snmp_int_val( $upsAdvBatteryRunTimeRemaining ); +@@ -161,7 +176,7 @@ + my $hrs = int($data / (60 * 60 * 100)); # Data is hundredths of a second + my $mins = int($data / (60 * 100)) % 60; + my $secs = ($data % 100) / 100; +- printf "%d:%02d:%05.2f | ", $hrs, $mins, $secs; ++ printf "%d:%02d:%05.2f$sep", $hrs, $mins, $secs; + if ($data <= $runtimecrit) { + escalate_exitval($ERRORS{'CRITICAL'}); + } elsif ($data <= $runtimewarn) { +@@ -170,7 +185,7 @@ + escalate_exitval($ERRORS{'OK'}); + } + } else { +- print "unknown | "; ++ print "unknown$sep"; + } + + $data = get_snmp_int_val( $upsBasicBatteryStatus ); +@@ -181,20 +196,20 @@ + my $fc = get_snmp_int_val( $upsAdvInputLineFailCause ); + if ($data == $onbattery) { + if (defined ($failCauseVals[$fc])) { $failcause = $failCauseVals[$fc]; } +- print "$battStatVals[$data][0] ($failcause) | "; ++ print "$battStatVals[$data][0] ($failcause)$sep"; + } else { +- print "$battStatVals[$data][0] | "; ++ print "$battStatVals[$data][0]$sep"; + } + escalate_exitval($battStatVals[$data][1]); + } else { +- print "unknown | "; ++ print "unknown$sep"; + } + + $data = get_snmp_int_val( $upsAdvBatteryTemperature ); + + print "Battery temp(C): "; + if (defined ($data)) { +- print "$data | "; ++ print "$data$sep"; + if ($data >= $tempcrit) { + escalate_exitval($ERRORS{'CRITICAL'}); + } elsif ($data >= $tempwarn) { +@@ -203,24 +218,24 @@ + escalate_exitval($ERRORS{'OK'}); + } + } else { +- print "unknown | "; ++ print "unknown$sep"; + } + + $data = get_snmp_int_val( $upsAdvBatteryReplaceIndicator ); + + print "Battery repl: "; + if (defined ($data) && defined ($battReplVals[$data][0])) { +- print "$battReplVals[$data][0] | "; ++ print "$battReplVals[$data][0]$sep"; + escalate_exitval($battReplVals[$data][1]); + } else { +- print "unknown | "; ++ print "unknown$sep"; + } + + $data = get_snmp_int_val( $upsAdvOutputLoad ); + + print "Output load (%): "; + if (defined ($data)) { +- print "$data | "; ++ print "$data$sep"; + if ($data >= $loadcrit) { + escalate_exitval($ERRORS{'CRITICAL'}); + } elsif ($data >= $loadwarn) { +@@ -229,19 +244,25 @@ + escalate_exitval($ERRORS{'OK'}); + } + } else { +- print "unknown | "; ++ print "unknown$sep"; + } + + $data = get_snmp_int_val( $upsAdvTestDiagnosticsResults ); + + print "Diag result: "; + if (defined ($data) && defined ($diagnosticsResultsVals[$data][0])) { +- print "$diagnosticsResultsVals[$data][0]\n"; ++ print "$diagnosticsResultsVals[$data][0]$sep"; + escalate_exitval($diagnosticsResultsVals[$data][1]); + } else { +- print "unknown\n"; ++ print "unknown$sep"; + } + ++foreach my $key (keys %ERRORS) { ++ if ($ERRORS{$key} == $exitval) { ++ print "Status $key\n"; ++ last; ++ } ++} + + exit $exitval; + +@@ -263,6 +284,8 @@ + print " + -H, --hostname=HOST + Name or IP address of host to check ++-C, --community=string ++ Community string to use to query UPS (default: public) + -T --temp-critical + Battery degrees C above which a CRITICAL status will result (default: 60) + -t --temp-warning +@@ -284,7 +307,7 @@ + my $val=0; + my $oid = shift(@_); + +- $val = `/usr/bin/snmpget $host public $oid 2> /dev/null`; ++ $val = `/usr/bin/snmpget -v 1 -c $community $host $oid 2> /dev/null`; + my @test = split(/ /,$val,3); + + return undef unless (defined ($test[2])); +@@ -297,6 +320,7 @@ + $val = $test[2]; + } + ++ chomp($val); + return $val; + } + -- cgit v1.2.3-74-g34f1