Page 4 of 6

Re: UPS battery lifetime alert

Posted: Fri Nov 04, 2016 2:31 pm
by tgrtjake
If you don't want to use run time you could use battery capacity remaining in percentage. I use this instead of run time as that fluctuates based on connected devices being powered on and off.

upsAdvBatteryCapacity .1.3.6.1.4.1.318.1.1.1.2.2.1.0

Re: UPS battery lifetime alert

Posted: Fri Nov 04, 2016 2:44 pm
by sa77if
tgrtjake wrote:If you don't want to use run time you could use battery capacity remaining in percentage. I use this instead of run time as that fluctuates based on connected devices being powered on and off.

upsAdvBatteryCapacity .1.3.6.1.4.1.318.1.1.1.2.2.1.0

thanks

Re: UPS battery lifetime alert

Posted: Fri Nov 04, 2016 3:07 pm
by sa77if
tgrtjake wrote:
sa77if wrote:so its not the battery lifetime that warn for replacing
its the one that warn for remaining charge
ok, how can raise the values to reduce warnings like that, because i am on AC its not important to have 10m or 5m
Yes, you'll need to change the -c and -w to something like this. Also, if I were you I'd change the name to Battery RunTime.

I think with your current setup being 10 min run time you would maybe want to warn at 5 mins and crit at 3 mins? 6000 = 1 min

Code: Select all

# 'snmp_ups_stat' command definition
define command{
        command_name    snmp_ups_stat
        command_line    $USER1$/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.318.1.1.1.2.2.3.0 -w 30000 -c 18000 -l 'Battery RunTime'
        }
Sorry, edits for correct timings

so
i changed that

###############################################################################
40 #
41 # UPS SNMP COMMANDS
42 #
43 ################################################################################
44 # 'snmp_ups_stat' command definition
45 define command{
46 command_name snmp_ups_stat
47
48 command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.318.1.1.1.2.2.3.0 -w 30000 -c 18000 -l 'Battery RunTime'
49 }
50
51 # 'snmp_ups_load' command definition
52 define command{
53 command_name snmp_ups_load
54
55 command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.318.1.1.1.4.2.3.0 -w 75 -c 90 -l 'Output Load' -u '%'
56 }


and still getting this

***** Nagios *****

Notification Type: PROBLEM

Service: Check UPS Battery LifeTime
Host: SmartUPS 2200B
Address: 192.168.0.7
State: CRITICAL

Date/Time: Fri Nov 4 13:04:40 PDT 2016

Additional Info:

SNMP CRITICAL - Battery RunTime *60000*


please help

Re: UPS battery lifetime alert

Posted: Mon Nov 07, 2016 10:09 am
by avandemore
48 command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.318.1.1.1.2.2.3.0 -w 30000 -c 18000 -l 'Battery RunTime'
You've instructed Nagios to go critical if it gets a value <= 18000. You're getting a value > 18000 hence the critical. Also I'm not sure having a warning value less than a critical value is what you want.

Re: UPS battery lifetime alert

Posted: Tue Nov 08, 2016 9:38 am
by tgrtjake
sa77if wrote:
so
i changed that

###############################################################################
40 #
41 # UPS SNMP COMMANDS
42 #
43 ################################################################################
44 # 'snmp_ups_stat' command definition
45 define command{
46 command_name snmp_ups_stat
47
48 command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.318.1.1.1.2.2.3.0 -w 30000 -c 18000 -l 'Battery RunTime'
49 }
50
51 # 'snmp_ups_load' command definition
52 define command{
53 command_name snmp_ups_load
54
55 command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.318.1.1.1.4.2.3.0 -w 75 -c 90 -l 'Output Load' -u '%'
56 }


and still getting this

***** Nagios *****

Notification Type: PROBLEM

Service: Check UPS Battery LifeTime
Host: SmartUPS 2200B
Address: 192.168.0.7
State: CRITICAL

Date/Time: Fri Nov 4 13:04:40 PDT 2016

Additional Info:

SNMP CRITICAL - Battery RunTime *60000*


please help
I see, I didn't think about that. I am using a perl script for checking my ups units. I edited the script per ups variations as needed and pasted some output below.
https://exchange.nagios.org/directory/P ... ks/details

Sample output from Eaton

Code: Select all

Status is OK -- BATTERY AT 100% -- UPS IS NORMAL, ENERGY SAVER SYSTEM -- OUTPUT LOAD 23% -- REMOTE TEMP 68 F 
Sample output from APC

