| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package hardware::ups::powerware::snmp::mode::environment; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub set_counters { |
| 29 |
my ($self, %options) = @_; |
| 30 |
|
| 31 |
$self->{maps_counters_type} = [ |
| 32 |
{ name => 'global', type => 0, skipped_code => { -10 => 1 } } |
| 33 |
]; |
| 34 |
|
| 35 |
$self->{maps_counters}->{global} = [ |
| 36 |
{ label => 'internal-temperature', nlabel => 'environment.internal.temperature.celsius', set => { |
| 37 |
key_values => [ { name => 'internal_temperature' } ], |
| 38 |
output_template => 'internal temperature: %.2f C', |
| 39 |
perfdatas => [ |
| 40 |
{ label => 'internal_temperature', value => 'internal_temperature', template => '%.2f', |
| 41 |
min => 0, unit => 'C' }, |
| 42 |
], |
| 43 |
} |
| 44 |
}, |
| 45 |
{ label => 'internal-humidity', nlabel => 'environment.internal.humidity.percentage', set => { |
| 46 |
key_values => [ { name => 'internal_humidity' } ], |
| 47 |
output_template => 'internal humidity: %.2f %%', |
| 48 |
perfdatas => [ |
| 49 |
{ label => 'internal_humidity', value => 'internal_humidity', template => '%.2f', |
| 50 |
min => 0, max => 100, unit => '%' }, |
| 51 |
], |
| 52 |
} |
| 53 |
}, |
| 54 |
{ label => 'remote-temperature', nlabel => 'environment.remote.temperature.celsius', set => { |
| 55 |
key_values => [ { name => 'remote_temperature' } ], |
| 56 |
output_template => 'remote temperature: %.2f C', |
| 57 |
perfdatas => [ |
| 58 |
{ label => 'remote_temperature', value => 'remote_temperature', template => '%.2f', |
| 59 |
min => 0, unit => 'C' }, |
| 60 |
], |
| 61 |
} |
| 62 |
}, |
| 63 |
{ label => 'remote-humidity', nlabel => 'environment.remote.humidity.percentage', set => { |
| 64 |
key_values => [ { name => 'remote_humidity' } ], |
| 65 |
output_template => 'remote humidity: %.2f %%', |
| 66 |
perfdatas => [ |
| 67 |
{ label => 'remote_humidity', value => 'remote_humidity', template => '%.2f', |
| 68 |
min => 0, max => 100, unit => '%' }, |
| 69 |
], |
| 70 |
} |
| 71 |
}, |
| 72 |
]; |
| 73 |
} |
| 74 |
|
| 75 |
sub new { |
| 76 |
my ($class, %options) = @_; |
| 77 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 78 |
bless $self, $class; |
| 79 |
|
| 80 |
$options{options}->add_options(arguments => { |
| 81 |
}); |
| 82 |
|
| 83 |
return $self; |
| 84 |
} |
| 85 |
|
| 86 |
sub manage_selection { |
| 87 |
my ($self, %options) = @_; |
| 88 |
|
| 89 |
my $oids = { |
| 90 |
xupsEnvAmbientTemp => '.1.3.6.1.4.1.534.1.6.1.0', |
| 91 |
xupsEnvAmbientLowerLimit => '.1.3.6.1.4.1.534.1.6.2.0', |
| 92 |
xupsEnvAmbientUpperLimit => '.1.3.6.1.4.1.534.1.6.3.0', |
| 93 |
xupsEnvAmbientHumidity => '.1.3.6.1.4.1.534.1.6.4.0', |
| 94 |
xupsEnvRemoteTemp => '.1.3.6.1.4.1.534.1.6.5.0', |
| 95 |
xupsEnvRemoteHumidity => '.1.3.6.1.4.1.534.1.6.6.0', |
| 96 |
xupsEnvRemoteTempLowerLimit => '.1.3.6.1.4.1.534.1.6.9.0', |
| 97 |
xupsEnvRemoteTempUpperLimit => '.1.3.6.1.4.1.534.1.6.10.0', |
| 98 |
xupsEnvRemoteHumidityLowerLimit => '.1.3.6.1.4.1.534.1.6.11.0', |
| 99 |
xupsEnvRemoteHumidityUpperLimit => '.1.3.6.1.4.1.534.1.6.11.0', |
| 100 |
}; |
| 101 |
my $snmp_result = $options{snmp}->get_leef( |
| 102 |
oids => [ |
| 103 |
values %$oids |
| 104 |
], |
| 105 |
nothing_quit => 1 |
| 106 |
); |
| 107 |
|
| 108 |
$self->{global} = { |
| 109 |
internal_temperature => defined($snmp_result->{$oids->{xupsEnvAmbientTemp}}) && $snmp_result->{$oids->{xupsEnvAmbientTemp}} ne '' && $snmp_result->{$oids->{xupsEnvAmbientTemp}} != 0 ? |
| 110 |
$snmp_result->{$oids->{xupsEnvAmbientTemp}} : undef, |
| 111 |
internal_humidity => defined($snmp_result->{$oids->{xupsEnvAmbientHumidity}}) && $snmp_result->{$oids->{xupsEnvAmbientHumidity}} ne '' && $snmp_result->{$oids->{xupsEnvAmbientHumidity}} != 0 ? |
| 112 |
$snmp_result->{$oids->{xupsEnvAmbientHumidity}} : undef, |
| 113 |
remote_temperature => defined($snmp_result->{$oids->{xupsEnvRemoteTemp}}) && $snmp_result->{$oids->{xupsEnvRemoteTemp}} ne '' && $snmp_result->{$oids->{xupsEnvRemoteTemp}} != 0 ? |
| 114 |
$snmp_result->{$oids->{xupsEnvRemoteTemp}} : undef, |
| 115 |
remote_humidity => defined($snmp_result->{$oids->{xupsEnvRemoteHumidity}}) && $snmp_result->{$oids->{xupsEnvRemoteHumidity}} ne '' && $snmp_result->{$oids->{xupsEnvRemoteHumidity}} != 0 ? |
| 116 |
$snmp_result->{$oids->{xupsEnvRemoteHumidity}} : undef, |
| 117 |
}; |
| 118 |
|
| 119 |
if (!defined($self->{option_results}->{'critical-internal-temperature'}) || $self->{option_results}->{'critical-internal-temperature'} eq '') { |
| 120 |
my $crit_val = ''; |
| 121 |
$crit_val = $snmp_result->{$oids->{xupsEnvAmbientLowerLimit}} . ':' |
| 122 |
if (defined($snmp_result->{$oids->{xupsEnvAmbientLowerLimit}}) && |
| 123 |
$snmp_result->{$oids->{xupsEnvAmbientLowerLimit}} ne '' && $snmp_result->{$oids->{xupsEnvAmbientLowerLimit}} != 0); |
| 124 |
$crit_val .= $snmp_result->{$oids->{xupsEnvAmbientUpperLimit}} |
| 125 |
if (defined($snmp_result->{$oids->{xupsEnvAmbientUpperLimit}}) && |
| 126 |
$snmp_result->{$oids->{xupsEnvAmbientUpperLimit}} ne '' && $snmp_result->{$oids->{xupsEnvAmbientUpperLimit}} != 0); |
| 127 |
$self->{perfdata}->threshold_validate(label => 'critical-internal-temperature', value => $crit_val); |
| 128 |
} |
| 129 |
|
| 130 |
if (!defined($self->{option_results}->{'critical-remote-temperature'}) || $self->{option_results}->{'critical-remote-temperature'} eq '') { |
| 131 |
my $crit_val = ''; |
| 132 |
$crit_val = $snmp_result->{$oids->{xupsEnvRemoteTempLowerLimit}} . ':' |
| 133 |
if (defined($snmp_result->{$oids->{xupsEnvRemoteTempLowerLimit}}) && |
| 134 |
$snmp_result->{$oids->{xupsEnvRemoteTempLowerLimit}} ne '' && $snmp_result->{$oids->{xupsEnvRemoteTempLowerLimit}} != 0); |
| 135 |
$crit_val .= $snmp_result->{$oids->{xupsEnvRemoteTempUpperLimit}} |
| 136 |
if (defined($snmp_result->{$oids->{xupsEnvRemoteTempUpperLimit}}) && |
| 137 |
$snmp_result->{$oids->{xupsEnvRemoteTempUpperLimit}} ne '' && $snmp_result->{$oids->{xupsEnvRemoteTempUpperLimit}} != 0); |
| 138 |
$self->{perfdata}->threshold_validate(label => 'critical-remote-temperature', value => $crit_val); |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
1; |
| 143 |
|
| 144 |
__END__ |
| 145 |
|
| 146 |
=head1 MODE |
| 147 |
|
| 148 |
Check environment (temperature and humidity) (XUPS-MIB). |
| 149 |
|
| 150 |
=over 8 |
| 151 |
|
| 152 |
=item B<--warning-*> B<--critical-*> |
| 153 |
|
| 154 |
Thresholds. |
| 155 |
Can be: 'internal-temperature', 'internal-humidity', |
| 156 |
'remote-temperature', 'remote-humidity'. |
| 157 |
|
| 158 |
=back |
| 159 |
|
| 160 |
=cut |