| 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::global; |
| 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 |
my %map_agent_status = ( |
| 36 |
1 => 'other', |
| 37 |
2 => 'unknown', |
| 38 |
3 => 'ok', |
| 39 |
4 => 'non-critical', |
| 40 |
5 => 'critical', |
| 41 |
6 => 'non-recoverable', |
| 42 |
); |
| 43 |
|
| 44 |
# In MIB 'ADIC-TAPE-LIBRARY-MIB' |
| 45 |
my $mapping = { |
| 46 |
GlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.1.8', map => \%map_status }, # libraryGlobalStatus |
| 47 |
}; |
| 48 |
# In MIB 'ADIC-INTELLIGENT-STORAGE-MIB' |
| 49 |
my $mapping2 = { |
| 50 |
GlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.1.20.1', map => \%map_agent_status }, # agentGlobalStatus |
| 51 |
}; |
| 52 |
|
| 53 |
sub load { |
| 54 |
my ($self) = @_; |
| 55 |
|
| 56 |
push @{$self->{request}}, { oid => $mapping->{GlobalStatus}->{oid} }, |
| 57 |
{ oid => $mapping2->{GlobalStatus}->{oid} }; |
| 58 |
} |
| 59 |
|
| 60 |
sub check { |
| 61 |
my ($self) = @_; |
| 62 |
|
| 63 |
$self->{output}->output_add(long_msg => "Checking global"); |
| 64 |
$self->{components}->{global} = {name => 'global', total => 0, skip => 0}; |
| 65 |
return if ($self->check_filter(section => 'global')); |
| 66 |
|
| 67 |
my $instance = '0'; |
| 68 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{GlobalStatus}->{oid}}, instance => $instance); |
| 69 |
if (!defined($result->{GlobalStatus})) { |
| 70 |
$result = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{GlobalStatus}->{oid}}, instance => $instance); |
| 71 |
} |
| 72 |
if (!defined($result->{GlobalStatus})) { |
| 73 |
$self->{output}->output_add(long_msg => "skipping global status: no value."); |
| 74 |
return ; |
| 75 |
} |
| 76 |
|
| 77 |
return if ($self->check_filter(section => 'global', instance => $instance)); |
| 78 |
$self->{components}->{global}->{total}++; |
| 79 |
|
| 80 |
$self->{output}->output_add(long_msg => sprintf("library global status is %s [instance: %s].", |
| 81 |
$result->{GlobalStatus}, $instance |
| 82 |
)); |
| 83 |
my $exit = $self->get_severity(section => 'global', label => 'default', value => $result->{GlobalStatus}); |
| 84 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 85 |
$self->{output}->output_add(severity => $exit, |
| 86 |
short_msg => sprintf("Library global status is %s", |
| 87 |
$result->{GlobalStatus})); |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
1; |