Code: Select all

Status is OK -- BATTERY AT 100% -- UPS IS NORMAL -- OUTPUT LOAD 19% -- INTERNAL TEMP 96.8 F

Re: UPS battery lifetime alert

Posted: Tue Nov 08, 2016 10:04 am
by tgrtjake
Here's an edited script to work with my APC Smart-UPS 2200.

Code: Select all

#!/usr/local/groundwork/bin/perl

#    Copyright (C) 2004 Altinity Limited
#    E: [email protected]    W: http://www.altinity.com/
#    Modified by [email protected]
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA    02111-1307    USA

use Net::SNMP;
use Getopt::Std;

$script    = "check_ups_pow.pl";
$script_version = "1.0";

$metric = 1;

$ipaddress = "192.168.1.1";     # default IP address, if none supplied
$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_upstype = ".1.3.6.1.2.1.1.5.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_temperature = ".1.3.6.1.4.1.318.1.1.1.2.2.2.0";

$upstype = "";
$battery_capacity = 0;
$output_status = 0;
$output_current =0;
$output_load = 0;
$temperature = 0;


# Do we have enough information?
if (@ARGV < 1) {
     print "Too few arguments\n";
     usage();
}

getopts("h:H:C:w:c:");
if ($opt_h){
    usage();
    exit(0);
}
if ($opt_H){
    $hostname = $opt_H;
}
else {
    print "No hostname specified\n";
    usage();
}
if ($opt_C){
    $community = $opt_C;
}
else {
}



# Create the SNMP session
my ($s, $e) = Net::SNMP->session(
     -community  =>  $community,
     -hostname   =>  $hostname,
     -version    =>  $version,
     -timeout    =>  $timeout,
);

main();

# Close the session
$s->close();

if ($status == 0){
    print "Status is OK -- $returnstring|$perfdata\n";
    # print "$returnstring\n";
}
elsif ($status == 1){
    print "Status is at WARNING -- $returnstring|$perfdata\n";
}
elsif ($status == 2){
    print "Status is at CRITICAL -- $returnstring|$perfdata\n";
}
else{
    print "Problem with monitoring plugin. No response from SNMP agent.\n";
}

exit $status;


####################################################################
# This is where we gather data via SNMP and return results         #
####################################################################

