| 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 storage::ibm::ts3200::snmp::mode::globalstatus; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::mode); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
my %states = ( |
| 29 |
1 => ['other', 'WARNING'], |
| 30 |
2 => ['unknown', 'WARNING'], |
| 31 |
3 => ['ok', 'OK'], |
| 32 |
4 => ['non critical', 'WARNING'], |
| 33 |
5 => ['critical', 'CRITICAL'], |
| 34 |
6 => ['nonRecoverable', 'WARNING'], |
| 35 |
); |
| 36 |
|
| 37 |
sub new { |
| 38 |
my ($class, %options) = @_; |
| 39 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 40 |
bless $self, $class; |
| 41 |
|
| 42 |
$options{options}->add_options(arguments => |
| 43 |
{ |
| 44 |
"threshold-overload:s@" => { name => 'threshold_overload' }, |
| 45 |
}); |
| 46 |
|
| 47 |
return $self; |
| 48 |
} |
| 49 |
|
| 50 |
sub check_threshold_overload { |
| 51 |
my ($self, %options) = @_; |
| 52 |
|
| 53 |
$self->{overload_th} = {}; |
| 54 |
foreach my $val (@{$self->{option_results}->{threshold_overload}}) { |
| 55 |
if ($val !~ /(.*?)=(.*)/) { |
| 56 |
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); |
| 57 |
$self->{output}->option_exit(); |
| 58 |
} |
| 59 |
my ($filter, $threshold) = ($1, $2); |
| 60 |
if ($self->{output}->is_litteral_status(status => $threshold) == 0) { |
| 61 |
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); |
| 62 |
$self->{output}->option_exit(); |
| 63 |
} |
| 64 |
$self->{overload_th}->{$filter} = $threshold; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
sub check_options { |
| 69 |
my ($self, %options) = @_; |
| 70 |
$self->SUPER::init(%options); |
| 71 |
$self->check_threshold_overload(); |
| 72 |
} |
| 73 |
|
| 74 |
sub get_severity { |
| 75 |
my ($self, %options) = @_; |
| 76 |
my $status = ${$states{$options{value}}}[1]; |
| 77 |
|
| 78 |
foreach (keys %{$self->{overload_th}}) { |
| 79 |
if (${$states{$options{value}}}[0] =~ /$_/) { |
| 80 |
$status = $self->{overload_th}->{$_}; |
| 81 |
} |
| 82 |
} |
| 83 |
return $status; |
| 84 |
} |
| 85 |
|
| 86 |
sub run { |
| 87 |
my ($self, %options) = @_; |
| 88 |
$self->{snmp} = $options{snmp}; |
| 89 |
|
| 90 |
my $oid_ibm3200StatusGlobalStatus = '.1.3.6.1.4.1.2.6.211.2.1.0'; |
| 91 |
my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3200StatusGlobalStatus], nothing_quit => 1); |
| 92 |
|
| 93 |
$self->{output}->output_add(severity => $self->get_severity(value => $result->{$oid_ibm3200StatusGlobalStatus}), |
| 94 |
short_msg => sprintf("Overall global status is '%s'.", |
| 95 |
${$states{$result->{$oid_ibm3200StatusGlobalStatus}}}[0])); |
| 96 |
$self->{output}->display(); |
| 97 |
$self->{output}->exit(); |
| 98 |
} |
| 99 |
|
| 100 |
1; |
| 101 |
|
| 102 |
__END__ |
| 103 |
|
| 104 |
=head1 MODE |
| 105 |
|
| 106 |
Check the overall status of the appliance. |
| 107 |
|
| 108 |
=over 8 |
| 109 |
|
| 110 |
=item B<--threshold-overload> |
| 111 |
|
| 112 |
Set to overload default threshold value. |
| 113 |
Example: --threshold-overload='(unknown|non critical)=critical' |
| 114 |
|
| 115 |
=back |
| 116 |
|
| 117 |
=cut |
| 118 |
|