BB Unix Network Monitor - Message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: {bb} bb-xsnmp-1.77.patch1.txt - APC UPS



Hey Everyone,

For those who are interested, here's Craig's patch in GNU patch format.

Just save the text between the "*** start/end ***" markers to a file
(eg. filename.patch), and do the usual "patch -p1 < filename.patch"
while in the same directory as the script (to be patched).

*** Start of patch ***
diff -Naur bb-xsnmp-1.77/bb-xsnmp.pl bb-xsnmp-1.77pl1/bb-xsnmp.pl
--- bb-xsnmp-1.77/bb-xsnmp.pl   2004-03-28 22:40:32.000000000 -1000
+++ bb-xsnmp-1.77pl1/bb-xsnmp.pl        2005-02-04 10:53:41.307727000
-1000
@@ -2691,16 +2691,16 @@
     }

     # Digest results
-    my $model = $result->{'upsBasicIdentModel'};
+    my $model = $result->{$snmpoids{'upsBasicIdentModel'}};
     my $battstatus =
$snmpsyntaxdb{'upsBasicBatteryStatus'}{$result->{$snmpoids{'upsBasicBatt
eryStatus'}}};
     my $outstatus =
$snmpsyntaxdb{'upsBasicOutputStatus'}{$result->{$snmpoids{'upsBasicOutpu
tStatus'}}};
-    my $capacity = $result->{'upsAdvBatteryCapacity'};
-    my $remain = $result->{'upsAdvBatteryRunTimeRemaining'} / 100; #
Seconds
+    my $capacity = $result->{$snmpoids{'upsAdvBatteryCapacity'}};
+    my $remain = $result->{$snmpoids{'upsAdvBatteryRunTimeRemaining'}}
/ 100; # Seconds
     my $replace =
$snmpsyntaxdb{'upsAdvBatteryReplaceIndicator'}{$result->{$snmpoids{'upsA
dvBatteryReplaceIndicator'}}};
-    my $inputvoltage = $result->{'upsAdvInputLineVoltage'};
-    my $outputload = $result->{'upsAdvOutputLoad'};
-    my $outputvoltage = $result->{'upsAdvOutputVoltage'};
-    my $replacedate = $result->{'upsBasicBatteryLastReplaceDate'};
+    my $inputvoltage = $result->{$snmpoids{'upsAdvInputLineVoltage'}};
+    my $outputload = $result->{$snmpoids{'upsAdvOutputLoad'}};
+    my $outputvoltage = $result->{$snmpoids{'upsAdvOutputVoltage'}};
+    my $replacedate =
$result->{$snmpoids{'upsBasicBatteryLastReplaceDate'}};

     # Determine state
     my $worstcolor = 'green';
@@ -2708,6 +2708,20 @@
       $worstcolor = 'red';
       $message .= "Battery time remaining low.\n";
     }
+    if ($capacity < 50) {
+      $worstcolor = 'red';
+      $message .= "Battery capacity is less than 50%.\n";
+    } elsif ($capacity < 75) {
+      $worstcolor = ($worstcolor eq 'green') ? 'yellow' : $worstcolor;
+      $message .= "Battery capacity is less than 75%.\n";
+    }
+    if ($remain < 900) {
+      $worstcolor = 'red';
+      $message .= "Battery capacity is less than 900 seconds.\n";
+    } elsif ($remain < 1800) {
+      $worstcolor = ($worstcolor eq 'green') ? 'yellow' : $worstcolor;
+      $message .= "Battery capacity is less than 1800 seconds.\n";
+    }
     if ($replace eq 'batteryNeedsReplacing') {
       $worstcolor = 'red';
       $message .= "Battery needs replacing.\n";
@@ -2715,10 +2729,10 @@
     # upsAdvOutputLoad, say yellow for 90 and red for 95.
     if ($outputload > 95) {
       $worstcolor = 'red';
-      $message .= "Output load above 95 percent.\n";
+      $message .= "Output load is above 95 percent.\n";
     } elsif ($outputload > 90) {
       $worstcolor = ($worstcolor eq 'green') ? 'yellow' : $worstcolor;
-      $message .= "Output load above 90 percent.\n";
+      $message .= "Output load is above 90 percent.\n";
     }

     # Collect the following if currently on battery power.
@@ -2737,6 +2751,7 @@
       my $timeonbatt = $result->{'upsBasicBatteryTimeOnBattery'} / 100;
# Seconds
       $message .= "Reason for input line failure: $failcause\n";
       $message .= "Time elapsed since switching to battery: $timeonbatt
seconds\n";
+      $worstcolor = ($worstcolor eq 'green') ? 'yellow' : $worstcolor;
     }

     # Compose remainder of message.
@@ -2747,9 +2762,9 @@
     $message .= "Remaining Battery Capacity: $capacity\n";
     $message .= "Time Remaining Before Battery Exhaustion: $remain
seconds\n";
     $message .= "Battery Replacement Indicator: $replace\n";
-    $message .= "Input Voltage: $replace\n";
+    $message .= "Input Voltage: $inputvoltage\n";
     $message .= "UPS Load: $outputload %\n";
-    $message .= "Output Voltage: $outputvoltage %\n";
+    $message .= "Output Voltage: $outputvoltage\n";
     $message .= "Date Batteries Last Replaced: $replacedate\n";

     $message = "status $commahost.$test $worstcolor
".scalar(localtime)."\n\n$message";
*** End of patch ***

Lowell

-----Original Message-----
From: owner-bb@bb4.com [mailto:owner-bb@bb4.com] On Behalf Of Craig Cook
Sent: Wednesday, February 02, 2005 3:53 AM
To: bb@bb4.com
Subject: {bb} bb-xsnmp-1.77.patch1.txt - APC UPS


I have posted this patch to deadcat to correct (& enhance) APC
monitoring.

I saw questions in the archives about it, but no one has posted any
fixes.

Craig Cook
--
Big Brother Consulting and Training Services www.cookitservices.com

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=
To unsubscribe from this list, or to subscribe to the bb-digest list
send e-mail to mailto:majordomo@bb4.com with unsubscribe bb -and/or-
subscribe bb-digest in the BODY of the message.

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=
To unsubscribe from this list, or to subscribe to the bb-digest list
send e-mail to mailto:majordomo@bb4.com with unsubscribe bb -and/or-
subscribe bb-digest in the BODY of the message.


Home | Main Index | Thread Index