sub main {

        #######################################################

    if (!defined($s->get_request($oid_upstype))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $upstype = $s->var_bind_list()->{$_};
    }

    #######################################################

    if (!defined($s->get_request($oid_battery_capacity))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $battery_capacity = $s->var_bind_list()->{$_};
    }

    #######################################################

    if (!defined($s->get_request($oid_output_status))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $output_status = $s->var_bind_list()->{$_};
    }
    #######################################################

    if (!defined($s->get_request($oid_output_current))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $output_current = $s->var_bind_list()->{$_};
    }
    #######################################################

    if (!defined($s->get_request($oid_output_load))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $output_load = $s->var_bind_list()->{$_};
    }
    #######################################################

    if (!defined($s->get_request($oid_temperature))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $temperature = $s->var_bind_list()->{$_};
    }

$temp = $temperature * 1.8 + 32;
    #######################################################

    $returnstring = "";
    $status = 0;
    $perfdata = "";

#    if (defined($oid_upstype)) {
#        $returnstring = "$upstype - ";
#    }

    if ($battery_capacity < 25) {
        $returnstring = $returnstring . "BATTERY AT $battery_capacity% -- ";
        $status = 2;
    }
    elsif ($battery_capacity < 50) {
        $returnstring = $returnstring . "BATTERY AT $battery_capacity% -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($battery_capacity <= 100) {
        $returnstring = $returnstring . "BATTERY AT $battery_capacity% -- ";
    }
    else {
        $returnstring = $returnstring . "BATTERY CAPACITY UNKNOWN! -- ";
        $status = 3 if ( ( $status != 2 ) && ( $status != 1 ) );
    }


    if ($output_status eq "2"){
        $returnstring = $returnstring . "UPS IS NORMAL -- ";
    }
    elsif ($output_status eq "3"){
        $returnstring = $returnstring . "UPS IS ON BATTERY! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "4"){
        $returnstring = $returnstring . "UPS IS ON SMART BOOST! - ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "5"){
        $returnstring = $returnstring . "UPS IS ON TIMED SLEEP! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "6"){
        $returnstring = $returnstring . "UPS IS ON SOFTWARE BYPASS! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "7"){
        $returnstring = $returnstring . "UPS IS OFF! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "8"){
        $returnstring = $returnstring . "UPS IS REBOOTING! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "9"){
        $returnstring = $returnstring . "UPS IS ON SWITCHED BYPASS! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "10"){
        $returnstring = $returnstring . "UPS IS ON HARDWARE FAILURE BYPASS! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "11"){
        $returnstring = $returnstring . "UPS IS SLEEPING UNTIL POWER RETURN! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "12"){
        $returnstring = $returnstring . "UPS IS ON SMART TRIM! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "13"){
        $returnstring = $returnstring . "UPS IS ON ECO MODE! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "14"){
        $returnstring = $returnstring . "UPS IS ON HOT STANDBY! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "15"){
        $returnstring = $returnstring . "UPS IS PERFORMING BATTERY TEST! -- ";
#        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "16"){
        $returnstring = $returnstring . "UPS IS ON EMERGENCY STATIC BYPASS! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "17"){
        $returnstring = $returnstring . "UPS IS ON STATIC BYPASS STANDBY! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "18"){
        $returnstring = $returnstring . "UPS IS ON POWER SAVING MODE! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "19"){
        $returnstring = $returnstring . "UPS IS ON SPOT MODE! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "20"){
        $returnstring = $returnstring . "UPS IS ON ECONVERSION! -- ";
        $status = 1 if ( $status != 2 );
    }
    else {
        $returnstring = $returnstring . "UNKNOWN OUTPUT STATUS! -- ";
        $status = 3 if ( ( $status != 2 ) && ( $status != 1 ) );
    }

    if ($output_load > 90) {
        $returnstring = $returnstring . "OUTPUT LOAD $output_load% -- ";
        $perfdata = $perfdata . "'load'=$output_load ";
        $status = 2;
    }
    elsif ($output_load > 80) {
        $returnstring = $returnstring . "OUTPUT LOAD $output_load% -- ";
        $perfdata = $perfdata . "'load'=$output_load ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_load >= 0) {
        $returnstring = $returnstring . "OUTPUT LOAD $output_load% -- ";
        $perfdata = $perfdata . "'load'=$output_load ";
    }
    else {
        $returnstring = $returnstring . "OUTPUT LOAD UNKNOWN! -- ";
        $perfdata = $perfdata . "'load'=NAN ";
        $status = 3 if ( ( $status != 2 ) && ( $status != 1 ) );
    }

    if ($temperature > 93) {
        $returnstring = $returnstring . "INTERNAL TEMP $temp F";
        $perfdata = $perfdata . "'temp'=$temp ";
        $status = 2;
    }
    elsif ($temperature > 89) {
        $returnstring = $returnstring . "INTERNAL TEMP $temp F";
        $perfdata = $perfdata . "'temp'=$temp ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($temperature >= 0) {
        $returnstring = $returnstring . "INTERNAL TEMP $temp F";
        $perfdata = $perfdata . "'temp'=$temp ";
    }
    else {
        $returnstring = $returnstring . "INTERNAL TEMP UNKNOWN!";
        $perfdata = $perfdata . "'temp'=NAN ";
        $status = 3 if ( ( $status != 2 ) && ( $status != 1 ) );
    }

}

####################################################################
# help and usage information                                       #
####################################################################

sub usage {
    print << "USAGE";
-----------------------------------------------------------------
$script v$script_version

Monitors PowerWare UPS via SNMP management card.

Usage: $script -H <hostname> -C <community> [...]

Options: -H     Hostname or IP address
         -C     Community (default is public)

-----------------------------------------------------------------
Copyright 2004 Altinity Limited

This program is free software; you can redistribute it or modify
it under the terms of the GNU General Public License
-----------------------------------------------------------------

USAGE
     exit 1;
}                                                                                                                                      

Re: UPS battery lifetime alert

Posted: Tue Nov 08, 2016 2:15 pm
by avandemore
@sa77if -- Does this answer your question?

Re: UPS battery lifetime alert

Posted: Tue Nov 08, 2016 4:45 pm
by sa77if
avandemore wrote:
48 command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.318.1.1.1.2.2.3.0 -w 30000 -c 18000 -l 'Battery RunTime'
You've instructed Nagios to go critical if it gets a value <= 18000. You're getting a value > 18000 hence the critical. Also I'm not sure having a warning value less than a critical value is what you want.
it should alert when it goes to 30000 and lower, and shows critical when the value goes to 1800 and lower, now its alerting when the values are bigger! i didnt configure this the server was here before i came so i am trying to fix it



