From 433239aa548836d3bf2986ca7f0b5179ee8cd6d2 Mon Sep 17 00:00:00 2001 From: Davide Foschi Date: Mon, 21 Jan 2019 13:31:55 +0100 Subject: [PATCH] check_apc: added high precision (double) value in input voltage, iutput voltage and output current checks Fix #1 as proposed by @fbarton --- check symmetra apc/check_apc.pl | 39 +++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/check symmetra apc/check_apc.pl b/check symmetra apc/check_apc.pl index cc363bf..11dd456 100644 --- a/check symmetra apc/check_apc.pl +++ b/check symmetra apc/check_apc.pl @@ -1,13 +1,14 @@ #!/usr/bin/perl -w # -# check_apc.pl v2.1.1 +# check_apc.pl v2.2 # # version history # +# 2.2 added High Precision value for InputVoltage/OutputVoltage/OutputCurrent (thanks to @fbarton) # 2.1 added power modules check # 2.0 first release after fork # -# Nagios plugin script for checking APC UPS. +# Nagios plugin script for checking APC Symmetra UPS. # # License: GPL v2 # Copyright (c) 2017 Davide "Argaar" Foschi @@ -24,15 +25,15 @@ use Time::Local; # Command arguments my %options=(); -getopts("H:C:l:p:t:w:c:u", \%options); +getopts("H:C:l:p:t:w:c:hu", \%options); # Help message etc (my $script_name = $0) =~ s/.\///; my $help_info = < ERROR <--\n--> Not all required options were specified. <--\n\n"; + print "$help_info\n --> Not all required options were specified. <--\n\n"; exit $UNKNOWN; } @@ -452,7 +458,12 @@ if (!defined $options{l}) { # If no command was given, just output the UPS mode exit $exitCode; } case "in_volt" { - my $in_volt = query_oid($oid_upsAdvInputLineVoltage); + my $in_volt; + if ($high_precision) { + $in_volt = query_oid($oid_upsAdvInputHPLineVoltage)/10; + } else { + $in_volt = query_oid($oid_upsAdvInputLineVoltage); + } $session->close(); my @crit_values = split(/:/, $critical_threshold); my @warn_values = split(/:/, $warning_threshold); @@ -550,7 +561,12 @@ if (!defined $options{l}) { # If no command was given, just output the UPS mode exit $exitCode; } case "out_volt" { - my $out_volt = query_oid($oid_upsAdvOutputVoltage); + my $out_volt; + if ($high_precision) { + $out_volt = query_oid($oid_upsAdvOutputHPVoltage)/10; + } else { + $out_volt = query_oid($oid_upsAdvOutputVoltage); + } $session->close(); my @crit_values = split(/:/, $critical_threshold); my @warn_values = split(/:/, $warning_threshold); @@ -617,7 +633,12 @@ if (!defined $options{l}) { # If no command was given, just output the UPS mode exit $exitCode; } case "out_current" { - my $out_current = query_oid($oid_upsAdvOutputCurrent); + my $out_current; + if ($high_precision) { + $out_current = query_oid($oid_upsAdvOutputHPCurrent)/10; + } else { + $out_current = query_oid($oid_upsAdvOutputCurrent); + } $session->close(); if (defined $critical_threshold && defined $warning_threshold && $critical_threshold<$warning_threshold) { print "ERROR: Critical Threshold should be GREATER than Warning Threshold!\n"; -- GitLab