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

Update check_apcext.pl

Fix code indentation
This commit is contained in:
Sidney Souza 2014-12-02 10:58:38 -02:00
parent 13cab5608e
commit 231f2c74c4

View File

@ -6,7 +6,7 @@
# #
# v0.0.2 # v0.0.2
# #
# # vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
use Net::SNMP; use Net::SNMP;
use Getopt::Std; use Getopt::Std;
@ -55,14 +55,14 @@ my %oids = (
'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',
@ -70,7 +70,7 @@ my %oids = (
'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' => '',
@ -78,131 +78,131 @@ my %oids = (
'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) = @_;
@ -235,7 +235,9 @@ if ($list) {
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}\"");
} }
@ -253,7 +255,7 @@ Detected sensors:
if ($param eq "rpduamps") { if ($param eq "rpduamps") {
# $param = "RackPDU"; # $param = "RackPDU";
for (my $i=1;$i<4;$i++) { for (my $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;
@ -265,8 +267,8 @@ if ($param eq "rpduamps") {
exit $retval; exit $retval;
} }
$rpduamps{$i} = $response->{$phoid}; $rpduamps{$i} = $response->{$phoid};
} }
$session->close; $session->close;
#$crit = ($crit * 10); #$crit = ($crit * 10);
#$warn = ($warn * 10); #$warn = ($warn * 10);
@ -322,8 +324,9 @@ if ($param eq "rpduamps") {
} else { } else {
my $snmpd = getmasked_values( my $snmpd = getmasked_values(
$oidbase, { $oidbase, {
$oids{$param}->{sensor_key} => 'sensor_key', $oids{$param}->{sensor_key} => 'sensor_key',
$oids{$param}->{sensor_val} => 'sensor_val' } $oids{$param}->{sensor_val} => 'sensor_val'
}
); );
if ((keys %{$snmpd}) > 1 && !$sensor_int_name) { if ((keys %{$snmpd}) > 1 && !$sensor_int_name) {