thanks

Re: UPS battery lifetime alert

Posted: Tue Nov 08, 2016 4:49 pm
by sa77if
tgrtjake wrote:Here's an edited script to work with my APC Smart-UPS 2200.

Code: Select all

#!/usr/local/groundwork/bin/perl

#    Copyright (C) 2004 Altinity Limited
#    E: [email protected]    W: http://www.altinity.com/
#    Modified by [email protected]
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA    02111-1307    USA

use Net::SNMP;
use Getopt::Std;

$script    = "check_ups_pow.pl";
$script_version = "1.0";

$metric = 1;

$ipaddress = "192.168.1.1";     # default IP address, if none supplied
$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_upstype = ".1.3.6.1.2.1.1.5.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_temperature = ".1.3.6.1.4.1.318.1.1.1.2.2.2.0";

$upstype = "";
$battery_capacity = 0;
$output_status = 0;
$output_current =0;
$output_load = 0;
$temperature = 0;


# Do we have enough information?
if (@ARGV < 1) {
     print "Too few arguments\n";
     usage();
}

getopts("h:H:C:w:c:");
if ($opt_h){
    usage();
    exit(0);
}
if ($opt_H){
    $hostname = $opt_H;
}
else {
    print "No hostname specified\n";
    usage();
}
if ($opt_C){
    $community = $opt_C;
}
else {
}



# Create the SNMP session
my ($s, $e) = Net::SNMP->session(
     -community  =>  $community,
     -hostname   =>  $hostname,
     -version    =>  $version,
     -timeout    =>  $timeout,
);

main();

# Close the session
$s->close();

if ($status == 0){
    print "Status is OK -- $returnstring|$perfdata\n";
    # print "$returnstring\n";
}
elsif ($status == 1){
    print "Status is at WARNING -- $returnstring|$perfdata\n";
}
elsif ($status == 2){
    print "Status is at CRITICAL -- $returnstring|$perfdata\n";
}
else{
    print "Problem with monitoring plugin. No response from SNMP agent.\n";
}

exit $status;


####################################################################
# This is where we gather data via SNMP and return results         #
####################################################################

