| 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 network::radware::alteon::snmp::mode::hardware; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::hardware); |
| 24 |
|
| 25 |
sub set_system { |
| 26 |
my ($self, %options) = @_; |
| 27 |
|
| 28 |
$self->{cb_hook2} = 'snmp_execute'; |
| 29 |
|
| 30 |
$self->{thresholds} = { |
| 31 |
cpu => [ |
| 32 |
['normal', 'OK'], |
| 33 |
['warning', 'WARNING'], |
| 34 |
['critical', 'CRITICAL'], |
| 35 |
], |
| 36 |
psu => [ |
| 37 |
['singlePowerSupplyOk', 'OK'], |
| 38 |
['firstPowerSupplyFailed', 'CRITICAL'], |
| 39 |
['secondPowerSupplyFailed', 'CRITICAL'], |
| 40 |
['doublePowerSupplyOk', 'OK'], |
| 41 |
['unknownPowerSupplyFailed', 'UNKNOWN'], |
| 42 |
], |
| 43 |
temperature => [ |
| 44 |
['ok', 'OK'], |
| 45 |
['exceed', 'WARNING'], |
| 46 |
], |
| 47 |
fan => [ |
| 48 |
['ok', 'OK'], |
| 49 |
['fail', 'CRITICAL'], |
| 50 |
], |
| 51 |
}; |
| 52 |
|
| 53 |
$self->{components_path} = 'network::radware::alteon::snmp::mode::components'; |
| 54 |
$self->{components_module} = ['cpu', 'temperature', 'psu', 'fan']; |
| 55 |
} |
| 56 |
|
| 57 |
sub new { |
| 58 |
my ($class, %options) = @_; |
| 59 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1, no_load_components => 1); |
| 60 |
bless $self, $class; |
| 61 |
|
| 62 |
$options{options}->add_options(arguments => {}); |
| 63 |
|
| 64 |
return $self; |
| 65 |
} |
| 66 |
|
| 67 |
sub snmp_execute { |
| 68 |
my ($self, %options) = @_; |
| 69 |
|
| 70 |
$self->{snmp} = $options{snmp}; |
| 71 |
$self->{results} = $self->{snmp}->get_leef(oids => $self->{request}); |
| 72 |
} |
| 73 |
|
| 74 |
1; |
| 75 |
|
| 76 |
=head1 MODE |
| 77 |
|
| 78 |
Check hardware (ALTEON-CHEETAH-SWITCH-MIB). |
| 79 |
|
| 80 |
=over 8 |
| 81 |
|
| 82 |
=item B<--component> |
| 83 |
|
| 84 |
Which component to check (default: '.*'). |
| 85 |
Can be: 'cpu', 'temperature', 'psu', 'fan'. |
| 86 |
|
| 87 |
=item B<--filter> |
| 88 |
|
| 89 |
Exclude some parts (comma separated list) |
| 90 |
You can also exclude items from specific instances: --filter=cpu,1 |
| 91 |
|
| 92 |
=item B<--no-component> |
| 93 |
|
| 94 |
Define the expected status if no components are found (default: critical). |
| 95 |
|
| 96 |
|
| 97 |
=item B<--threshold-overload> |
| 98 |
|
| 99 |
Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp). |
| 100 |
Example: --threshold-overload='psu,OK,unknownPowerSupplyFailed' |
| 101 |
|
| 102 |
=back |
| 103 |
|
| 104 |
=cut |
| 105 |
|
| 106 |
package network::radware::alteon::snmp::mode::components::cpu; |
| 107 |
|
| 108 |
use strict; |
| 109 |
use warnings; |
| 110 |
|
| 111 |
my %map_cpu_status = (1 => 'normal', 2 => 'warning', 3 => 'critical'); |
| 112 |
|
| 113 |
my $mapping_cpu = { |
| 114 |
hwTemperatureThresholdStatusCPU1Get => { oid => '.1.3.6.1.4.1.1872.2.5.1.3.1.28.3', map => \%map_cpu_status }, |
| 115 |
hwTemperatureThresholdStatusCPU2Get => { oid => '.1.3.6.1.4.1.1872.2.5.1.3.1.28.4', map => \%map_cpu_status }, |
| 116 |
}; |
| 117 |
|
| 118 |
sub load { |
| 119 |
my ($self) = @_; |
| 120 |
|
| 121 |
push @{$self->{request}}, $mapping_cpu->{hwTemperatureThresholdStatusCPU1Get}->{oid} . '.0', $mapping_cpu->{hwTemperatureThresholdStatusCPU2Get}->{oid} . '.0'; |
| 122 |
} |
| 123 |
|
| 124 |
sub check_cpu { |
| 125 |
my ($self, %options) = @_; |
| 126 |
|
| 127 |
return if (!defined($options{status})); |
| 128 |
return if ($self->check_filter(section => 'cpu', instance => $options{instance})); |
| 129 |
|
| 130 |
$self->{components}->{cpu}->{total}++; |
| 131 |
$self->{output}->output_add(long_msg => sprintf("cpu '%s' status is '%s' [instance = %s]", |
| 132 |
$options{instance}, $options{status}, $options{instance})); |
| 133 |
my $exit = $self->get_severity(section => 'cpu', value => $options{status}); |
| 134 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 135 |
$self->{output}->output_add(severity => $exit, |
| 136 |
short_msg => sprintf("Cpu '%s' status is '%s'", $options{instance}, $options{status})); |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
sub check { |
| 141 |
my ($self) = @_; |
| 142 |
|
| 143 |
$self->{output}->output_add(long_msg => "Checking cpu"); |
| 144 |
$self->{components}->{cpu} = {name => 'cpu', total => 0, skip => 0}; |
| 145 |
return if ($self->check_filter(section => 'cpu')); |
| 146 |
|
| 147 |
my $result = $self->{snmp}->map_instance(mapping => $mapping_cpu, results => $self->{results}, instance => '0'); |
| 148 |
|
| 149 |
check_cpu($self, status => $result->{hwTemperatureThresholdStatusCPU1Get}, instance => 1); |
| 150 |
check_cpu($self, status => $result->{hwTemperatureThresholdStatusCPU2Get}, instance => 2); |
| 151 |
} |
| 152 |
|
| 153 |
1; |
| 154 |
|
| 155 |
package network::radware::alteon::snmp::mode::components::fan; |
| 156 |
|
| 157 |
use strict; |
| 158 |
use warnings; |
| 159 |
|
| 160 |
my %map_fan_status = (1 => 'ok', 2 => 'fail'); |
| 161 |
|
| 162 |
my $mapping_fan = { |
| 163 |
hwFanStatus => { oid => '.1.3.6.1.4.1.1872.2.5.1.3.1.4', map => \%map_fan_status }, |
| 164 |
}; |
| 165 |
|
| 166 |
sub load { |
| 167 |
my ($self) = @_; |
| 168 |
|
| 169 |
push @{$self->{request}}, $mapping_fan->{hwFanStatus}->{oid} . '.0'; |
| 170 |
} |
| 171 |
|
| 172 |
sub check { |
| 173 |
my ($self) = @_; |
| 174 |
|
| 175 |
$self->{output}->output_add(long_msg => "Checking fans"); |
| 176 |
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; |
| 177 |
return if ($self->check_filter(section => 'fan')); |
| 178 |
|
| 179 |
my $result = $self->{snmp}->map_instance(mapping => $mapping_fan, results => $self->{results}, instance => '0'); |
| 180 |
|
| 181 |
return if (!defined($result->{hwFanStatus})); |
| 182 |
$self->{components}->{fan}->{total}++; |
| 183 |
$self->{output}->output_add(long_msg => sprintf("fan status is '%s' [instance = %s]", |
| 184 |
$result->{hwFanStatus}, '0')); |
| 185 |
my $exit = $self->get_severity(section => 'fan', value => $result->{hwFanStatus}); |
| 186 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 187 |
$self->{output}->output_add(severity => $exit, |
| 188 |
short_msg => sprintf("Fan status is '%s'", $result->{hwFanStatus})); |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
1; |
| 193 |
|
| 194 |
package network::radware::alteon::snmp::mode::components::temperature; |
| 195 |
|
| 196 |
use strict; |
| 197 |
use warnings; |
| 198 |
|
| 199 |
my %map_temp_status = (1 => 'ok', 2 => 'exceed'); |
| 200 |
|
| 201 |
my $mapping_temp = { |
| 202 |
hwTemperatureStatus => { oid => '.1.3.6.1.4.1.1872.2.5.1.3.1.3', map => \%map_temp_status }, |
| 203 |
}; |
| 204 |
|
| 205 |
sub load { |
| 206 |
my ($self) = @_; |
| 207 |
|
| 208 |
push @{$self->{request}}, $mapping_temp->{hwTemperatureStatus}->{oid} . '.0'; |
| 209 |
} |
| 210 |
|
| 211 |
sub check { |
| 212 |
my ($self) = @_; |
| 213 |
|
| 214 |
$self->{output}->output_add(long_msg => "Checking temperature"); |
| 215 |
$self->{components}->{temperature} = {name => 'temperature', total => 0, skip => 0}; |
| 216 |
return if ($self->check_filter(section => 'temperature')); |
| 217 |
|
| 218 |
my $result = $self->{snmp}->map_instance(mapping => $mapping_temp, results => $self->{results}, instance => '0'); |
| 219 |
|
| 220 |
return if (!defined($result->{hwTemperatureStatus})); |
| 221 |
$self->{components}->{temperature}->{total}++; |
| 222 |
$self->{output}->output_add(long_msg => sprintf("temperature status is '%s' [instance = %s]", |
| 223 |
$result->{hwTemperatureStatus}, '0')); |
| 224 |
my $exit = $self->get_severity(section => 'temperature', value => $result->{hwTemperatureStatus}); |
| 225 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 226 |
$self->{output}->output_add(severity => $exit, |
| 227 |
short_msg => sprintf("Temperature status is '%s'", $result->{hwTemperatureStatus})); |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
1; |
| 232 |
|
| 233 |
package network::radware::alteon::snmp::mode::components::psu; |
| 234 |
|
| 235 |
use strict; |
| 236 |
use warnings; |
| 237 |
|
| 238 |
my %map_psu_status = (1 => 'singlePowerSupplyOk', |
| 239 |
2 => 'firstPowerSupplyFailed', 3 => 'secondPowerSupplyFailed', 4 => 'doublePowerSupplyOk', |
| 240 |
5 => 'unknownPowerSupplyFailed' |
| 241 |
); |
| 242 |
|
| 243 |
my $mapping_psu = { |
| 244 |
hwPowerSupplyStatus => { oid => '.1.3.6.1.4.1.1872.2.5.1.3.1.29.2', map => \%map_psu_status }, |
| 245 |
}; |
| 246 |
|
| 247 |
sub load { |
| 248 |
my ($self) = @_; |
| 249 |
|
| 250 |
push @{$self->{request}}, $mapping_psu->{hwPowerSupplyStatus}->{oid} . '.0'; |
| 251 |
} |
| 252 |
|
| 253 |
sub check { |
| 254 |
my ($self) = @_; |
| 255 |
|
| 256 |
$self->{output}->output_add(long_msg => "Checking psus"); |
| 257 |
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; |
| 258 |
return if ($self->check_filter(section => 'psu')); |
| 259 |
|
| 260 |
my $result = $self->{snmp}->map_instance(mapping => $mapping_psu, results => $self->{results}, instance => '0'); |
| 261 |
|
| 262 |
return if (!defined($result->{hwPowerSupplyStatus})); |
| 263 |
$self->{components}->{psu}->{total}++; |
| 264 |
$self->{output}->output_add(long_msg => sprintf("power supply status is '%s' [instance = %s]", |
| 265 |
$result->{hwPowerSupplyStatus}, '0')); |
| 266 |
my $exit = $self->get_severity(section => 'psu', value => $result->{hwPowerSupplyStatus}); |
| 267 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 268 |
$self->{output}->output_add(severity => $exit, |
| 269 |
short_msg => sprintf("Power supply status is '%s'", $result->{hwPowerSupplyStatus})); |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
1; |
| 274 |
|