| 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 centreon::common::adic::tape::snmp::mode::components::subsystem; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_status = ( |
| 27 |
1 => 'good', |
| 28 |
2 => 'failed', |
| 29 |
3 => 'degraded', |
| 30 |
4 => 'warning', |
| 31 |
5 => 'informational', |
| 32 |
6 => 'unknown', |
| 33 |
7 => 'invalid', |
| 34 |
); |
| 35 |
|
| 36 |
# In MIB 'ADIC-TAPE-LIBRARY-MIB' |
| 37 |
my $mapping = { |
| 38 |
powerStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.1', map => \%map_status, label => 'power', instance => 1 }, |
| 39 |
coolingStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.2', map => \%map_status, label => 'cooling', instance => 2 }, |
| 40 |
controlStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.3', map => \%map_status, label => 'control', instance => 3 }, |
| 41 |
connectivityStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.4', map => \%map_status, label => 'connectivity', instance => 4 }, |
| 42 |
roboticsStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.5', map => \%map_status, label => 'robotics', instance => 5 }, |
| 43 |
mediaStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.6', map => \%map_status, label => 'media', instance => 6 }, |
| 44 |
driveStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.6', map => \%map_status, label => 'drive', instance => 7 }, |
| 45 |
}; |
| 46 |
my $oid_rasSubSystem = '.1.3.6.1.4.1.3764.1.10.10.12'; |
| 47 |
|
| 48 |
sub load { |
| 49 |
my ($self) = @_; |
| 50 |
|
| 51 |
push @{$self->{request}}, { oid => $oid_rasSubSystem }; |
| 52 |
} |
| 53 |
|
| 54 |
sub check { |
| 55 |
my ($self) = @_; |
| 56 |
|
| 57 |
$self->{output}->output_add(long_msg => "Checking subsystems"); |
| 58 |
$self->{components}->{subsystem} = {name => 'subsystems', total => 0, skip => 0}; |
| 59 |
return if ($self->check_filter(section => 'subsystem')); |
| 60 |
|
| 61 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rasSubSystem}, instance => '0'); |
| 62 |
foreach my $name (keys %$mapping) { |
| 63 |
if (!defined($result->{$name})) { |
| 64 |
$self->{output}->output_add(long_msg => sprintf("skipping %s status: no value.", $mapping->{$name}->{label})); |
| 65 |
next; |
| 66 |
} |
| 67 |
|
| 68 |
next if ($self->check_filter(section => 'subsystem', instance => $mapping->{$name}->{instance})); |
| 69 |
$self->{components}->{subsystem}->{total}++; |
| 70 |
|
| 71 |
$self->{output}->output_add(long_msg => sprintf("%s status is %s [instance: %s].", |
| 72 |
$mapping->{$name}->{label}, $result->{$name}, |
| 73 |
$mapping->{$name}->{instance} |
| 74 |
)); |
| 75 |
my $exit = $self->get_severity(section => 'subsystem', label => 'default', value => $result->{$name}); |
| 76 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 77 |
$self->{output}->output_add(severity => $exit, |
| 78 |
short_msg => sprintf("%s status is %s", |
| 79 |
ucfirst($mapping->{$name}->{label}), $result->{$name})); |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
1; |