sub main {

        #######################################################

    if (!defined($s->get_request($oid_upstype))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $upstype = $s->var_bind_list()->{$_};
    }

    #######################################################

    if (!defined($s->get_request($oid_battery_capacity))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $battery_capacity = $s->var_bind_list()->{$_};
    }

    #######################################################

    if (!defined($s->get_request($oid_output_status))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $output_status = $s->var_bind_list()->{$_};
    }
    #######################################################

    if (!defined($s->get_request($oid_output_current))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $output_current = $s->var_bind_list()->{$_};
    }
    #######################################################

    if (!defined($s->get_request($oid_output_load))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $output_load = $s->var_bind_list()->{$_};
    }
    #######################################################

    if (!defined($s->get_request($oid_temperature))) {
        if (!defined($s->get_request($oid_sysDescr))) {
            $returnstring = "SNMP agent not responding";
            $status = 1;
            return 1;
        }
        else {
            $returnstring = "SNMP OID does not exist";
            $status = 1;
            return 1;
        }
    }
     foreach ($s->var_bind_names()) {
         $temperature = $s->var_bind_list()->{$_};
    }

$temp = $temperature * 1.8 + 32;
    #######################################################

    $returnstring = "";
    $status = 0;
    $perfdata = "";

#    if (defined($oid_upstype)) {
#        $returnstring = "$upstype - ";
#    }

    if ($battery_capacity < 25) {
        $returnstring = $returnstring . "BATTERY AT $battery_capacity% -- ";
        $status = 2;
    }
    elsif ($battery_capacity < 50) {
        $returnstring = $returnstring . "BATTERY AT $battery_capacity% -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($battery_capacity <= 100) {
        $returnstring = $returnstring . "BATTERY AT $battery_capacity% -- ";
    }
    else {
        $returnstring = $returnstring . "BATTERY CAPACITY UNKNOWN! -- ";
        $status = 3 if ( ( $status != 2 ) && ( $status != 1 ) );
    }


    if ($output_status eq "2"){
        $returnstring = $returnstring . "UPS IS NORMAL -- ";
    }
    elsif ($output_status eq "3"){
        $returnstring = $returnstring . "UPS IS ON BATTERY! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "4"){
        $returnstring = $returnstring . "UPS IS ON SMART BOOST! - ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "5"){
        $returnstring = $returnstring . "UPS IS ON TIMED SLEEP! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "6"){
        $returnstring = $returnstring . "UPS IS ON SOFTWARE BYPASS! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "7"){
        $returnstring = $returnstring . "UPS IS OFF! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "8"){
        $returnstring = $returnstring . "UPS IS REBOOTING! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "9"){
        $returnstring = $returnstring . "UPS IS ON SWITCHED BYPASS! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "10"){
        $returnstring = $returnstring . "UPS IS ON HARDWARE FAILURE BYPASS! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "11"){
        $returnstring = $returnstring . "UPS IS SLEEPING UNTIL POWER RETURN! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "12"){
        $returnstring = $returnstring . "UPS IS ON SMART TRIM! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "13"){
        $returnstring = $returnstring . "UPS IS ON ECO MODE! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "14"){
        $returnstring = $returnstring . "UPS IS ON HOT STANDBY! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "15"){
        $returnstring = $returnstring . "UPS IS PERFORMING BATTERY TEST! -- ";
#        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "16"){
        $returnstring = $returnstring . "UPS IS ON EMERGENCY STATIC BYPASS! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "17"){
        $returnstring = $returnstring . "UPS IS ON STATIC BYPASS STANDBY! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "18"){
        $returnstring = $returnstring . "UPS IS ON POWER SAVING MODE! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "19"){
        $returnstring = $returnstring . "UPS IS ON SPOT MODE! -- ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_status eq "20"){
        $returnstring = $returnstring . "UPS IS ON ECONVERSION! -- ";
        $status = 1 if ( $status != 2 );
    }
    else {
        $returnstring = $returnstring . "UNKNOWN OUTPUT STATUS! -- ";
        $status = 3 if ( ( $status != 2 ) && ( $status != 1 ) );
    }

    if ($output_load > 90) {
        $returnstring = $returnstring . "OUTPUT LOAD $output_load% -- ";
        $perfdata = $perfdata . "'load'=$output_load ";
        $status = 2;
    }
    elsif ($output_load > 80) {
        $returnstring = $returnstring . "OUTPUT LOAD $output_load% -- ";
        $perfdata = $perfdata . "'load'=$output_load ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($output_load >= 0) {
        $returnstring = $returnstring . "OUTPUT LOAD $output_load% -- ";
        $perfdata = $perfdata . "'load'=$output_load ";
    }
    else {
        $returnstring = $returnstring . "OUTPUT LOAD UNKNOWN! -- ";
        $perfdata = $perfdata . "'load'=NAN ";
        $status = 3 if ( ( $status != 2 ) && ( $status != 1 ) );
    }

    if ($temperature > 93) {
        $returnstring = $returnstring . "INTERNAL TEMP $temp F";
        $perfdata = $perfdata . "'temp'=$temp ";
        $status = 2;
    }
    elsif ($temperature > 89) {
        $returnstring = $returnstring . "INTERNAL TEMP $temp F";
        $perfdata = $perfdata . "'temp'=$temp ";
        $status = 1 if ( $status != 2 );
    }
    elsif ($temperature >= 0) {
        $returnstring = $returnstring . "INTERNAL TEMP $temp F";
        $perfdata = $perfdata . "'temp'=$temp ";
    }
    else {
        $returnstring = $returnstring . "INTERNAL TEMP UNKNOWN!";
        $perfdata = $perfdata . "'temp'=NAN ";
        $status = 3 if ( ( $status != 2 ) && ( $status != 1 ) );
    }

}

####################################################################
# help and usage information                                       #
####################################################################

sub usage {
    print << "USAGE";
-----------------------------------------------------------------
$script v$script_version

Monitors PowerWare UPS via SNMP management card.

Usage: $script -H <hostname> -C <community> [...]

Options: -H     Hostname or IP address
         -C     Community (default is public)

-----------------------------------------------------------------
Copyright 2004 Altinity Limited

This program is free software; you can redistribute it or modify
it under the terms of the GNU General Public License
-----------------------------------------------------------------

USAGE
     exit 1;
}                                                                                                                                      



so you mean copying this to my commands.cfg will solve it? after changing the IPs and other parameters for sure

Re: UPS battery lifetime alert

Posted: Tue Nov 08, 2016 4:50 pm
by sa77if
avandemore wrote:@sa77if -- Does this answer your question?

i am sorry i was not on my desk for last 2 days, i will check now
thanks