UPS battery lifetime alert

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: UPS battery lifetime alert

Post by rkennedy »

No, this replaces the plugin you were previously using as @tgrtjake modified it for you.
Former Nagios Employee
sa77if
Posts: 35
Joined: Fri Oct 07, 2016 5:55 pm

Re: UPS battery lifetime alert

Post by sa77if »

rkennedy wrote:No, this replaces the plugin you were previously using as @tgrtjake modified it for you.
i am sorry, bare with me plz, where do i have to use this code? i am new on nagios

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;
}
tgrtjake
Posts: 20
Joined: Thu Sep 25, 2014 10:35 am

Re: UPS battery lifetime alert

Post by tgrtjake »

This is a perl script so you would need perl installed to use this. In my case it works great. You may or may not like it, but I thought I would suggest it to you to try.

Here's the link for the plugin.
https://exchange.nagios.org/directory/P ... 1451320184
Nagios Core 4.1.1 running on Ubuntu 14.04
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: UPS battery lifetime alert

Post by mcapra »

Thanks again @tgrtjake :)

@sa77if let us know if you have additional questions.
Former Nagios employee
https://www.mcapra.com/
sa77if
Posts: 35
Joined: Fri Oct 07, 2016 5:55 pm

Re: UPS battery lifetime alert

Post by sa77if »

sa77if wrote:
rkennedy wrote:No, this replaces the plugin you were previously using as @tgrtjake modified it for you.
i am sorry, bare with me plz, where do i have to use this code? i am new on nagios

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;
}

can we just modify the current code?
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: UPS battery lifetime alert

Post by rkennedy »

Yes, but we are not sure what changes have been made so I recommend using what was posted above.
Former Nagios Employee
sa77if
Posts: 35
Joined: Fri Oct 07, 2016 5:55 pm

Re: UPS battery lifetime alert

Post by sa77if »

rkennedy wrote:Yes, but we are not sure what changes have been made so I recommend using what was posted above.
ok i will give it a try
thanks
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: UPS battery lifetime alert

Post by tmcdonald »

Keep us posted.
Former Nagios employee
sa77if
Posts: 35
Joined: Fri Oct 07, 2016 5:55 pm

Re: UPS battery lifetime alert

Post by sa77if »

i modified the values according to this article and it works fine now
tank you though
you guys were great


https://exchange.nagios.org/directory/P ... ad/details
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: UPS battery lifetime alert

Post by tmcdonald »

Glad it's working! Mind if we close up this ticket?
Former Nagios employee
Locked