1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2024-11-24 11:23:47 +01:00

Fix snmp session get without community defined

Fix snmp session get without community defined
Fix code indentation
Added options -m on usage
Added constants variables
This commit is contained in:
Sidney Souza 2014-12-02 12:56:01 -02:00
parent 944d47e18e
commit 3528589b39

View File

@ -6,7 +6,12 @@
# #
# v0.0.1 # v0.0.1
# #
# v.0.0.2 02/12/2014, Sidney Souza
# Fix snmp session get without community defined
# Fix code indentation
# Added options -m on usage
# #
# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4
use Net::SNMP; use Net::SNMP;
use Getopt::Std; use Getopt::Std;
@ -14,12 +19,23 @@ use Data::Dumper;
use vars qw/ %opt /; use vars qw/ %opt /;
use strict; use strict;
use constant{
OK => 0,
WARNING => 1,
CRITICAL => 2,
UNKNOWN => 3,
true => 1,
false => 0,
VERSION => '0.0.2'
};
sub getmasked_values ($$); sub getmasked_values ($$);
sub f2c ($); sub f2c ($);
if ($ARGV[0] =~ /(--help|-h|help)/ || !defined$ARGV[0]) { if ($ARGV[0] =~ /(--help|-h|help)/ || !defined$ARGV[0]) {
&usage; &usage;
exit 0; exit 0;
} }
my $opts = 's:lmC:H:p:w:c:'; my $opts = 's:lmC:H:p:w:c:';
@ -31,360 +47,360 @@ my $comm = $opt{C};
my $param = $opt{p}; my $param = $opt{p};
my $warn = $opt{w}; my $warn = $opt{w};
my $crit = $opt{c}; my $crit = $opt{c};
my $metric = $opt{m}; my $metric = "degF" if ( defined ($opt{m}) );
my $list = $opt{l}; my $list = $opt{l};
my $sensor_int_name = $opt{s}; my $sensor_int_name = $opt{s};
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $comm,
-version => 'snmpv2c',
-port => "161"
);
my ($oid, $oidbase, $fval, $unit, $outmsg); my ($oid, $oidbase, $fval, $unit, $outmsg);
my $retval = 0; my $retval = OK;
my %rpduamps; my %rpduamps;
my %oids = ( my %oids = (
'nbmstemp' => { 'nbmstemp' => {
'label' => 'Temp', 'label' => 'Temp',
'unit' => 'degF', 'unit' => 'degF',
'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.1.1', 'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.1.1',
'sensor_key' => 5, 'sensor_key' => 5,
'sensor_val' => 9, 'sensor_val' => 9,
#'cdef' => '$val * 0.1' #'cdef' => '$val * 0.1'
}, },
'nbmshum' => { 'nbmshum' => {
'label' => 'Humidity', 'label' => 'Humidity',
'unit' => '%', 'unit' => '%',
'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.2.1', 'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.2.1',
'sensor_key' => 5, 'sensor_key' => 5,
'sensor_val' => 8, 'sensor_val' => 8,
}, },
'nbmsairflow' => { 'nbmsairflow' => {
'label' => 'Air Flow', 'label' => 'Air Flow',
'unit' => 'CFM', 'unit' => 'CFM',
'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.5.1', 'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.5.1',
'sensor_val' => 8, 'sensor_val' => 8,
'sensor_key' => 5, 'sensor_key' => 5,
'mod' => 'lt' 'mod' => 'lt'
}, },
'nbmsaudio' => { 'nbmsaudio' => {
'label' => 'Audio Level', 'label' => 'Audio Level',
'unit' => '', 'unit' => '',
'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.4.1', 'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.4.1',
'sensor_val' => 7, 'sensor_val' => 7,
'sensor_key' => 5, 'sensor_key' => 5,
'mod' => '' 'mod' => ''
}, },
'rpduamps' => { 'rpduamps' => {
'label' => 'Power Output', 'label' => 'Power Output',
'unit' => 'Amps', 'unit' => 'Amps',
'oid' => '.1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.', 'oid' => '.1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acscstatus' => { 'acscstatus' => {
'label' => 'Status', 'label' => 'Status',
'unit' => '', 'unit' => '',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.1.0' 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.1.0'
}, },
'acscload' => { 'acscload' => {
'label' => 'Cooling Load', 'label' => 'Cooling Load',
'unit' => 'kW', 'unit' => 'kW',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.3.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.3.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acscoutput' => { 'acscoutput' => {
'label' => 'Cooling output', 'label' => 'Cooling output',
'unit' => 'kW', 'unit' => 'kW',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.2.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.2.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acscsupair' => { 'acscsupair' => {
'label' => 'Supply Air', 'label' => 'Supply Air',
'unit' => 'degF', 'unit' => 'degF',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.8.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.8.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acscretair' => { 'acscretair' => {
'label' => 'Return Air', 'label' => 'Return Air',
'unit' => 'degF', 'unit' => 'degF',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.10.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.10.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acscairflow' => { 'acscairflow' => {
'label' => 'Airflow', 'label' => 'Airflow',
'unit' => 'CFM', 'unit' => 'CFM',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.4.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.4.0',
}, },
'acscracktemp' => { 'acscracktemp' => {
'label' => 'Rack Inlet Temp', 'label' => 'Rack Inlet Temp',
'unit' => 'degF', 'unit' => 'degF',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.6.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.6.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acsccondin' => { 'acsccondin' => {
'label' => 'Cond Inlet Temp', 'label' => 'Cond Inlet Temp',
'unit' => 'degF', 'unit' => 'degF',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.30.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.30.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acsccondout' => { 'acsccondout' => {
'label' => 'Cond Outlet Temp', 'label' => 'Cond Outlet Temp',
'unit' => 'degF', 'unit' => 'degF',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.28.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.28.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acrcstatus' => { 'acrcstatus' => {
'label' => 'Status', 'label' => 'Status',
'unit' => '', 'unit' => '',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.1.0' 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.1.0'
}, },
'acrcload' => { 'acrcload' => {
'label' => 'Cooling Load', 'label' => 'Cooling Load',
'unit' => 'kW', 'unit' => 'kW',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.2.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.2.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acrcoutput' => { 'acrcoutput' => {
'label' => 'Cooling Output', 'label' => 'Cooling Output',
'unit' => 'kW', 'unit' => 'kW',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.3.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.3.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acrcairflow' => { 'acrcairflow' => {
'label' => 'Airflow', 'label' => 'Airflow',
'unit' => 'CFM', 'unit' => 'CFM',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.4.0' 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.4.0'
}, },
'acrcracktemp' => { 'acrcracktemp' => {
'label' => 'Rack Inlet Temp', 'label' => 'Rack Inlet Temp',
'unit' => 'degF', 'unit' => 'degF',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.6.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.6.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acrcsupair' => { 'acrcsupair' => {
'label' => 'Supply Air', 'label' => 'Supply Air',
'unit' => 'degF', 'unit' => 'degF',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.8.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.8.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acrcretair' => { 'acrcretair' => {
'label' => 'Return Air', 'label' => 'Return Air',
'unit' => 'degF', 'unit' => 'degF',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.10.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.10.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acrcfanspeed' => { 'acrcfanspeed' => {
'label' => 'Fan Speed', 'label' => 'Fan Speed',
'unit' => '%', 'unit' => '%',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.16.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.16.0',
'cdef' => '$val * .10', 'cdef' => '$val * .10',
}, },
'acrcfluidflow' => { 'acrcfluidflow' => {
'label' => 'Fluid Flow', 'label' => 'Fluid Flow',
'unit' => 'GPM', 'unit' => 'GPM',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.21.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.21.0',
'cdef' => '$val * .10', 'cdef' => '$val * .10',
'mod' => 'lt' 'mod' => 'lt'
}, },
'acrcflenttemp' => { 'acrcflenttemp' => {
'label' => 'Entering Fluid Temp', 'label' => 'Entering Fluid Temp',
'unit' => 'degF', 'unit' => 'degF',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.23.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.23.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
'acrcflrettemp' => { 'acrcflrettemp' => {
'label' => 'Returning Fluid Temp', 'label' => 'Returning Fluid Temp',
'unit' => 'degF', 'unit' => 'degF',
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.25.0', 'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.25.0',
'cdef' => '$val * .10' 'cdef' => '$val * .10'
}, },
); );
if ($list) { if ($list) {
my ($baseoid, $int_name_id, $value_id) = @_; my ($baseoid, $int_name_id, $value_id) = @_;
my ($session, $error) = Net::SNMP->session( my $response = $session->get_table(-baseoid => ".1.3.6.1.4.1.5528.100.2.1.1");
-hostname => $host,
-community => $comm, my $err = $session->error;
-version => 1,
# -translate => [-octetstring => 0x0], if ($err){
-port => "161" $retval = UNKNOWN;
); $outmsg = "UNKNOWN";
my $response = $session->get_table(-baseoid => ".1.3.6.1.4.1.5528.100.2.1.1"); $session->close();
my $err = $session->error; print "$outmsg $err - SNMP Error connecting to $host\n";
if ($err){ exit $retval;
$retval = 3; }
$outmsg = "UNKNOWN";
$session->close(); my %sensor;
print "$outmsg $err - SNMP Error connecting to $host\n"; foreach my $key (keys %{$response}) {
exit $retval; my ($type, $id) = (split(/\./, $key))[-2,-1];
next if ($type != 1 and $type != 4);
next if ($id < 2000000000);
if ($type == 1) {
$sensor{$id}->{"int_name"} = $response->{$key};
} else {
$sensor{$id}->{"friendly_name"} = $response->{$key};
} }
my %sensor; }
foreach my $k (keys %{$response}) {
my ($type, $id) = (split(/\./, $k))[-2,-1];
next if ($type != 1 and $type != 4);
next if ($id < 2000000000);
if ($type == 1) {
$sensor{$id}->{"int_name"} = $response->{$k};
} else {
$sensor{$id}->{"friendly_name"} = $response->{$k};
}
}
print <<" EO"; print <<" EO";
Specify a sensor by using the -s and the INTERNAL name of the sensor Specify a sensor by using the -s and the INTERNAL name of the sensor
Detected sensors: Detected sensors:
EO
EO printf("\t%-32s %s\n", "Friendly Name", "Internal Name");
printf("\t%-32s %s\n", "Friendly Name", "Internal Name"); foreach my $id (sort { $sensor{$a}->{"friendly_name"} cmp $sensor{$b}->{"friendly_name"} } keys %sensor) {
foreach my $id (sort { $sensor{$a}->{"friendly_name"} cmp $sensor{$b}->{"friendly_name"} } keys %sensor) { printf ("\t%-32s %s\n", "\"$sensor{$id}->{friendly_name}\"", "\"$sensor{$id}->{int_name}\"");
printf ("\t%-32s %s\n", "\"$sensor{$id}->{friendly_name}\"", "\"$sensor{$id}->{int_name}\""); }
} exit 0;
exit 0;
} elsif (!$oids{$param}) { } elsif (!$oids{$param}) {
print "No test parameter specified"; print "No test parameter specified";
exit 3; exit 3;
} else { } else {
$oid = $oids{$param}->{oid}; $oid = $oids{$param}->{oid};
$oidbase = $oids{$param}->{oidbase}; $oidbase = $oids{$param}->{oidbase};
} }
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $comm,
-version => 1,
# -translate => [-octetstring => 0x0],
-port => "161"
);
if ($param eq "rpduamps") { if ($param eq "rpduamps") {
# $param = "RackPDU"; # $param = "RackPDU";
my $i; for (my $i=1;$i<4;$i++) {
for ($i=1;$i<4;$i++) { my $phoid = $oid . $i;
my $phoid = $oid . $i; my $response = $session->get_request($phoid);
my $response = $session->get_request($phoid); my $err = $session->error;
my $err = $session->error;
if ($err){
$retval = 3;
$outmsg = "UNKNOWN";
$session->close();
print "$outmsg $err - SNMP Error connecting to $host\n";
exit $retval;
}
$rpduamps{$i} = $response->{$phoid};
}
$session->close;
#$crit = ($crit * 10);
#$warn = ($warn * 10);
$unit = "Amps"; if ($err){
foreach my $ph ( sort keys %rpduamps ) { $retval = UNKNOWN;
my $tphase = ($rpduamps{$ph} * .1); $outmsg = "UNKNOWN";
$session->close();
print "$outmsg $err - SNMP Error connecting to $host\n";
exit $retval;
}
if (($tphase >= $crit) && ($retval < 2)) { $rpduamps{$i} = $response->{$phoid};
$retval = 2; }
$outmsg = "CRITICAL"; $session->close;
#$crit = ($crit * 10);
#$warn = ($warn * 10);
} elsif (($tphase >= $warn) && ($retval < 1)) { $unit = "Amps";
$retval = 1; foreach my $ph ( sort keys %rpduamps ) {
$outmsg = "WARNING"; my $tphase = ($rpduamps{$ph} * .1);
} elsif ($retval < 1) { if (($tphase >= $crit) && ($retval < 2)) {
$retval = 0; $retval = CRITICAL;
$outmsg = "OK"; $outmsg = "CRITICAL";
}
$fval .= "Phase $ph: " . $tphase; } elsif (($tphase >= $warn) && ($retval < 1)) {
#$fval .= "Phase $ph: " . ($tphase * .1); $retval = WARNING;
if ($ph lt 3) { $outmsg = "WARNING";
$fval .= " Amps, ";
#} else {
# $fval .= " ";
}
} } elsif ($retval < 1) {
$retval = OK;
$outmsg = "OK";
}
$fval .= "Phase $ph: " . $tphase;
#$fval .= "Phase $ph: " . ($tphase * .1);
if ($ph lt 3) {
$fval .= " Amps, ";
#} else {
# $fval .= " ";
}
}
} else { } else {
my $val; my $val;
if ($oid) {
my $response = $session->get_request($oid);
my $err = $session->error; if ($oid) {
if ($err){ my $response = $session->get_request($oid);
$retval = 3;
$outmsg = "UNKNOWN"; my $err = $session->error;
$session->close();
print "$outmsg $err - SNMP Error connecting to $host\n"; if ($err){
exit $retval; $retval = UNKNOWN;
} $outmsg = "UNKNOWN";
$session->close();
print "$outmsg $err - SNMP Error connecting to $host\n";
exit $retval;
}
$val = $response->{$oid}; $val = $response->{$oid};
$session->close(); $session->close();
} else { } else {
my $snmpd = getmasked_values($oidbase, { $oids{$param}->{sensor_key} => 'sensor_key', my $snmpd = getmasked_values(
$oids{$param}->{sensor_val} => 'sensor_val' }); $oidbase, {
$oids{$param}->{sensor_key} => 'sensor_key',
$oids{$param}->{sensor_val} => 'sensor_val' }
);
if ((keys %{$snmpd}) > 1 && !$sensor_int_name) { if ((keys %{$snmpd}) > 1 && !$sensor_int_name) {
print "UNKNOWN - Many sensors found but none specified, see -s and -l\n"; print "UNKNOWN - Many sensors found but none specified, see -s and -l\n";
exit 3; exit UNKNOWN;
} elsif ((keys %{$snmpd}) == 0) { } elsif ((keys %{$snmpd}) == 0) {
print "UNKNOWN - no sensors found on this device\n"; print "UNKNOWN - no sensors found on this device\n";
exit 3; exit UNKNOWN;
} else { } else {
my $id = (keys %{$snmpd})[0]; my $id = (keys %{$snmpd})[0];
$val = $snmpd->{$id}->{sensor_val}; $val = $snmpd->{$id}->{sensor_val};
} }
if ($sensor_int_name) { if ($sensor_int_name) {
foreach my $k (keys %{$snmpd}) { foreach my $k (keys %{$snmpd}) {
if (lc($snmpd->{$k}->{sensor_key}) eq lc($sensor_int_name)) { if (lc($snmpd->{$k}->{sensor_key}) eq lc($sensor_int_name)) {
$val = $snmpd->{$k}->{sensor_val}; $val = $snmpd->{$k}->{sensor_val};
} }
} }
} }
if ($val eq "") { if ($val eq "") {
print Dumper $snmpd; print Dumper $snmpd;
print "UNKNOWN Unable to get sensor status\n"; print "UNKNOWN Unable to get sensor status\n";
exit 3; exit UNKNOWN;
} }
} }
if ($param eq "acscstatus" || $param eq "acrcstatus") { if ($param eq "acscstatus" || $param eq "acrcstatus") {
if ($val == 1) {
$fval = "Standby";
$retval = 1;
$outmsg = "WARNING";
} elsif ($val == 2) {
$fval = "On";
$retval = 0;
$outmsg = "OK";
}
} else {
if ($oids{$param}->{cdef}) { if ($val == 1) {
$fval = eval "$oids{$param}->{cdef}"; $fval = "Standby";
} else { $retval = WARNING;
$fval = $val; $outmsg = "WARNING";
} } elsif ($val == 2) {
$fval = "On";
$retval = OK;
$outmsg = "OK";
}
} else {
if ($metric and $oids{$param}->{unit} eq 'degF') { if ($oids{$param}->{cdef}) {
$oids{$param}->{unit} = 'degC'; $fval = eval "$oids{$param}->{cdef}";
$fval = sprintf("%.1f", f2c($fval)); } else {
} $fval = $val;
}
if ($fval > $crit) { if ($metric and $oids{$param}->{unit} eq 'degF') {
$retval = 2; $oids{$param}->{unit} = 'degC';
$outmsg = "CRITICAL"; $fval = sprintf("%.1f", f2c($fval));
} elsif ($fval > $warn) { }
$retval = 1;
$outmsg = "WARNING"; if ($fval > $crit) {
} else { $retval = CRITICAL;
$retval = 0; $outmsg = "CRITICAL";
$outmsg = "OK"; } elsif ($fval > $warn) {
} $retval = WARNING;
} $outmsg = "WARNING";
} else {
$retval = OK;
$outmsg = "OK";
}
}
} }
print "$outmsg - " . $oids{$param}->{label} . " " .$fval . " " . $oids{$param}->{unit} . " | $param=$fval$oids{$param}->{unit}\n"; print "$outmsg - " . $oids{$param}->{label} . " " .$fval . " " . $oids{$param}->{unit} . " | $param=$fval$oids{$param}->{unit}\n";
@ -394,67 +410,58 @@ exit $retval;
sub usage { sub usage {
print "Usage: $0 -H <hostip> -C <community> -p <parameter> -w <warnval> -c <critval> [-l] [-s sensor]\n"; print "Usage: $0 -H <hostip> -C <community> -p <parameter> -w <warnval> -c <critval> [-l] [-s sensor] [-m]\n";
print "\nParameters:\n"; print "\nParameters:\n";
print <<" EO"; print <<" EO";
APC NetBotz APC NetBotz
nbmstemp NetBotz main sensor temp | nbmshum NetBotz main sensor humidity nbmstemp NetBotz main sensor temp | nbmshum NetBotz main sensor humidity
nbmsairflow NetBotz main sensor airflow | nbmsaudio NetBotz main sensor audio nbmsairflow NetBotz main sensor airflow | nbmsaudio NetBotz main sensor audio
-l List connected sensors | -s sensor Sensor we want info from -l List connected sensors | -s sensor Sensor we want info from
APC Metered Rack PDU APC Metered Rack PDU
rpduamps Amps on each phase rpduamps Amps on each phase
APC ACSC In-Row APC ACSC In-Row
acscstatus System status (on/standby) | acscload Cooling load acscstatus System status (on/standby) | acscload Cooling load
acscoutput Cooling output | acscsupair Supply air acscoutput Cooling output | acscsupair Supply air
acscairflow Air flow | acscracktemp Rack inlet temp acscairflow Air flow | acscracktemp Rack inlet temp
acsccondin Condenser input temp | acsccondout Condenser outlet temp acsccondin Condenser input temp | acsccondout Condenser outlet temp
APC ACRC In-Row APC ACRC In-Row
acrcstatus System status (on/standby) | acrcload Cooling load acrcstatus System status (on/standby) | acrcload Cooling load
acrcoutput Cooling output | acrcairflow Air flow acrcoutput Cooling output | acrcairflow Air flow
acrcracktemp Rack inlet temp | acrcsupair Supply air acrcracktemp Rack inlet temp | acrcsupair Supply air
acrcretair Return air | acrcfanspeed Fan speed acrcretair Return air | acrcfanspeed Fan speed
acrcfluidflow Fluid flow | acrcflenttemp Fluid entering temp acrcfluidflow Fluid flow | acrcflenttemp Fluid entering temp
acrcflrettemp Fluid return temp acrcflrettemp Fluid return temp
EO EO
exit 3; exit 3;
} }
sub f2c($) { sub f2c($) {
my $f = shift; my $f = shift;
return ($f - 32) * (5/9); return ($f - 32) * (5/9);
} }
sub getmasked_values ($$) { sub getmasked_values ($$) {
my ($baseoid, $values) = @_; my ($baseoid, $values) = @_;
my ($session, $error) = Net::SNMP->session( my $response = $session->get_table(-baseoid => $baseoid);
-hostname => $host, my $err = $session->error;
-community => $comm, if ($err){
-version => 1, $retval = UNKNOWN;
-port => "161" $outmsg = "UNKNOWN";
); $session->close();
my $response = $session->get_table(-baseoid => $baseoid); print "$err - SNMP Error connecting to $host\n";
my $err = $session->error; exit $retval;
if ($err){ }
$retval = 3;
$outmsg = "UNKNOWN"; my %snmpdata;
$session->close(); foreach my $k (keys %{$response}) {
print "$err - SNMP Error connecting to $host\n"; my ($type, $id) = (split(/\./, $k))[-2,-1];
exit $retval; if ($values->{$type}) {
$snmpdata{$id}->{$values->{$type}} = $response->{$k};
} }
}
my %snmpdata; return \%snmpdata;
foreach my $k (keys %{$response}) {
my ($type, $id) = (split(/\./, $k))[-2,-1];
if ($values->{$type}) {
$snmpdata{$id}->{$values->{$type}} = $response->{$k};
}
}
return \%snmpdata;
} }