Home Directory

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Directory

RadoS

Reviews(1)
byRadoS, February 5, 2015
0 of 1 people found this review helpful
I use the ups_acp.pl Script.
a) it provides some useful info, thanks
b) some parts may be incorrect (don't know enough about SNMP/UPS-APC, guessing from code where it checks the same SNMP value twice)
c) code fails to operate with embedded perl when enabled in nagios (which is by default on ubuntu 14/04)

I changed quite a bit for what I think is correct for b) and definitely is necessary for c).
If I did wrong, then correct my corrections as needed. ;-)
Enjoy

======

*** check_ups_apc.pl 2014-03-20 16:58:31.000000000 +0100
--- jjj.pl 2015-02-02 18:34:43.000000000 +0100
***************
*** 39,99 ****
# After: CRIT - Smart-UPS RT 10000 XL - CRIT BATTERY CAPACITY 50% - STATUS NORMAL - OUTPUT LOAD 31% - TEMPERATURE 23 C
# - Added multiline output for firmware,manufacture date and serial number

use Net::SNMP;
use Getopt::Std;
# DEBUGGING PURPOSE
use Data::Dumper;

! $script = "check_ups_apc.pl";
! $script_version = "1.2";

! $metric = 1;

! $version = "1"; # SNMP version
! $timeout = 2; # SNMP query timeout
# $warning = 100;
# $critical = 150;
! $status = 0;
! $returnstring = "";
! $perfdata = "";
!
! $community = "public"; # Default community string
!
! $oid_sysDescr = ".1.3.6.1.2.1.1.1.0";
! $oid_serial_number = ".1.3.6.1.4.1.318.1.1.1.1.2.3.0";
! $oid_firmware = ".1.3.6.1.4.1.318.1.1.1.1.2.1.0";
! $oid_manufacture_date = ".1.3.6.1.4.1.318.1.1.1.1.2.2.0";
! $oid_upstype = ".1.3.6.1.4.1.318.1.1.1.1.1.1.0";
! $oid_battery_capacity = ".1.3.6.1.4.1.318.1.1.1.2.2.1.0";
! $oid_output_status = ".1.3.6.1.4.1.318.1.1.1.4.1.1.0";
! $oid_output_current = ".1.3.6.1.4.1.318.1.1.1.4.2.4.0";
! $oid_output_load = ".1.3.6.1.4.1.318.1.1.1.4.2.3.0";
! $oid_battemperature = ".1.3.6.1.4.1.318.1.1.1.2.2.2.0";
! $oid_exttemperature = ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1";
! $oid_remaining_time = ".1.3.6.1.4.1.318.1.1.1.2.2.3.0";
# optional, Smart-UPS 2200 support this
! $oid_current_load_wh = ".1.3.6.1.4.1.318.1.1.1.4.3.6.0";

! $oid_battery_replacment = ".1.3.6.1.4.1.318.1.1.1.2.2.4.0";

! $upstype = "";
! $battery_capacity = 0;
! $output_status = 0;
! $output_current = 0;
! $output_load = 0;
! $battemperature = 0;
! $exttemperature = 0;
# crit / warn values ! $remaining_time_crit = 5;
! $output_load_crit = 80; ! $output_load_warn = 70;
! $battemperature_crit = 33; ! $battemperature_warn = 31;
! $exttemperature_crit = 30;
! $exttemperature_warn = 26; ! $battery_capacity_crit = 35;
! $battery_capacity_warn = 65;
# Do we have enough information? if (@ARGV var_bind_names()) {
***************
*** 233,249 ****
--- 243,262 ----
}
}

+ my $firmware;
# some useful stuff
if (defined($s->get_request($oid_firmware))) {
foreach ($s->var_bind_names()) {
$firmware = $s->var_bind_list()->{$_};
}
}
+ my $serial_number;
if ( defined ( $s->get_request($oid_serial_number))) {
foreach ($s->var_bind_names()) {
$serial_number = $s->var_bind_list()->{$_};
}
}
+ my $manufacture_date;
if ( defined ( $s->get_request($oid_manufacture_date))) {
foreach ($s->var_bind_names()) {
$manufacture_date = $s->var_bind_list()->{$_};
***************
*** 279,285 ****
#######################################################

if (!defined($s->get_request($oid_battery_replacment))) {
! if (!defined($s->get_request($oid_battery_replacement))) {
$returnstring = "SNMP agent not responding";
$status = 1;
return 1;
--- 292,298 ----
#######################################################

if (!defined($s->get_request($oid_battery_replacment))) {
! if (!defined($s->get_request($oid_sysDescr))) {
$returnstring = "SNMP agent not responding";
$status = 1;
return 1;
***************
*** 290,295 ****
--- 303,309 ----
return 1;
}
}
+ my $battery_replacement;
foreach ($s->var_bind_names()) {
$battery_replacement = $s->var_bind_list()->{$_};
}
***************
*** 308,313 ****
--- 322,328 ----
return 1;
}
}
+ my $remaining_time;
foreach ($s->var_bind_names()) {
$remaining_time = $s->var_bind_list()->{$_}; # returns (days),(hours),(minutes),seconds
}
***************
*** 453,469 ****
if ( defined ( $remaining_time ) ) {
# convert time to minutes
my @a = split(/ /,$remaining_time);
! my $timeUnit = @a[1];
my $minutes = 0;

if ( $timeUnit =~ /hour/ ) {
# hours returned
! my @minutesArray = split(/:/,@a[2]);
! $minutes = @a[0] * 60;
! $minutes = $minutes + @minutesArray[0];
} elsif ( $timeUnit =~ /minute/ ) {
# minutes returned
! $minutes = @a[0];
} else {
# seconds returned?
$minutes = 0;
--- 468,484 ----
if ( defined ( $remaining_time ) ) {
# convert time to minutes
my @a = split(/ /,$remaining_time);
! my $timeUnit = $a[1];
my $minutes = 0;

if ( $timeUnit =~ /hour/ ) {
# hours returned
! my @minutesArray = split(/:/,$a[2]);
! $minutes = $a[0] * 60;
! $minutes = $minutes + $minutesArray[0];
} elsif ( $timeUnit =~ /minute/ ) {
# minutes returned
! $minutes = $a[0];
} else {
# seconds returned?
$minutes = 0;