| 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::dell::me4::restapi::mode::controllerstatistics; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use Digest::MD5 qw(md5_hex); |
| 28 |
|
| 29 |
sub prefix_output { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
return "Controller '" . $options{instance_value}->{display} . "' "; |
| 33 |
} |
| 34 |
|
| 35 |
sub set_counters { |
| 36 |
my ($self, %options) = @_; |
| 37 |
|
| 38 |
$self->{maps_counters_type} = [ |
| 39 |
{ name => 'controllers', type => 1, cb_prefix_output => 'prefix_output', message_multiple => 'All controllers statistics are ok' } |
| 40 |
]; |
| 41 |
|
| 42 |
$self->{maps_counters}->{controllers} = [ |
| 43 |
{ label => 'data-read', nlabel => 'controller.data.read.bytespersecond', set => { |
| 44 |
key_values => [ { name => 'data-read-numeric', per_second => 1 } ], |
| 45 |
output_template => 'data read: %s%s/s', |
| 46 |
output_change_bytes => 1, |
| 47 |
perfdatas => [ |
| 48 |
{ template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1 } |
| 49 |
] |
| 50 |
} |
| 51 |
}, |
| 52 |
{ label => 'data-written', nlabel => 'controller.data.written.bytespersecond', set => { |
| 53 |
key_values => [ { name => 'data-written-numeric', per_second => 1 } ], |
| 54 |
output_template => 'data written: %s%s/s', |
| 55 |
output_change_bytes => 1, |
| 56 |
perfdatas => [ |
| 57 |
{ template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1 } |
| 58 |
] |
| 59 |
} |
| 60 |
}, |
| 61 |
{ label => 'reads', nlabel => 'controller.reads.persecond', set => { |
| 62 |
key_values => [ { name => 'number-of-reads', per_second => 1 } ], |
| 63 |
output_template => 'reads: %s/s', |
| 64 |
perfdatas => [ |
| 65 |
{ template => '%s', min => 0, label_extra_instance => 1 } |
| 66 |
] |
| 67 |
} |
| 68 |
}, |
| 69 |
{ label => 'writes', nlabel => 'controller.writes.persecond', set => { |
| 70 |
key_values => [ { name => 'number-of-writes', per_second => 1 } ], |
| 71 |
output_template => 'writes: %s/s', |
| 72 |
perfdatas => [ |
| 73 |
{ template => '%s', min => 0, label_extra_instance => 1 } |
| 74 |
] |
| 75 |
} |
| 76 |
}, |
| 77 |
{ label => 'data-transfer', nlabel => 'controller.data.transfer.bytespersecond', set => { |
| 78 |
key_values => [ { name => 'bytes-per-second-numeric' } ], |
| 79 |
output_template => 'data transfer: %s%s/s', |
| 80 |
output_change_bytes => 1, |
| 81 |
perfdatas => [ |
| 82 |
{ template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1 } |
| 83 |
] |
| 84 |
} |
| 85 |
}, |
| 86 |
{ label => 'iops', nlabel => 'controller.iops.count', set => { |
| 87 |
key_values => [ { name => 'iops' } ], |
| 88 |
output_template => 'iops: %d ops', |
| 89 |
perfdatas => [ |
| 90 |
{ template => '%d', min => 0, unit => 'ops', label_extra_instance => 1 } |
| 91 |
] |
| 92 |
} |
| 93 |
}, |
| 94 |
{ label => 'forwarded-cmds', nlabel => 'controller.commands.forwarded.count', set => { |
| 95 |
key_values => [ { name => 'num-forwarded-cmds' } ], |
| 96 |
output_template => 'forwarded commands: %d', |
| 97 |
perfdatas => [ |
| 98 |
{ template => '%d', min => 0, label_extra_instance => 1 } |
| 99 |
] |
| 100 |
} |
| 101 |
}, |
| 102 |
{ label => 'write-cache-used', nlabel => 'controller.cache.write.usage.percentage', set => { |
| 103 |
key_values => [ { name => 'write-cache-used' } ], |
| 104 |
output_template => 'cache write usage: %s%%', |
| 105 |
perfdatas => [ |
| 106 |
{ template => '%d', min => 0, label_extra_instance => 1 } |
| 107 |
] |
| 108 |
} |
| 109 |
}, |
| 110 |
{ label => 'write-cache-hits', nlabel => 'controller.cache.write.hits.persecond', set => { |
| 111 |
key_values => [ { name => 'write-cache-hits', per_second => 1 } ], |
| 112 |
output_template => 'cache write hits: %s/s', |
| 113 |
perfdatas => [ |
| 114 |
{ template => '%s', min => 0, label_extra_instance => 1 } |
| 115 |
] |
| 116 |
} |
| 117 |
}, |
| 118 |
{ label => 'write-cache-misses', nlabel => 'controller.cache.write.misses.persecond', set => { |
| 119 |
key_values => [ { name => 'write-cache-misses', per_second => 1 } ], |
| 120 |
output_template => 'cache write misses: %s/s', |
| 121 |
perfdatas => [ |
| 122 |
{ template => '%s', min => 0, label_extra_instance => 1 } |
| 123 |
] |
| 124 |
} |
| 125 |
}, |
| 126 |
{ label => 'read-cache-hits', nlabel => 'controller.cache.read.hits.persecond', set => { |
| 127 |
key_values => [ { name => 'read-cache-hits', per_second => 1 } ], |
| 128 |
output_template => 'cache read hits: %s/s', |
| 129 |
perfdatas => [ |
| 130 |
{ template => '%s', min => 0, label_extra_instance => 1 } |
| 131 |
] |
| 132 |
} |
| 133 |
}, |
| 134 |
{ label => 'read-cache-misses', nlabel => 'controller.cache.read.misses.persecond', set => { |
| 135 |
key_values => [ { name => 'read-cache-misses', per_second => 1 } ], |
| 136 |
output_template => 'cache read misses: %s/s', |
| 137 |
perfdatas => [ |
| 138 |
{ template => '%s', min => 0, label_extra_instance => 1 } |
| 139 |
] |
| 140 |
} |
| 141 |
}, |
| 142 |
{ label => 'cpu-utilization', nlabel => 'controller.cpu.utilization.percentage', set => { |
| 143 |
key_values => [ { name => 'cpu-load' } ], |
| 144 |
output_template => 'cpu utilization: %.2f%%', |
| 145 |
perfdatas => [ |
| 146 |
{ template => '%s', min => 0, label_extra_instance => 1 } |
| 147 |
] |
| 148 |
} |
| 149 |
} |
| 150 |
]; |
| 151 |
} |
| 152 |
|
| 153 |
sub new { |
| 154 |
my ($class, %options) = @_; |
| 155 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); |
| 156 |
bless $self, $class; |
| 157 |
|
| 158 |
$options{options}->add_options(arguments => { |
| 159 |
'filter-name:s' => { name => 'filter_name' } |
| 160 |
}); |
| 161 |
|
| 162 |
return $self; |
| 163 |
} |
| 164 |
|
| 165 |
sub manage_selection { |
| 166 |
my ($self, %options) = @_; |
| 167 |
|
| 168 |
my $results = $options{custom}->request_api(method => 'GET', url_path => '/api/show/controller-statistics'); |
| 169 |
|
| 170 |
$self->{controllers} = {}; |
| 171 |
foreach my $controller (@{$results->{'controller-statistics'}}) { |
| 172 |
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' |
| 173 |
&& $controller->{'durable-id'} !~ /$self->{option_results}->{filter_name}/); |
| 174 |
|
| 175 |
$self->{controllers}->{$controller->{'durable-id'}} = { display => $controller->{'durable-id'}, %{$controller} }; |
| 176 |
} |
| 177 |
|
| 178 |
if (scalar(keys %{$self->{controllers}}) <= 0) { |
| 179 |
$self->{output}->add_option_msg(short_msg => "No controllers found."); |
| 180 |
$self->{output}->option_exit(); |
| 181 |
} |
| 182 |
|
| 183 |
$self->{cache_name} = "dell_me4_" . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . |
| 184 |
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . |
| 185 |
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); |
| 186 |
|
| 187 |
} |
| 188 |
|
| 189 |
1; |
| 190 |
|
| 191 |
__END__ |
| 192 |
|
| 193 |
=head1 MODE |
| 194 |
|
| 195 |
Check controllers statistics. |
| 196 |
|
| 197 |
=over 8 |
| 198 |
|
| 199 |
=item B<--filter-name> |
| 200 |
|
| 201 |
Filter controller name (can be a regexp). |
| 202 |
|
| 203 |
=item B<--warning-*> B<--critical-*> |
| 204 |
|
| 205 |
Thresholds. |
| 206 |
Can be: 'data-read', 'data-written', |
| 207 |
'reads', 'writes', 'data-transfer', |
| 208 |
'iops', 'forwarded-cmds', |
| 209 |
'write-cache-used', 'write-cache-hits', 'write-cache-misses', |
| 210 |
'read-cache-hits', 'read-cache-misses', 'cpu-utilization'. |
| 211 |
|
| 212 |
=back |
| 213 |
|
| 214 |
=cut |