Debian Codegraph @

src/storage/emc/xtremio/restapi/mode/ssdiops.pm

raw
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::emc::xtremio::restapi::mode::ssdiops;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub set_counters {
29 my ($self, %options) = @_;
30
31 $self->{maps_counters_type} = [
32 { name => 'global', type => 0 },
33 { name => 'ssd', type => 1, cb_prefix_output => 'prefix_ssd_output', message_multiple => 'All SSDs usages are ok' }
34 ];
35
36 $self->{maps_counters}->{global} = [
37 { label => 'total', set => {
38 key_values => [ { name => 'total' } ],
39 output_template => 'Total : %s iops',
40 perfdatas => [
41 { label => 'total', value => 'total', template => '%s',
42 min => 0, unit => 'iops' },
43 ],
44 }
45 },
46 { label => 'total-read', set => {
47 key_values => [ { name => 'total_read' } ],
48 output_template => 'Total read : %s iops',
49 perfdatas => [
50 { label => 'total_read', value => 'total_read', template => '%s',
51 min => 0, unit => 'iops' },
52 ],
53 }
54 },
55 { label => 'total-write', set => {
56 key_values => [ { name => 'total_write' } ],
57 output_template => 'Total write : %s iops',
58 perfdatas => [
59 { label => 'total_write', value => 'total_write', template => '%s',
60 min => 0, unit => 'iops' },
61 ],
62 }
63 },
64 ];
65
66 $self->{maps_counters}->{ssd} = [
67 { label => 'global', set => {
68 key_values => [ { name => 'global_iops' }, { name => 'display' }, ],
69 output_template => 'Global : %s iops',
70 perfdatas => [
71 { label => 'global', value => 'global_iops', template => '%s',
72 min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display' },
73 ],
74 }
75 },
76 { label => 'read', set => {
77 key_values => [ { name => 'read_iops' }, { name => 'display' }, ],
78 output_template => 'Read : %s iops',
79 perfdatas => [
80 { label => 'read', value => 'read_iops', template => '%s',
81 min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display' },
82 ],
83 }
84 },
85 { label => 'write', set => {
86 key_values => [ { name => 'write_iops' }, { name => 'display' }, ],
87 output_template => 'Write : %s iopss',
88 perfdatas => [
89 { label => 'write', value => 'write_iops', template => '%s',
90 min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display' },
91 ],
92 }
93 },
94 ];
95 }
96
97 sub new {
98 my ($class, %options) = @_;
99 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
100 bless $self, $class;
101
102 $options{options}->add_options(arguments => {
103 "filter-name:s" => { name => 'filter_name' },
104 });
105
106 return $self;
107 }
108
109 sub prefix_ssd_output {
110 my ($self, %options) = @_;
111
112 return "SSD '" . $options{instance_value}->{display} . "' Usage ";
113 }
114
115 sub manage_selection {
116 my ($self, %options) = @_;
117
118 my $urlbase = '/api/json/types/';
119 my @items = $options{custom}->get_items(
120 url => $urlbase,
121 obj => 'ssds'
122 );
123
124 $self->{ssd} = {};
125 $self->{global} = { total => 0, total_read => 0, total_write => 0 };
126 foreach my $item (@items) {
127 if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
128 $item !~ /$self->{option_results}->{filter_name}/) {
129 $self->{output}->output_add(long_msg => "skipping '" . $item . "': no matching name.", debug => 1);
130 next;
131 }
132
133 my $details = $options{custom}->get_details(
134 url => $urlbase,
135 obj => 'ssds',
136 name => $item
137 );
138
139 $self->{global}->{total} += $details->{iops};
140 $self->{global}->{total_read} += $details->{'rd-iops'};
141 $self->{global}->{total_write} += $details->{'wr-iops'};
142 $self->{ssd}->{$item} = {
143 display => $item,
144 global_iops => $details->{iops},
145 read_iops => $details->{'rd-iops'},
146 write_iops => $details->{'wr-iops'},
147 };
148 }
149
150 if (scalar(keys %{$self->{ssd}}) <= 0) {
151 $self->{output}->add_option_msg(short_msg => "No entry found.");
152 $self->{output}->option_exit();
153 }
154 }
155
156 1;
157
158 __END__
159
160 =head1 MODE
161
162 Check SSDs usage.
163
164 =over 8
165
166 =item B<--warning-*> B<--critical-*>
167
168 Warning threshold (number of iops)
169 Can be: 'total', 'total-read', 'total-write',
170 'global', 'read', 'write'.
171
172 =item B<--filter-name>
173
174 Filter the SSD names to monitor with a regular expression. Example: --filter-name '.*' for all SSDs.
175
176 =back
177
178 =cut