| 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::avid::isis::snmp::mode::status; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); |
| 28 |
|
| 29 |
sub custom_status_output { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
my $msg = sprintf("System Director state is '%s'", $self->{result_values}->{status}); |
| 33 |
return $msg; |
| 34 |
} |
| 35 |
|
| 36 |
sub custom_status_calc { |
| 37 |
my ($self, %options) = @_; |
| 38 |
|
| 39 |
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_SystemDirectorState'}; |
| 40 |
return 0; |
| 41 |
} |
| 42 |
|
| 43 |
sub set_counters { |
| 44 |
my ($self, %options) = @_; |
| 45 |
|
| 46 |
$self->{maps_counters_type} = [ |
| 47 |
{ name => 'global', type => 0, message_separator => ' - ' }, |
| 48 |
]; |
| 49 |
|
| 50 |
$self->{maps_counters}->{global} = [ |
| 51 |
{ label => 'status', set => { |
| 52 |
key_values => [ { name => 'SystemDirectorState' } ], |
| 53 |
closure_custom_calc => $self->can('custom_status_calc'), |
| 54 |
closure_custom_output => $self->can('custom_status_output'), |
| 55 |
closure_custom_perfdata => sub { return 0; }, |
| 56 |
closure_custom_threshold_check => \&catalog_status_threshold, |
| 57 |
} |
| 58 |
}, |
| 59 |
{ label => 'redistributing-count', set => { |
| 60 |
key_values => [ { name => 'WorkspaceRedistributingCount' } ], |
| 61 |
output_template => 'Workspace redistributing count: %d', |
| 62 |
perfdatas => [ |
| 63 |
{ label => 'redistributing_count', value => 'WorkspaceRedistributingCount', |
| 64 |
template => '%d', min => 0 }, |
| 65 |
], |
| 66 |
} |
| 67 |
}, |
| 68 |
]; |
| 69 |
} |
| 70 |
|
| 71 |
sub new { |
| 72 |
my ($class, %options) = @_; |
| 73 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 74 |
bless $self, $class; |
| 75 |
|
| 76 |
$options{options}->add_options(arguments => { |
| 77 |
"warning-status:s" => { name => 'warning_status', default => '' }, |
| 78 |
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /Online/i' }, |
| 79 |
}); |
| 80 |
|
| 81 |
return $self; |
| 82 |
} |
| 83 |
|
| 84 |
sub check_options { |
| 85 |
my ($self, %options) = @_; |
| 86 |
$self->SUPER::check_options(%options); |
| 87 |
|
| 88 |
$self->change_macros(macros => ['warning_status', 'critical_status']); |
| 89 |
} |
| 90 |
|
| 91 |
my %map_status = ( |
| 92 |
0 => 'Online', |
| 93 |
1 => 'Offline', |
| 94 |
2 => 'Standby', |
| 95 |
3 => 'Unknown', |
| 96 |
); |
| 97 |
|
| 98 |
my $oid_SystemDirectorState = '.1.3.6.1.4.1.526.20.2.1.0'; |
| 99 |
my $oid_WorkspaceRedistributingCount = '.1.3.6.1.4.1.526.20.2.4.0'; |
| 100 |
|
| 101 |
sub manage_selection { |
| 102 |
my ($self, %options) = @_; |
| 103 |
|
| 104 |
my $results = $options{snmp}->get_leef(oids => [ $oid_SystemDirectorState, $oid_WorkspaceRedistributingCount ], |
| 105 |
nothing_quit => 1); |
| 106 |
|
| 107 |
$self->{global} = {}; |
| 108 |
|
| 109 |
$self->{global} = { |
| 110 |
SystemDirectorState => $map_status{$results->{$oid_SystemDirectorState}}, |
| 111 |
WorkspaceRedistributingCount => $results->{$oid_WorkspaceRedistributingCount}, |
| 112 |
}; |
| 113 |
} |
| 114 |
|
| 115 |
1; |
| 116 |
|
| 117 |
__END__ |
| 118 |
|
| 119 |
=head1 MODE |
| 120 |
|
| 121 |
Check System Director state and workspaces redistributing count. |
| 122 |
|
| 123 |
=over 8 |
| 124 |
|
| 125 |
=item B<--warning-status> |
| 126 |
|
| 127 |
Define the conditions to match for the status to be WARNING. (default: ''). |
| 128 |
Can use special variables like: %{state} |
| 129 |
|
| 130 |
=item B<--critical-status> |
| 131 |
|
| 132 |
Define the conditions to match for the status to be CRITICAL. (default: '%{state} !~ /Online/i'). |
| 133 |
Can use special variables like: %{state} |
| 134 |
|
| 135 |
=item B<--warning-redistributing-count> |
| 136 |
|
| 137 |
Warning threshold for number of workspaces redistributing. |
| 138 |
|
| 139 |
=item B<--critical-redistributing-count> |
| 140 |
|
| 141 |
Critical threshold for number of workspaces redistributing. |
| 142 |
|
| 143 |
=back |
| 144 |
|
| 145 |
=cut |