| 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::fujitsu::eternus::dx::ssh::mode::volumestats; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use centreon::plugins::misc; |
| 28 |
|
| 29 |
sub prefix_volume_output { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
return "Volume '" . $options{instance_value}->{display} . "' "; |
| 33 |
} |
| 34 |
|
| 35 |
sub set_counters { |
| 36 |
my ($self, %options) = @_; |
| 37 |
|
| 38 |
$self->{maps_counters_type} = [ |
| 39 |
{ name => 'volume', type => 1, cb_prefix_output => 'prefix_volume_output', message_multiple => 'All Volumes are ok' } |
| 40 |
]; |
| 41 |
|
| 42 |
$self->{maps_counters}->{volume} = [ |
| 43 |
{ label => 'read-iops', nlabel => 'volume.io.read.usage.iops', set => { |
| 44 |
key_values => [ { name => 'read_iops' }, { name => 'display' } ], |
| 45 |
output_template => 'Read IOPS : %d', |
| 46 |
perfdatas => [ |
| 47 |
{ label => 'read_iops', template => '%d', |
| 48 |
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 49 |
] |
| 50 |
} |
| 51 |
}, |
| 52 |
{ label => 'write-iops', nlabel => 'volume.io.write.usage.iops', set => { |
| 53 |
key_values => [ { name => 'write_iops' }, { name => 'display' } ], |
| 54 |
output_template => 'Write IOPS : %d', |
| 55 |
perfdatas => [ |
| 56 |
{ label => 'write_iops', template => '%d', |
| 57 |
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 58 |
] |
| 59 |
} |
| 60 |
}, |
| 61 |
{ label => 'read-traffic', nlabel => 'volume.traffic.read.usage.bitspersecond', set => { |
| 62 |
key_values => [ { name => 'read_throughput' }, { name => 'display' } ], |
| 63 |
output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2, |
| 64 |
perfdatas => [ |
| 65 |
{ label => 'read_throughput', template => '%d', |
| 66 |
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 67 |
] |
| 68 |
} |
| 69 |
}, |
| 70 |
{ label => 'write-traffic', nlabel => 'volume.traffic.write.usage.bitspersecond', set => { |
| 71 |
key_values => [ { name => 'write_throughput' }, { name => 'display' } ], |
| 72 |
output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2, |
| 73 |
perfdatas => [ |
| 74 |
{ label => 'write_throughput', template => '%d', |
| 75 |
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 76 |
] |
| 77 |
} |
| 78 |
}, |
| 79 |
{ label => 'read-response-time', nlabel => 'volume.io.read.time.response.milliseconds', set => { |
| 80 |
key_values => [ { name => 'read_response_time' }, { name => 'display' } ], |
| 81 |
output_template => 'Read Response Time : %d ms', |
| 82 |
perfdatas => [ |
| 83 |
{ label => 'read_response_time', template => '%d', |
| 84 |
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 85 |
] |
| 86 |
} |
| 87 |
}, |
| 88 |
{ label => 'write-response-time', nlabel => 'volume.io.write.time.response.milliseconds', set => { |
| 89 |
key_values => [ { name => 'write_response_time' }, { name => 'display' } ], |
| 90 |
output_template => 'Write Response Time : %d ms', |
| 91 |
perfdatas => [ |
| 92 |
{ label => 'write_response_time', template => '%d', |
| 93 |
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, |
| 94 |
], |
| 95 |
} |
| 96 |
}, |
| 97 |
{ label => 'read-processing-time', nlabel => 'volume.io.read.time.processing.milliseconds', set => { |
| 98 |
key_values => [ { name => 'read_processing_time' }, { name => 'display' } ], |
| 99 |
output_template => 'Read Processing Time : %d ms', |
| 100 |
perfdatas => [ |
| 101 |
{ label => 'read_processing_time', template => '%d', |
| 102 |
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 103 |
] |
| 104 |
} |
| 105 |
}, |
| 106 |
{ label => 'write-processing-time', nlabel => 'volume.io.write.time.processing.milliseconds', set => { |
| 107 |
key_values => [ { name => 'write_processing_time' }, { name => 'display' } ], |
| 108 |
output_template => 'Write Processing Time : %d ms', |
| 109 |
perfdatas => [ |
| 110 |
{ label => 'write_processing_time', template => '%d', |
| 111 |
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 112 |
] |
| 113 |
} |
| 114 |
}, |
| 115 |
{ label => 'read-cache-hit-rate', nlabel => 'volume.io.read.cache.hits.percentage', set => { |
| 116 |
key_values => [ { name => 'read_cache_hit_rate' }, { name => 'display' } ], |
| 117 |
output_template => 'Read Cache Hit Rate : %d %%', |
| 118 |
perfdatas => [ |
| 119 |
{ label => 'read_cache_hit_rate', template => '%d', |
| 120 |
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } |
| 121 |
] |
| 122 |
} |
| 123 |
}, |
| 124 |
{ label => 'write-cache-hit-rate', nlabel => 'volume.io.write.cache.hits.percentage', set => { |
| 125 |
key_values => [ { name => 'write_cache_hit_rate' }, { name => 'display' } ], |
| 126 |
output_template => 'Write Cache Hit Rate : %d %%', |
| 127 |
perfdatas => [ |
| 128 |
{ label => 'write_cache_hit_rate', template => '%d', |
| 129 |
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } |
| 130 |
] |
| 131 |
} |
| 132 |
} |
| 133 |
]; |
| 134 |
} |
| 135 |
|
| 136 |
sub new { |
| 137 |
my ($class, %options) = @_; |
| 138 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 139 |
bless $self, $class; |
| 140 |
|
| 141 |
$options{options}->add_options(arguments => { |
| 142 |
'filter-name:s' => { name => 'filter_name' } |
| 143 |
}); |
| 144 |
|
| 145 |
return $self; |
| 146 |
} |
| 147 |
|
| 148 |
sub manage_selection { |
| 149 |
my ($self, %options) = @_; |
| 150 |
|
| 151 |
my ($stdout) = $options{custom}->execute_command( |
| 152 |
command => 'show', |
| 153 |
command_options => "performance -type host-io\n", |
| 154 |
ssh_pipe => 1 |
| 155 |
); |
| 156 |
|
| 157 |
#Volume IOPS(IOPS) Throughput(MB/s) Response Time(msec.) Processing Time(msec.) Cache Hit Rate(%) |
| 158 |
#No. Name Read / Write Read / Write Read / Write Read / Write Read / Write / Prefetch |
| 159 |
#----- -------------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- |
| 160 |
# 1 VOL001 6621 5192 589 379 17055 12056 10025 10010 41 37 36 |
| 161 |
# 2 VOL002 7791 6608 613 292 12148 11045 10005 10007 41 37 36 |
| 162 |
|
| 163 |
$self->{volume} = {}; |
| 164 |
my %template_label = (cache_hit_rate => { labels => ['read', 'write', 'prefetch'] }); |
| 165 |
my @template_values = (); |
| 166 |
foreach (split /\n/, $stdout) { |
| 167 |
if (/^Volume/) { |
| 168 |
while (/(\sIOPS|\sThroughput|\sResponse Time|\sProcessing Time|[^C]\sCache Hit Rate)/mgi) { |
| 169 |
my $value = lc(centreon::plugins::misc::trim($1)); |
| 170 |
$value =~ s/ /_/g; |
| 171 |
|
| 172 |
my $labels = ['read', 'write']; |
| 173 |
if (defined($template_label{$value})) { |
| 174 |
$labels = $template_label{$value}->{labels}; |
| 175 |
} |
| 176 |
|
| 177 |
foreach (@{$labels}) { |
| 178 |
push @template_values, { label => $_ . '_' . $value }; |
| 179 |
} |
| 180 |
} |
| 181 |
next; |
| 182 |
} |
| 183 |
next if (/----|Name/i); |
| 184 |
next if (/^CLI>/); |
| 185 |
|
| 186 |
my $value = centreon::plugins::misc::trim($_); |
| 187 |
my @matches = split(/\s+/, $value); |
| 188 |
|
| 189 |
next if (!defined($matches[1])); |
| 190 |
|
| 191 |
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && |
| 192 |
$matches[1] !~ /$self->{option_results}->{filter_name}/) { |
| 193 |
$self->{output}->output_add(long_msg => "Skipping '" . $matches[1] . "': no matching filter name.", debug => 1); |
| 194 |
next; |
| 195 |
} |
| 196 |
|
| 197 |
my %counters = (); |
| 198 |
for (my $i = 0; $i < scalar(@template_values); $i++) { |
| 199 |
$counters{$template_values[$i]->{label}} = $matches[$i + 2]; |
| 200 |
} |
| 201 |
$counters{read_throughput} *= 1000 * 1000 * 8 if (defined($counters{read_throughput})); |
| 202 |
$counters{write_throughput} *= 1000 * 1000 * 8 if (defined($counters{write_throughput})); |
| 203 |
|
| 204 |
$self->{volume}->{$matches[0]} = { |
| 205 |
display => $matches[1], |
| 206 |
%counters |
| 207 |
}; |
| 208 |
} |
| 209 |
|
| 210 |
if (scalar(keys %{$self->{volume}}) <= 0) { |
| 211 |
$self->{output}->add_option_msg(short_msg => "No volume found."); |
| 212 |
$self->{output}->option_exit(); |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
1; |
| 217 |
|
| 218 |
__END__ |
| 219 |
|
| 220 |
=head1 MODE |
| 221 |
|
| 222 |
Check volume statistics. |
| 223 |
|
| 224 |
Command used: show performance -type host-io |
| 225 |
|
| 226 |
=over 8 |
| 227 |
|
| 228 |
=item B<--filter-name> |
| 229 |
|
| 230 |
Filter by name (regexp can be used). |
| 231 |
|
| 232 |
=item B<--warning-*> B<--critical-*> |
| 233 |
|
| 234 |
Thresholds. |
| 235 |
Can be: 'read-iops', 'write-iops', 'read-traffic', 'write-traffic', |
| 236 |
'read-response-time', 'write-response-time', 'read-processing-time', 'write-processing-time', |
| 237 |
'read-cache-hit-rate', 'write-cache-hit-rate'. |
| 238 |
|
| 239 |
=back |
| 240 |
|
| 241 |
=cut |