This commit is contained in:
garnier-quentin 2019-12-26 10:58:23 +01:00
parent fd90ccb74c
commit 426343eee1
2 changed files with 114 additions and 56 deletions

View File

@ -33,20 +33,38 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'temperature', nlabel => 'environment.ambient.temperature.celsius', set => { { label => 'internal-temperature', nlabel => 'environment.internal.temperature.celsius', set => {
key_values => [ { name => 'temperature' } ], key_values => [ { name => 'internal_temperature' } ],
output_template => 'ambient temperature: %.2f C', output_template => 'internal temperature: %.2f C',
perfdatas => [ perfdatas => [
{ value => 'temperature_absolute', template => '%.2f', { value => 'internal_temperature_absolute', template => '%.2f',
min => 0, unit => 'C' }, min => 0, unit => 'C' },
], ],
} }
}, },
{ label => 'humidity', nlabel => 'environment.humidity.percentage', set => { { label => 'internal-humidity', nlabel => 'environment.internal.humidity.percentage', set => {
key_values => [ { name => 'humidity' } ], key_values => [ { name => 'internal_humidity' } ],
output_template => 'humidity: %.2f %%', output_template => 'internal humidity: %.2f %%',
perfdatas => [ perfdatas => [
{ value => 'humidity_absolute', template => '%.2f', { value => 'internal_humidity_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' },
],
}
},
{ label => 'remote-temperature', nlabel => 'environment.remote.temperature.celsius', set => {
key_values => [ { name => 'remote_temperature' } ],
output_template => 'remote temperature: %.2f C',
perfdatas => [
{ value => 'remote_temperature_absolute', template => '%.2f',
min => 0, unit => 'C' },
],
}
},
{ label => 'remote-humidity', nlabel => 'environment.remote.humidity.percentage', set => {
key_values => [ { name => 'internal_humidity' } ],
output_template => 'remote humidity: %.2f %%',
perfdatas => [
{ value => 'remote_humidity_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' }, min => 0, max => 100, unit => '%' },
], ],
} }
@ -85,17 +103,18 @@ sub manage_selection {
nothing_quit => 1 nothing_quit => 1
); );
$self->{global} = {}; $self->{global} = {
$self->{global}->{temperature} = defined($snmp_result->{$oids->{upsEnvAmbientTemp}}) && $snmp_result->{$oids->{upsEnvAmbientTemp}} ne '' && $snmp_result->{$oids->{upsEnvAmbientTemp}} != 0 ? internal_temperature => defined($snmp_result->{$oids->{upsEnvAmbientTemp}}) && $snmp_result->{$oids->{upsEnvAmbientTemp}} ne '' && $snmp_result->{$oids->{upsEnvAmbientTemp}} != 0 ?
$snmp_result->{$oids->{upsEnvAmbientTemp}} : $snmp_result->{$oids->{upsEnvAmbientTemp}} : undef,
(defined($snmp_result->{$oids->{upsEnvRemoteTemp}}) && $snmp_result->{$oids->{upsEnvRemoteTemp}} ne '' && $snmp_result->{$oids->{upsEnvRemoteTemp}} != 0 ? internal_humidity => defined($snmp_result->{$oids->{upsEnvAmbientHumidity}}) && $snmp_result->{$oids->{upsEnvAmbientHumidity}} ne '' && $snmp_result->{$oids->{upsEnvAmbientHumidity}} != 0 ?
$snmp_result->{$oids->{upsEnvRemoteTemp}} : undef); $snmp_result->{$oids->{upsEnvAmbientHumidity}} : undef,
$self->{global}->{humidity} = defined($snmp_result->{$oids->{upsEnvAmbientHumidity}}) && $snmp_result->{$oids->{upsEnvAmbientHumidity}} ne '' && $snmp_result->{$oids->{upsEnvAmbientHumidity}} != 0 ? remote_temperature => defined($snmp_result->{$oids->{upsEnvRemoteTemp}}) && $snmp_result->{$oids->{upsEnvRemoteTemp}} ne '' && $snmp_result->{$oids->{upsEnvRemoteTemp}} != 0 ?
$snmp_result->{$oids->{upsEnvAmbientHumidity}} : $snmp_result->{$oids->{upsEnvRemoteTemp}} : undef,
(defined($snmp_result->{$oids->{upsEnvRemoteHumidity}}) && $snmp_result->{$oids->{upsEnvRemoteHumidity}} ne '' && $snmp_result->{$oids->{upsEnvRemoteHumidity}} != 0 ? remote_humidity => defined($snmp_result->{$oids->{upsEnvRemoteHumidity}}) && $snmp_result->{$oids->{upsEnvRemoteHumidity}} ne '' && $snmp_result->{$oids->{upsEnvRemoteHumidity}} != 0 ?
$snmp_result->{$oids->{upsEnvRemoteHumidity}} : undef); $snmp_result->{$oids->{upsEnvRemoteHumidity}} : undef,
};
if (!defined($self->{option_results}->{'critical-environment-ambient-temperature-celsius'}) || $self->{option_results}->{'critical-environment-ambient-temperature-celsius'} eq '') { if (!defined($self->{option_results}->{'critical-environment-internal-temperature-celsius'}) || $self->{option_results}->{'critical-environment-internal-temperature-celsius'} eq '') {
my $crit_val = ''; my $crit_val = '';
$crit_val = $snmp_result->{$oids->{upsEnvAmbientLowerLimit}} . ':' $crit_val = $snmp_result->{$oids->{upsEnvAmbientLowerLimit}} . ':'
if (defined($snmp_result->{$oids->{upsEnvAmbientLowerLimit}}) && if (defined($snmp_result->{$oids->{upsEnvAmbientLowerLimit}}) &&
@ -103,7 +122,18 @@ sub manage_selection {
$crit_val .= $snmp_result->{$oids->{upsEnvAmbientUpperLimit}} $crit_val .= $snmp_result->{$oids->{upsEnvAmbientUpperLimit}}
if (defined($snmp_result->{$oids->{upsEnvAmbientUpperLimit}}) && if (defined($snmp_result->{$oids->{upsEnvAmbientUpperLimit}}) &&
$snmp_result->{$oids->{upsEnvAmbientUpperLimit}} ne '' && $snmp_result->{$oids->{upsEnvAmbientUpperLimit}} != 0); $snmp_result->{$oids->{upsEnvAmbientUpperLimit}} ne '' && $snmp_result->{$oids->{upsEnvAmbientUpperLimit}} != 0);
$self->{perfdata}->threshold_validate(label => 'critical-environment-ambient-temperature-celsius', value => $crit_val); $self->{perfdata}->threshold_validate(label => 'critical-environment-internal-temperature-celsius', value => $crit_val);
}
if (!defined($self->{option_results}->{'critical-environment-remote-temperature-celsius'}) || $self->{option_results}->{'critical-environment-remote-temperature-celsius'} eq '') {
my $crit_val = '';
$crit_val = $snmp_result->{$oids->{upsEnvRemoteTempLowerLimit}} . ':'
if (defined($snmp_result->{$oids->{upsEnvRemoteTempLowerLimit}}) &&
$snmp_result->{$oids->{upsEnvRemoteTempLowerLimit}} ne '' && $snmp_result->{$oids->{upsEnvRemoteTempLowerLimit}} != 0);
$crit_val .= $snmp_result->{$oids->{upsEnvRemoteTempUpperLimit}}
if (defined($snmp_result->{$oids->{upsEnvRemoteTempUpperLimit}}) &&
$snmp_result->{$oids->{upsEnvRemoteTempUpperLimit}} ne '' && $snmp_result->{$oids->{upsEnvRemoteTempUpperLimit}} != 0);
$self->{perfdata}->threshold_validate(label => 'critical-environment-remote-temperature-celsius', value => $crit_val);
} }
} }
@ -119,8 +149,8 @@ Check environment.
=item B<--warning-*> B<--critical-*> =item B<--warning-*> B<--critical-*>
Thresholds. Can be: 'internal-temperature', 'internal-humidity',
Can be: 'temperature', 'humidity'. 'remote-temperature', 'remote-humidity'.
=back =back

View File

@ -33,20 +33,38 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'temperature', set => { { label => 'internal-temperature', nlabel => 'environment.internal.temperature.celsius', set => {
key_values => [ { name => 'temperature' } ], key_values => [ { name => 'internal_temperature' } ],
output_template => 'Ambiant Temperature: %.2f C', output_template => 'internal temperature: %.2f C',
perfdatas => [ perfdatas => [
{ label => 'temperature', value => 'temperature_absolute', template => '%.2f', { label => 'internal_temperature', value => 'internal_temperature_absolute', template => '%.2f',
min => 0, unit => 'C' }, min => 0, unit => 'C' },
], ],
} }
}, },
{ label => 'humidity', set => { { label => 'internal-humidity', nlabel => 'environment.internal.humidity.percentage', set => {
key_values => [ { name => 'humidity' } ], key_values => [ { name => 'internal_humidity' } ],
output_template => 'Humidity: %.2f %%', output_template => 'internal humidity: %.2f %%',
perfdatas => [ perfdatas => [
{ label => 'humidity', value => 'humidity_absolute', template => '%.2f', { label => 'internal_humidity', value => 'internal_humidity_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' },
],
}
},
{ label => 'remote-temperature', nlabel => 'environment.remote.temperature.celsius', set => {
key_values => [ { name => 'remote_temperature' } ],
output_template => 'remote temperature: %.2f C',
perfdatas => [
{ label => 'remote_temperature', value => 'remote_temperature_absolute', template => '%.2f',
min => 0, unit => 'C' },
],
}
},
{ label => 'remote-humidity', nlabel => 'environment.remote.humidity.percentage', set => {
key_values => [ { name => 'internal_humidity' } ],
output_template => 'remote humidity: %.2f %%',
perfdatas => [
{ label => 'remote_humidity', value => 'remote_humidity_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' }, min => 0, max => 100, unit => '%' },
], ],
} }
@ -58,11 +76,10 @@ sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ });
});
return $self; return $self;
} }
@ -81,21 +98,25 @@ sub manage_selection {
xupsEnvRemoteHumidityLowerLimit => '.1.3.6.1.4.1.534.1.6.11.0', xupsEnvRemoteHumidityLowerLimit => '.1.3.6.1.4.1.534.1.6.11.0',
xupsEnvRemoteHumidityUpperLimit => '.1.3.6.1.4.1.534.1.6.11.0', xupsEnvRemoteHumidityUpperLimit => '.1.3.6.1.4.1.534.1.6.11.0',
}; };
my $snmp_result = $options{snmp}->get_leef(oids => [ my $snmp_result = $options{snmp}->get_leef(
values %$oids oids => [
], nothing_quit => 1); values %$oids
],
nothing_quit => 1
);
$self->{global} = {}; $self->{global} = {
$self->{global}->{temperature} = defined($snmp_result->{$oids->{xupsEnvAmbientTemp}}) && $snmp_result->{$oids->{xupsEnvAmbientTemp}} ne '' && $snmp_result->{$oids->{xupsEnvAmbientTemp}} != 0 ? internal_temperature => defined($snmp_result->{$oids->{xupsEnvAmbientTemp}}) && $snmp_result->{$oids->{xupsEnvAmbientTemp}} ne '' && $snmp_result->{$oids->{xupsEnvAmbientTemp}} != 0 ?
$snmp_result->{$oids->{xupsEnvAmbientTemp}} : $snmp_result->{$oids->{xupsEnvAmbientTemp}} : undef,
(defined($snmp_result->{$oids->{xupsEnvRemoteTemp}}) && $snmp_result->{$oids->{xupsEnvRemoteTemp}} ne '' && $snmp_result->{$oids->{xupsEnvRemoteTemp}} != 0 ? internal_humidity => defined($snmp_result->{$oids->{xupsEnvAmbientHumidity}}) && $snmp_result->{$oids->{xupsEnvAmbientHumidity}} ne '' && $snmp_result->{$oids->{xupsEnvAmbientHumidity}} != 0 ?
$snmp_result->{$oids->{xupsEnvRemoteTemp}} : undef); $snmp_result->{$oids->{xupsEnvAmbientHumidity}} : undef,
$self->{global}->{humidity} = defined($snmp_result->{$oids->{xupsEnvAmbientHumidity}}) && $snmp_result->{$oids->{xupsEnvAmbientHumidity}} ne '' && $snmp_result->{$oids->{xupsEnvAmbientHumidity}} != 0 ? remote_temperature => defined($snmp_result->{$oids->{xupsEnvRemoteTemp}}) && $snmp_result->{$oids->{xupsEnvRemoteTemp}} ne '' && $snmp_result->{$oids->{xupsEnvRemoteTemp}} != 0 ?
$snmp_result->{$oids->{xupsEnvAmbientHumidity}} : $snmp_result->{$oids->{xupsEnvRemoteTemp}} : undef,
(defined($snmp_result->{$oids->{xupsEnvRemoteHumidity}}) && $snmp_result->{$oids->{xupsEnvRemoteHumidity}} ne '' && $snmp_result->{$oids->{xupsEnvRemoteHumidity}} != 0 ? remote_humidity => defined($snmp_result->{$oids->{xupsEnvRemoteHumidity}}) && $snmp_result->{$oids->{xupsEnvRemoteHumidity}} ne '' && $snmp_result->{$oids->{xupsEnvRemoteHumidity}} != 0 ?
$snmp_result->{$oids->{xupsEnvRemoteHumidity}} : undef); $snmp_result->{$oids->{xupsEnvRemoteHumidity}} : undef,
};
if (!defined($self->{option_results}->{'critical-temperature'}) || $self->{option_results}->{'critical-temperature'} eq '') { if (!defined($self->{option_results}->{'critical-internal-temperature'}) || $self->{option_results}->{'critical-internal-temperature'} eq '') {
my $crit_val = ''; my $crit_val = '';
$crit_val = $snmp_result->{$oids->{xupsEnvAmbientLowerLimit}} . ':' $crit_val = $snmp_result->{$oids->{xupsEnvAmbientLowerLimit}} . ':'
if (defined($snmp_result->{$oids->{xupsEnvAmbientLowerLimit}}) && if (defined($snmp_result->{$oids->{xupsEnvAmbientLowerLimit}}) &&
@ -103,7 +124,18 @@ sub manage_selection {
$crit_val .= $snmp_result->{$oids->{xupsEnvAmbientUpperLimit}} $crit_val .= $snmp_result->{$oids->{xupsEnvAmbientUpperLimit}}
if (defined($snmp_result->{$oids->{xupsEnvAmbientUpperLimit}}) && if (defined($snmp_result->{$oids->{xupsEnvAmbientUpperLimit}}) &&
$snmp_result->{$oids->{xupsEnvAmbientUpperLimit}} ne '' && $snmp_result->{$oids->{xupsEnvAmbientUpperLimit}} != 0); $snmp_result->{$oids->{xupsEnvAmbientUpperLimit}} ne '' && $snmp_result->{$oids->{xupsEnvAmbientUpperLimit}} != 0);
$self->{perfdata}->threshold_validate(label => 'critical-temperature', value => $crit_val); $self->{perfdata}->threshold_validate(label => 'critical-internal-temperature', value => $crit_val);
}
if (!defined($self->{option_results}->{'critical-remote-temperature'}) || $self->{option_results}->{'critical-remote-temperature'} eq '') {
my $crit_val = '';
$crit_val = $snmp_result->{$oids->{xupsEnvRemoteTempLowerLimit}} . ':'
if (defined($snmp_result->{$oids->{xupsEnvRemoteTempLowerLimit}}) &&
$snmp_result->{$oids->{xupsEnvRemoteTempLowerLimit}} ne '' && $snmp_result->{$oids->{xupsEnvRemoteTempLowerLimit}} != 0);
$crit_val .= $snmp_result->{$oids->{xupsEnvRemoteTempUpperLimit}}
if (defined($snmp_result->{$oids->{xupsEnvRemoteTempUpperLimit}}) &&
$snmp_result->{$oids->{xupsEnvRemoteTempUpperLimit}} ne '' && $snmp_result->{$oids->{xupsEnvRemoteTempUpperLimit}} != 0);
$self->{perfdata}->threshold_validate(label => 'critical-remote-temperature', value => $crit_val);
} }
} }
@ -117,15 +149,11 @@ Check environment (temperature and humidity) (XUPS-MIB).
=over 8 =over 8
=item B<--warning-*> =item B<--warning-*> B<--critical-*>
Threshold warning. Thresholds.
Can be: 'temperature', 'humidity'. Can be: 'internal-temperature', 'internal-humidity',
'remote-temperature', 'remote-humidity'.
=item B<--critical-*>
Threshold critical.
Can be: 'temperature', 'humidity'.
=back =back