| 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::portstats; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use centreon::plugins::misc; |
| 28 |
|
| 29 |
sub set_counters { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
$self->{maps_counters_type} = [ |
| 33 |
{ name => 'port', type => 1, cb_prefix_output => 'prefix_port_output', message_multiple => 'All ports are ok' } |
| 34 |
]; |
| 35 |
|
| 36 |
$self->{maps_counters}->{port} = [ |
| 37 |
{ label => 'read-iops', nlabel => 'port.io.read.usage.iops', set => { |
| 38 |
key_values => [ { name => 'read_iops' }, { name => 'display' } ], |
| 39 |
output_template => 'Read IOPS : %d', |
| 40 |
perfdatas => [ |
| 41 |
{ label => 'read_iops', template => '%d', |
| 42 |
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 43 |
] |
| 44 |
} |
| 45 |
}, |
| 46 |
{ label => 'write-iops', nlabel => 'port.io.write.usage.iops', set => { |
| 47 |
key_values => [ { name => 'write_iops' }, { name => 'display' } ], |
| 48 |
output_template => 'Write IOPS : %d', |
| 49 |
perfdatas => [ |
| 50 |
{ label => 'write_iops', template => '%d', |
| 51 |
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 52 |
] |
| 53 |
} |
| 54 |
}, |
| 55 |
{ label => 'read-traffic', nlabel => 'port.traffic.read.usage.bitspersecond', set => { |
| 56 |
key_values => [ { name => 'read_traffic' }, { name => 'display' } ], |
| 57 |
output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2, |
| 58 |
perfdatas => [ |
| 59 |
{ label => 'read_traffic', template => '%d', |
| 60 |
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 61 |
] |
| 62 |
} |
| 63 |
}, |
| 64 |
{ label => 'write-traffic', nlabel => 'port.traffic.write.usage.bitspersecond', set => { |
| 65 |
key_values => [ { name => 'write_traffic' }, { name => 'display' } ], |
| 66 |
output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2, |
| 67 |
perfdatas => [ |
| 68 |
{ label => 'write_traffic', template => '%d', |
| 69 |
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' } |
| 70 |
] |
| 71 |
} |
| 72 |
} |
| 73 |
]; |
| 74 |
} |
| 75 |
|
| 76 |
sub prefix_port_output { |
| 77 |
my ($self, %options) = @_; |
| 78 |
|
| 79 |
return "Port '" . $options{instance_value}->{display} . "' "; |
| 80 |
} |
| 81 |
|
| 82 |
sub new { |
| 83 |
my ($class, %options) = @_; |
| 84 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 85 |
bless $self, $class; |
| 86 |
|
| 87 |
$options{options}->add_options(arguments => { |
| 88 |
'filter-name:s' => { name => 'filter_name' } |
| 89 |
}); |
| 90 |
|
| 91 |
return $self; |
| 92 |
} |
| 93 |
|
| 94 |
sub manage_selection { |
| 95 |
my ($self, %options) = @_; |
| 96 |
|
| 97 |
my ($stdout) = $options{custom}->execute_command( |
| 98 |
command => 'show', |
| 99 |
command_options => "performance -type port\n", |
| 100 |
ssh_pipe => 1 |
| 101 |
); |
| 102 |
|
| 103 |
#Location IOPS(IOPS) Throughput(MB/s) |
| 104 |
# Read / Write Read / Write |
| 105 |
#------------------- ----------- ------------ ----------- ----------- |
| 106 |
#CM#0 CA#0 Port#0 6621 5192 589 379 |
| 107 |
#CM#1 CA#1 Port#1 7791 6608 613 292 |
| 108 |
|
| 109 |
$self->{port} = {}; |
| 110 |
foreach (split /\n/, $stdout) { |
| 111 |
next if ($_ !~ /^(.*?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/); |
| 112 |
my ($port_name, $port_read_iops, $port_write_iops, $port_read_traffic, $port_write_traffic) = ($1, $2, $3, $4, $5); |
| 113 |
|
| 114 |
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && |
| 115 |
$port_name !~ /$self->{option_results}->{filter_name}/) { |
| 116 |
$self->{output}->output_add(long_msg => "Skipping '" . $port_name . "': no matching filter name."); |
| 117 |
next; |
| 118 |
} |
| 119 |
|
| 120 |
$self->{port}->{$port_name} = { |
| 121 |
display => $port_name, |
| 122 |
read_iops => $port_read_iops, write_iops => $port_write_iops, |
| 123 |
read_traffic => $port_read_traffic * 1000 * 1000 * 8, |
| 124 |
write_traffic => $port_write_traffic * 1000 * 1000 * 8 |
| 125 |
}; |
| 126 |
} |
| 127 |
|
| 128 |
if (scalar(keys %{$self->{port}}) <= 0) { |
| 129 |
$self->{output}->add_option_msg(short_msg => "No port found."); |
| 130 |
$self->{output}->option_exit(); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
1; |
| 135 |
|
| 136 |
__END__ |
| 137 |
|
| 138 |
=head1 MODE |
| 139 |
|
| 140 |
Check Port statistics. |
| 141 |
|
| 142 |
Command used: show performance -type port |
| 143 |
|
| 144 |
=over 8 |
| 145 |
|
| 146 |
=item B<--filter-name> |
| 147 |
|
| 148 |
Filter by name (regexp can be used). |
| 149 |
|
| 150 |
=item B<--warning-*> |
| 151 |
|
| 152 |
Warning threshold. |
| 153 |
Can be: 'read-iops', 'write-iops', 'read-traffic', 'write-traffic'. |
| 154 |
|
| 155 |
=item B<--critical-*> |
| 156 |
|
| 157 |
Critical threshold. |
| 158 |
Can be: 'read-iops', 'write-iops', 'read-traffic', 'write-traffic'. |
| 159 |
|
| 160 |
=back |
| 161 |
|
| 162 |
=cut |