Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# check_ups_apc
Monitors APC SmartUPS via SNMP.

Based on check_ups_apc.pl from altinity.com (Opsview) with modifications of Blueeye.
Based on check_ups_apc.pl from altinity.com (Opsview) with modifications by Blueeye and M. Fuchs.

Summary:
perfdata for Battery Capacity
Frequency-Monitoring (with perfdata)
Voltage-Monitoring (Input/Output and perfdata)
Battery Replacement notification
UPS Serialnumber
Temperature

Usage:

Expand Down
84 changes: 53 additions & 31 deletions check_ups_apc_v2.pl
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,32 @@
# Script edit by Andreas Winter (info@aw-edv-systeme.de)
# * adding Battery Replacement check
#
############
#
# Script modified by M. Fuchs
# * added custom warning temperature
#
############


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

$script = "check_ups_apc_v2.pl";
$script_version = "2.0";
$script_version = "2.1";

$metric = 1;

$ipaddress = "192.168.1.1"; # default IP address, if none supplied
$version = "1"; # SNMP version
$timeout = 2; # SNMP query timeout
$version = "1"; # SNMP version
$timeout = 2; # SNMP query timeout
# $warning = 100;
# $critical = 150;
$status = 0;
$returnstring = "";
$perfdata = "";

$community = "public"; # Default community string
$community = "public"; # Default community string

$oid_sysDescr = ".1.3.6.1.2.1.1.1.0";
$oid_upstype = ".1.3.6.1.4.1.318.1.1.1.1.1.1.0";
Expand All @@ -63,20 +70,22 @@
$oid_input_volt = ".1.3.6.1.4.1.318.1.1.1.3.2.1.0"; # added by Blueeye
$oid_output_volt = ".1.3.6.1.4.1.318.1.1.1.4.2.1.0"; # added by Blueeye
$oid_battery_replace = "1.3.6.1.4.1.318.1.1.1.2.2.4.0"; # added by AW
$oid_serial = "1.3.6.1.4.1.318.1.1.1.1.2.3.0"; # added by AW
$oid_serial = "1.3.6.1.4.1.318.1.1.1.1.2.3.0"; # added by AW

$upstype = "";
$battery_capacity = 0;
$output_status = 0;
$output_current =0;
$output_load = 0;
$temperature = 0;
$warn_temperature = 35; # default warning temperature / M. Fuchs
$crit_temperature = 38; # default warning temperature / M. Fuchs

$input_freq = 0; # added by Blueeye
$output_freq = 0; # added by Blueeye
$input_volt = 0; # added by Blueeye
$output_volt = 0; # added by Blueeye
$battery_replace = 1; # added by AW
$battery_replace = 1; # added by AW
$ups_serial = ""; # added by AW


Expand All @@ -86,7 +95,7 @@
usage();
}

getopts("h:H:C:w:c:");
getopts("h:H:C:I:A:w:c");
if ($opt_h){
usage();
exit(0);
Expand All @@ -104,7 +113,17 @@
else {
}

if ($opt_I){
$warn_temperature = $opt_I;
}
else {
}

if ($opt_A){
$crit_temperature = $opt_A;
}
else {
}

# Create the SNMP session
my ($s, $e) = Net::SNMP->session(
Expand Down Expand Up @@ -142,7 +161,7 @@

sub main {

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

if (!defined($s->get_request($oid_upstype))) {
if (!defined($s->get_request($oid_sysDescr))) {
Expand Down Expand Up @@ -428,19 +447,19 @@ sub main {
$status = 3 if ( ( $status != 2 ) && ( $status != 1 ) );
}

if ($temperature > 38) {
if ($temperature > $crit_temperature) {
$returnstring = $returnstring . "!!!CRITICAL TEMPERATURE!!! $temperature C - ";
$perfdata = $perfdata . "'temp'=$temperature;35;38;0;70 ";
$perfdata = $perfdata . "'temp'=$temperature;$warn_temperature;$crit_temperature;0;70 ";
$status = 2;
}
elsif ($temperature > 35) {
elsif ($temperature > $warn_temperature) {
$returnstring = $returnstring . "!!!WARNING TEMPERATURE!!! $temperature C - ";
$perfdata = $perfdata . "'temp'=$temperature;35;38;0;70 ";
$perfdata = $perfdata . "'temp'=$temperature;$warn_temperature;$crit_temperature;0;70 ";
$status = 1 if ( $status != 2 );
}
elsif ($temperature >= 0) {
$returnstring = $returnstring . "TEMPERATURE $temperature C - ";
$perfdata = $perfdata . "'temp'=$temperature;35;38;0;70 ";
$perfdata = $perfdata . "'temp'=$temperature;$warn_temperature;$crit_temperature;0;70 ";
}
else {
$returnstring = $returnstring . "TEMPERATURE UNKNOWN! - ";
Expand Down Expand Up @@ -509,18 +528,20 @@ sub main {
$status = 3 if ( ( $status != 2 ) && ( $status != 1 ) );
}

######## Added by AW #############
if ($battery_replace == 2 ) {
$returnstring = $returnstring . "!!!BATTERY NEEDS REPLACING!!! - ";
$status = 2;
}
else {
$returnstring = $returnstring . "BATTERY OK!";
$status = 3 if ( ( $status == 1 ) );
}

$returnstring = $returnstring . " UPS Serialnumber: $ups_serial - ";

######## Added by AW / modified by M. Fuchs #############
if ($battery_replace == 2 ) {
$returnstring = $returnstring . "!!!BATTERY NEEDS REPLACING!!! - ";
$status = 2;
}
elsif ($battery_replace == 1 ) {
$returnstring = $returnstring . "BATTERY OK!";
$status = 0 if ( ( $status != 2 ) && ( $status != 1 ) );
}
else {
$status = 3;
}

$returnstring = $returnstring . " UPS Serialnumber: $ups_serial - ";

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

Expand All @@ -539,19 +560,20 @@ sub usage {

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

Options: -H Hostname or IP address
-C Community (default is public)
Options: -H Hostname or IP address (default: 192.1368.1.1)
-C Community (default: public)
-I Warning Temperature (default: 35°C)
-A Critical Temperature (defalut: 38°C)

-----------------------------------------------------------------
Copyright 2004 Altinity Limited
Modified 03.2010 by Blueeye

Modified 03.2010 by Blueeye
Modified 06.2020 by M. Fuchs

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

USAGE
exit 1;
}