| 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::fs900::snmp::mode::fcusage; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub custom_bandwidth_perfdata { |
| 29 |
my ($self, %options) = @_; |
| 30 |
|
| 31 |
$self->{output}->perfdata_add( |
| 32 |
label => lc($self->{result_values}->{type}) . "_bandwidth", unit => 'B/s', |
| 33 |
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, |
| 34 |
value => $self->{result_values}->{bandwidth}, |
| 35 |
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), |
| 36 |
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), |
| 37 |
min => 0 |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
sub custom_bandwidth_threshold { |
| 42 |
my ($self, %options) = @_; |
| 43 |
|
| 44 |
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{bandwidth}, |
| 45 |
threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, |
| 46 |
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); |
| 47 |
return $exit; |
| 48 |
} |
| 49 |
|
| 50 |
sub custom_bandwidth_output { |
| 51 |
my ($self, %options) = @_; |
| 52 |
|
| 53 |
my ($bandwidth, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{bandwidth}); |
| 54 |
|
| 55 |
my $msg = sprintf("%s bandwidth: %s %s/s", $self->{result_values}->{type}, $bandwidth, $unit); |
| 56 |
return $msg; |
| 57 |
} |
| 58 |
|
| 59 |
sub custom_bandwidth_calc { |
| 60 |
my ($self, %options) = @_; |
| 61 |
|
| 62 |
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_fcObject'}; |
| 63 |
$self->{result_values}->{type} = $options{extra_options}->{type}; |
| 64 |
$self->{result_values}->{bandwidth} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{bandwidth}} * 1024 * 1024; |
| 65 |
|
| 66 |
return 0; |
| 67 |
} |
| 68 |
|
| 69 |
sub set_counters { |
| 70 |
my ($self, %options) = @_; |
| 71 |
|
| 72 |
$self->{maps_counters_type} = [ |
| 73 |
{ name => 'global', type => 1, cb_prefix_output => 'prefix_output', message_multiple => "All fibre channels read/write metrics are ok", skipped_code => { -10 => 1 } } |
| 74 |
]; |
| 75 |
|
| 76 |
$self->{maps_counters}->{global} = [ |
| 77 |
{ label => 'read-bandwidth', set => { |
| 78 |
key_values => [ { name => 'fcReadBW' }, { name => 'fcObject' } ], |
| 79 |
closure_custom_calc => $self->can('custom_bandwidth_calc'), |
| 80 |
closure_custom_calc_extra_options => { type => 'Read', bandwidth => 'fcReadBW' }, |
| 81 |
closure_custom_output => $self->can('custom_bandwidth_output'), |
| 82 |
closure_custom_perfdata => $self->can('custom_bandwidth_perfdata'), |
| 83 |
closure_custom_threshold_check => $self->can('custom_bandwidth_threshold'), |
| 84 |
} |
| 85 |
}, |
| 86 |
{ label => 'write-bandwidth', set => { |
| 87 |
key_values => [ { name => 'fcWriteBW' }, { name => 'fcObject' } ], |
| 88 |
closure_custom_calc => $self->can('custom_bandwidth_calc'), |
| 89 |
closure_custom_calc_extra_options => { type => 'Write', bandwidth => 'fcWriteBW' }, |
| 90 |
closure_custom_output => $self->can('custom_bandwidth_output'), |
| 91 |
closure_custom_perfdata => $self->can('custom_bandwidth_perfdata'), |
| 92 |
closure_custom_threshold_check => $self->can('custom_bandwidth_threshold'), |
| 93 |
} |
| 94 |
}, |
| 95 |
{ label => 'read-iops', set => { |
| 96 |
key_values => [ { name => 'fcReadIOPS' }, { name => 'fcObject' } ], |
| 97 |
output_template => 'Read IOPS: %s iops', |
| 98 |
perfdatas => [ |
| 99 |
{ label => 'read_iops', value => 'fcReadIOPS', template => '%s', label_extra_instance => 1, |
| 100 |
instance_use => 'fcObject', min => 0, unit => 'iops' }, |
| 101 |
], |
| 102 |
} |
| 103 |
}, |
| 104 |
{ label => 'write-iops', set => { |
| 105 |
key_values => [ { name => 'fcWriteIOPS' }, { name => 'fcObject' } ], |
| 106 |
output_template => 'Write IOPS: %s iops', |
| 107 |
perfdatas => [ |
| 108 |
{ label => 'write_iops', value => 'fcWriteIOPS', template => '%s', label_extra_instance => 1, |
| 109 |
instance_use => 'fcObject', min => 0, unit => 'iops' }, |
| 110 |
], |
| 111 |
} |
| 112 |
}, |
| 113 |
{ label => 'read-queue-depth', set => { |
| 114 |
key_values => [ { name => 'fcReadQueueDepth' }, { name => 'fcObject' } ], |
| 115 |
output_template => 'Read queue depth: %s', |
| 116 |
perfdatas => [ |
| 117 |
{ label => 'read_queue_depth', value => 'fcReadQueueDepth', template => '%s', label_extra_instance => 1, |
| 118 |
instance_use => 'fcObject', min => 0, unit => 'iops' }, |
| 119 |
], |
| 120 |
} |
| 121 |
}, |
| 122 |
{ label => 'write-queue-depth', set => { |
| 123 |
key_values => [ { name => 'fcWriteQueueDepth' }, { name => 'fcObject' } ], |
| 124 |
output_template => 'Write queue depth: %s', |
| 125 |
perfdatas => [ |
| 126 |
{ label => 'write_queue_depth', value => 'fcWriteQueueDepth', template => '%s', label_extra_instance => 1, |
| 127 |
instance_use => 'fcObject', min => 0, unit => 'iops' }, |
| 128 |
], |
| 129 |
} |
| 130 |
}, |
| 131 |
]; |
| 132 |
} |
| 133 |
|
| 134 |
sub prefix_output { |
| 135 |
my ($self, %options) = @_; |
| 136 |
|
| 137 |
return "Fibre channel '" . $options{instance_value}->{fcObject} . "' "; |
| 138 |
} |
| 139 |
|
| 140 |
sub new { |
| 141 |
my ($class, %options) = @_; |
| 142 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 143 |
bless $self, $class; |
| 144 |
|
| 145 |
$options{options}->add_options(arguments => |
| 146 |
{ |
| 147 |
}); |
| 148 |
|
| 149 |
return $self; |
| 150 |
} |
| 151 |
|
| 152 |
my $mapping = { |
| 153 |
fcObject => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.2' }, |
| 154 |
fcReadBW => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.13' }, #MB/s |
| 155 |
fcWriteBW => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.14' }, #MB/s |
| 156 |
fcReadIOPS => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.16' }, |
| 157 |
fcWriteIOPS => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.17' }, |
| 158 |
fcReadQueueDepth => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.19' }, |
| 159 |
fcWriteQueueDepth => { oid => '.1.3.6.1.4.1.2.6.255.1.1.2.1.1.20' }, |
| 160 |
}; |
| 161 |
|
| 162 |
my $oid_fcTableEntry = '.1.3.6.1.4.1.2.6.255.1.1.2.1.1'; |
| 163 |
|
| 164 |
sub manage_selection { |
| 165 |
my ($self, %options) = @_; |
| 166 |
|
| 167 |
my $snmp_result = $options{snmp}->get_table(oid => $oid_fcTableEntry, |
| 168 |
nothing_quit => 1); |
| 169 |
|
| 170 |
$self->{global} = {}; |
| 171 |
|
| 172 |
foreach my $oid (keys %{$snmp_result}) { |
| 173 |
next if ($oid !~ /^$mapping->{fcObject}->{oid}\.(.*)$/); |
| 174 |
my $instance = $1; |
| 175 |
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); |
| 176 |
|
| 177 |
$self->{global}->{$result->{fcObject}} = $result; |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
1; |
| 182 |
|
| 183 |
__END__ |
| 184 |
|
| 185 |
=head1 MODE |
| 186 |
|
| 187 |
Check fibre channels usage. |
| 188 |
|
| 189 |
=over 8 |
| 190 |
|
| 191 |
=item B<--warning-*> |
| 192 |
|
| 193 |
Warning threshold. |
| 194 |
Can be: 'read-bandwidth', 'write-bandwidth', 'read-iops', 'write-iops', 'read-queue-depth', 'write-queue-depth'. |
| 195 |
|
| 196 |
=item B<--critical-*> |
| 197 |
|
| 198 |
Critical threshold. |
| 199 |
Can be: 'read-bandwidth', 'write-bandwidth', 'read-iops', 'write-iops', 'read-queue-depth', 'write-queue-depth'. |
| 200 |
|
| 201 |
=back |
| 202 |
|
| 203 |
=cut |