| 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::alcatel::omniswitch::snmp::mode::components::chassis; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use network::alcatel::omniswitch::snmp::mode::components::resources qw(%oids $mapping); |
| 26 |
|
| 27 |
sub load {} |
| 28 |
|
| 29 |
sub check_temp_aos6 { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
my $mapping_temp = { |
| 33 |
boardTemp => { oid => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.4', default => -1 }, # chasHardwareBoardTemp |
| 34 |
threshold => { oid => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.7', default => -1 }, # chasTempThreshold |
| 35 |
danger => { oid => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.8', default => -1 } # chasDangerTempThreshold |
| 36 |
}; |
| 37 |
|
| 38 |
my $result = $self->{snmp}->map_instance(mapping => $mapping_temp, results => $self->{results}->{entity}, instance => $options{instance}); |
| 39 |
|
| 40 |
return if ($result->{boardTemp} <= 0); |
| 41 |
|
| 42 |
$self->{output}->output_add( |
| 43 |
long_msg => sprintf( |
| 44 |
"chassis '%s/%s' [instance: %s] board temperature is %s degree centigrade", |
| 45 |
$options{name}, |
| 46 |
$options{descr}, |
| 47 |
$options{instance}, |
| 48 |
$result->{boardTemp} |
| 49 |
) |
| 50 |
); |
| 51 |
|
| 52 |
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $options{instance}, value => $result->{boardTemp}); |
| 53 |
if ($checked == 0) { |
| 54 |
my $warn_th = $result->{threshold} > 0 ? $result->{threshold} : ''; |
| 55 |
my $crit_th = $result->{danger} > 0 ? $result->{danger} : ''; |
| 56 |
|
| 57 |
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $options{instance}, value => $warn_th); |
| 58 |
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $options{instance}, value => $crit_th); |
| 59 |
|
| 60 |
$exit = $self->{perfdata}->threshold_check( |
| 61 |
value => $result->{boardTemp}, |
| 62 |
threshold => [ |
| 63 |
{ label => 'critical-temperature-instance-' . $options{instance}, exit_litteral => 'critical' }, |
| 64 |
{ label => 'warning-temperature-instance-' . $options{instance}, exit_litteral => 'warning' } |
| 65 |
] |
| 66 |
); |
| 67 |
|
| 68 |
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $options{instance}); |
| 69 |
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $options{instance}) |
| 70 |
} |
| 71 |
|
| 72 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 73 |
$self->{output}->output_add( |
| 74 |
severity => $exit, |
| 75 |
short_msg => sprintf( |
| 76 |
"chassis '%s/%s/%s' board temperature is %s degree centigrade", |
| 77 |
$options{name}, |
| 78 |
$options{descr}, |
| 79 |
$options{instance}, |
| 80 |
$result->{boardTemp} |
| 81 |
) |
| 82 |
); |
| 83 |
} |
| 84 |
|
| 85 |
$self->{output}->perfdata_add( |
| 86 |
nlabel => 'hardware.temperature.celsius', |
| 87 |
unit => 'C', |
| 88 |
instances => [$options{name}, $options{descr}, $options{instance}, 'Chassis'], |
| 89 |
value => $result->{boardTemp}, |
| 90 |
warning => $warn, |
| 91 |
critical => $crit |
| 92 |
); |
| 93 |
} |
| 94 |
|
| 95 |
sub check_temp_aos7 { |
| 96 |
my ($self, %options) = @_; |
| 97 |
|
| 98 |
my $mapping_temp = { |
| 99 |
threshold => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.5', default => -1 }, # chasTempThreshold |
| 100 |
danger => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.6', default => -1 }, # chasDangerTempThreshold |
| 101 |
CPMA => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.8', default => -1 }, # chasCPMAHardwareBoardTemp |
| 102 |
CFMA => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.9', default => -1 }, # chasCFMAHardwareBoardTemp |
| 103 |
CPMB => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.10', default => -1 }, # chasCPMBHardwareBoardTemp |
| 104 |
CFMB => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.11', default => -1 }, # chasCFMBHardwareBoardTemp |
| 105 |
CFMC => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.12', default => -1 }, # chasCFMCHardwareBoardTemp |
| 106 |
CFMD => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.13', default => -1 }, # chasCFMDHardwareBoardTemp |
| 107 |
FanTray1 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.14', default => -1 }, # chasFTAHardwareBoardTemp |
| 108 |
FanTray2 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.15', default => -1 }, # chasFTBHardwareBoardTemp |
| 109 |
NI1 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.16', default => -1 }, # chasNI1HardwareBoardTemp |
| 110 |
NI2 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.17', default => -1 }, # chasNI2HardwareBoardTemp |
| 111 |
NI3 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.18', default => -1 }, # chasNI3HardwareBoardTemp |
| 112 |
NI4 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.19', default => -1 }, # chasNI4HardwareBoardTemp |
| 113 |
NI5 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.20', default => -1 }, # chasNI5HardwareBoardTemp |
| 114 |
NI6 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.21', default => -1 }, # chasNI6HardwareBoardTemp |
| 115 |
NI7 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.22', default => -1 }, # chasNI7HardwareBoardTemp |
| 116 |
NI8 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.23', default => -1 } # chasNI8HardwareBoardTemp |
| 117 |
}; |
| 118 |
|
| 119 |
my $result = $self->{snmp}->map_instance(mapping => $mapping_temp, results => $self->{results}->{entity}, instance => $options{instance}); |
| 120 |
|
| 121 |
foreach my $sensor ('CPMA', 'CFMA', 'CPMB', 'CFMB', 'CFMC', 'CFMD', 'FanTray1', 'FanTray2', 'NI1', 'NI2', 'NI3', 'NI4', 'NI5', 'NI6', 'NI7', 'NI8') { |
| 122 |
next if ($result->{$sensor} <= 0); |
| 123 |
|
| 124 |
$self->{output}->output_add( |
| 125 |
long_msg => sprintf( |
| 126 |
"chassis '%s/%s/%s/%s' temperature is %s degree centigrade", |
| 127 |
$options{name}, |
| 128 |
$options{descr}, |
| 129 |
$options{instance}, |
| 130 |
$sensor, |
| 131 |
$result->{$sensor} |
| 132 |
) |
| 133 |
); |
| 134 |
|
| 135 |
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $options{instance}, value => $result->{$sensor}); |
| 136 |
if ($checked == 0) { |
| 137 |
my $warn_th = $result->{threshold} > 0 ? $result->{threshold} : ''; |
| 138 |
my $crit_th = $result->{danger} > 0 ? $result->{danger} : ''; |
| 139 |
|
| 140 |
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $options{instance}, value => $warn_th); |
| 141 |
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $options{instance}, value => $crit_th); |
| 142 |
|
| 143 |
$exit = $self->{perfdata}->threshold_check( |
| 144 |
value => $result->{$sensor}, |
| 145 |
threshold => [ |
| 146 |
{ label => 'critical-temperature-instance-' . $options{instance}, exit_litteral => 'critical' }, |
| 147 |
{ label => 'warning-temperature-instance-' . $options{instance}, exit_litteral => 'warning' } |
| 148 |
] |
| 149 |
); |
| 150 |
|
| 151 |
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $options{instance}); |
| 152 |
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $options{instance}) |
| 153 |
} |
| 154 |
|
| 155 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 156 |
$self->{output}->output_add( |
| 157 |
severity => $exit, |
| 158 |
short_msg => sprintf( |
| 159 |
"chassis '%s/%s/%s/%s' temperature is %s degree centigrade", |
| 160 |
$options{name}, |
| 161 |
$options{descr}, |
| 162 |
$options{instance}, |
| 163 |
$sensor, |
| 164 |
$result->{$sensor} |
| 165 |
) |
| 166 |
); |
| 167 |
} |
| 168 |
|
| 169 |
$self->{output}->perfdata_add( |
| 170 |
nlabel => 'hardware.temperature.celsius', |
| 171 |
unit => 'C', |
| 172 |
instances => [$options{name}, $options{descr}, $options{instance}, $sensor], |
| 173 |
value => $result->{$sensor}, |
| 174 |
warning => $warn, |
| 175 |
critical => $crit |
| 176 |
); |
| 177 |
} |
| 178 |
} |
| 179 |
|
| 180 |
sub check { |
| 181 |
my ($self) = @_; |
| 182 |
|
| 183 |
$self->{output}->output_add(long_msg => "Checking chassis"); |
| 184 |
$self->{components}->{chassis} = {name => 'chassis', total => 0, skip => 0}; |
| 185 |
return if ($self->check_filter(section => 'chassis')); |
| 186 |
|
| 187 |
my @instances = (); |
| 188 |
foreach my $key (keys %{$self->{results}->{ $oids{common}->{entPhysicalClass} }}) { |
| 189 |
if ($self->{results}->{ $oids{common}->{entPhysicalClass} }->{$key} == 3) { |
| 190 |
next if ($key !~ /^$oids{common}->{entPhysicalClass}\.(.*)$/); |
| 191 |
push @instances, $1; |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
foreach my $instance (@instances) { |
| 196 |
next if (!defined($self->{results}->{entity}->{ $oids{ $self->{type} }->{chasEntPhysAdminStatus} . '.' . $instance })); |
| 197 |
|
| 198 |
my $result = $self->{snmp}->map_instance(mapping => $mapping->{ $self->{type} }, results => $self->{results}->{entity}, instance => $instance); |
| 199 |
|
| 200 |
next if ($self->check_filter(section => 'chassis', instance => $instance)); |
| 201 |
$self->{components}->{chassis}->{total}++; |
| 202 |
|
| 203 |
$self->{output}->output_add( |
| 204 |
long_msg => sprintf( |
| 205 |
"chassis '%s/%s' [instance: %s, admin status: %s] operationnal status is %s", |
| 206 |
$result->{entPhysicalName}, |
| 207 |
$result->{entPhysicalDescr}, |
| 208 |
$instance, |
| 209 |
$result->{chasEntPhysAdminStatus}, |
| 210 |
$result->{chasEntPhysOperStatus} |
| 211 |
) |
| 212 |
); |
| 213 |
|
| 214 |
if ($result->{chasEntPhysPower} > 0) { |
| 215 |
$self->{output}->perfdata_add( |
| 216 |
nlabel => 'hardware.chassis.power.watt', |
| 217 |
unit => 'W', |
| 218 |
instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], |
| 219 |
value => $result->{chasEntPhysPower}, |
| 220 |
min => 0 |
| 221 |
); |
| 222 |
} |
| 223 |
|
| 224 |
if ($self->{type} eq 'aos6') { |
| 225 |
check_temp_aos6($self, instance => $instance, name => $result->{entPhysicalName}, descr => $result->{entPhysicalDescr}); |
| 226 |
} else { |
| 227 |
check_temp_aos7($self, instance => $instance, name => $result->{entPhysicalName}, descr => $result->{entPhysicalDescr}); |
| 228 |
} |
| 229 |
|
| 230 |
my $exit = $self->get_severity(label => 'admin', section => 'chassis.admin', value => $result->{chasEntPhysAdminStatus}); |
| 231 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 232 |
$self->{output}->output_add( |
| 233 |
severity => $exit, |
| 234 |
short_msg => sprintf( |
| 235 |
"chassis '%s/%s/%s' admin status is %s", |
| 236 |
$result->{entPhysicalName}, |
| 237 |
$result->{entPhysicalDescr}, |
| 238 |
$instance, |
| 239 |
$result->{chasEntPhysAdminStatus} |
| 240 |
) |
| 241 |
); |
| 242 |
next; |
| 243 |
} |
| 244 |
|
| 245 |
$exit = $self->get_severity(label => 'oper', section => 'chassis.oper', value => $result->{chasEntPhysOperStatus}); |
| 246 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 247 |
$self->{output}->output_add( |
| 248 |
severity => $exit, |
| 249 |
short_msg => sprintf( |
| 250 |
"chassis '%s/%s/%s' operational status is %s", |
| 251 |
$result->{entPhysicalName}, |
| 252 |
$result->{entPhysicalDescr}, |
| 253 |
$instance, |
| 254 |
$result->{chasEntPhysOperStatus} |
| 255 |
) |
| 256 |
); |
| 257 |
} |
| 258 |
} |
| 259 |
} |
| 260 |
|
| 261 |
1; |