| 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::cisco::firepower::fxos::snmp::mode::components::chassis; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use network::cisco::firepower::fxos::snmp::mode::components::resources qw($map_operability); |
| 26 |
|
| 27 |
my $mapping = { |
| 28 |
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.20.21.1.2' }, # cfprEquipmentChassisDn |
| 29 |
operability => { oid => '.1.3.6.1.4.1.9.9.826.1.20.21.1.31', map => $map_operability } # cfprEquipmentChassisOperability |
| 30 |
}; |
| 31 |
my $mapping_stats = { |
| 32 |
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.20.26.1.2' }, # cfprEquipmentChassisStatsDn |
| 33 |
input_power => { oid => '.1.3.6.1.4.1.9.9.826.1.20.26.1.5' }, # cfprEquipmentChassisStatsInputPowerAvg |
| 34 |
output_power => { oid => '.1.3.6.1.4.1.9.9.826.1.20.26.1.10' } # cfprEquipmentChassisStatsOutputPowerAvg |
| 35 |
}; |
| 36 |
|
| 37 |
sub load { |
| 38 |
my ($self) = @_; |
| 39 |
|
| 40 |
push @{$self->{request}}, map({ oid => $_->{oid} }, values(%$mapping), values(%$mapping_stats)); |
| 41 |
} |
| 42 |
|
| 43 |
sub check { |
| 44 |
my ($self) = @_; |
| 45 |
|
| 46 |
$self->{output}->output_add(long_msg => "checking chassis"); |
| 47 |
$self->{components}->{chassis} = { name => 'chassis', total => 0, skip => 0 }; |
| 48 |
return if ($self->check_filter(section => 'chassis')); |
| 49 |
|
| 50 |
my $results = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping)) }; |
| 51 |
my $results_stats = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping_stats)) }; |
| 52 |
|
| 53 |
my ($exit, $warn, $crit, $checked); |
| 54 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$results)) { |
| 55 |
next if ($oid !~ /^$mapping->{operability}->{oid}\.(.*)$/); |
| 56 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $1); |
| 57 |
|
| 58 |
next if ($self->check_filter(section => 'chassis', instance => $result->{dn})); |
| 59 |
$self->{components}->{chassis}->{total}++; |
| 60 |
|
| 61 |
my $result_stats = $self->compare_dn( |
| 62 |
regexp => "^$result->{dn}/", |
| 63 |
lookup => 'dn', |
| 64 |
results => $results_stats, |
| 65 |
mapping => $mapping_stats |
| 66 |
); |
| 67 |
|
| 68 |
$self->{output}->output_add( |
| 69 |
long_msg => sprintf( |
| 70 |
"chassis '%s' status is '%s' [input power: %s W, output power: %s W].", |
| 71 |
$result->{dn}, |
| 72 |
$result->{operability}, |
| 73 |
$result_stats->{input_power}, |
| 74 |
$result_stats->{output_power}, |
| 75 |
) |
| 76 |
); |
| 77 |
$exit = $self->get_severity(label => 'operability', section => 'chassis', instance => $result->{dn}, value => $result->{operability}); |
| 78 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 79 |
$self->{output}->output_add( |
| 80 |
severity => $exit, |
| 81 |
short_msg => sprintf( |
| 82 |
"chassis '%s' status is '%s'", |
| 83 |
$result->{dn}, |
| 84 |
$result->{operability} |
| 85 |
) |
| 86 |
); |
| 87 |
} |
| 88 |
|
| 89 |
foreach (('input', 'output')) { |
| 90 |
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'chassis.' . $_ . 'power', instance => $result->{dn}, value => $result_stats->{$_ . '_power'}); |
| 91 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 92 |
$self->{output}->output_add( |
| 93 |
severity => $exit, |
| 94 |
short_msg => sprintf( |
| 95 |
"chassis '%s' %s power is %s W", |
| 96 |
$result->{dn}, |
| 97 |
$result_stats->{$_ . '_power'} |
| 98 |
) |
| 99 |
); |
| 100 |
} |
| 101 |
$self->{output}->perfdata_add( |
| 102 |
nlabel => 'hardware.chassis.' . $_ . '.power.watt', |
| 103 |
unit => 'W', |
| 104 |
instances => $result->{dn}, |
| 105 |
value => $result_stats->{$_ . '_power'}, |
| 106 |
warning => $warn, |
| 107 |
critical => $crit |
| 108 |
); |
| 109 |
} |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
1; |