Debian Codegraph @

src/storage/avid/isis/snmp/mode/performance.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::avid::isis::snmp::mode::performance;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub custom_client_perfdata {
29 my ($self, %options) = @_;
30
31 $self->{output}->perfdata_add(label => 'active_clients',
32 value => $self->{result_values}->{active},
33 unit => 'clients',
34 min => 0,
35 max => $self->{result_values}->{maximum});
36 }
37
38 sub custom_client_threshold {
39 my ($self, %options) = @_;
40
41 my ($exit, $threshold_value);
42 $threshold_value = defined($self->{instance_mode}->{option_results}->{percent}) ? $self->{result_values}->{prct_active} : $self->{result_values}->{active} ;
43 $exit = $self->{perfdata}->threshold_check(value => $threshold_value,
44 threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
45 { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
46 return $exit;
47 }
48
49 sub custom_client_output {
50 my ($self, %options) = @_;
51
52 my $msg = sprintf("Active clients: %d/%d (%.2f%%)",
53 $self->{result_values}->{active}, $self->{result_values}->{maximum}, $self->{result_values}->{prct_active});
54 return $msg;
55 }
56
57 sub custom_client_calc {
58 my ($self, %options) = @_;
59
60 $self->{result_values}->{active} = $options{new_datas}->{$self->{instance} . '_ActiveClientCount'};
61 $self->{result_values}->{maximum} = $options{new_datas}->{$self->{instance} . '_MaximumClientCount'};
62 $self->{result_values}->{prct_active} = ($self->{result_values}->{maximum} != 0) ? $self->{result_values}->{active} * 100 / $self->{result_values}->{maximum} : 0;
63
64 return 0;
65 }
66
67 sub set_counters {
68 my ($self, %options) = @_;
69
70 $self->{maps_counters_type} = [
71 { name => 'global', type => 0 },
72 ];
73
74 $self->{maps_counters}->{global} = [
75 { label => 'active-clients', set => {
76 key_values => [ { name => 'ActiveClientCount' }, { name => 'MaximumClientCount' } ],
77 closure_custom_calc => $self->can('custom_client_calc'),
78 closure_custom_output => $self->can('custom_client_output'),
79 closure_custom_threshold_check => $self->can('custom_client_threshold'),
80 closure_custom_perfdata => $self->can('custom_client_perfdata'),
81 }
82 },
83 { label => 'open-files', set => {
84 key_values => [ { name => 'OpenFiles' } ],
85 output_template => 'Open files: %s files',
86 perfdatas => [
87 { label => 'open_files', value => 'OpenFiles',
88 template => '%s', min => 0, unit => 'files' },
89 ],
90 }
91 },
92 { label => 'processing-speed', set => {
93 key_values => [ { name => 'MessagesPerSecond' } ],
94 output_template => 'Message processing speed: %s messages/s',
95 perfdatas => [
96 { label => 'processing_speed', value => 'MessagesPerSecond',
97 template => '%s', min => 0, unit => 'messages/s' },
98 ],
99 }
100 },
101 { label => 'read-throughput', set => {
102 key_values => [ { name => 'ReadMegabytesPerSecond' } ],
103 output_template => 'Read throughput: %s %s/s',
104 output_change_bytes => 1,
105 perfdatas => [
106 { label => 'read_throughput', value => 'ReadMegabytesPerSecond',
107 template => '%s', min => 0, unit => 'B/s' },
108 ],
109 }
110 },
111 { label => 'write-throughput', set => {
112 key_values => [ { name => 'WriteMegabytesPerSecond' } ],
113 output_template => 'Write throughput: %s %s/s',
114 output_change_bytes => 1,
115 perfdatas => [
116 { label => 'write_throughput', value => 'WriteMegabytesPerSecond',
117 template => '%s', min => 0, unit => 'B/s' },
118 ],
119 }
120 },
121 ];
122 }
123
124 sub new {
125 my ($class, %options) = @_;
126 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
127 bless $self, $class;
128
129 $options{options}->add_options(arguments => {
130 "percent" => { name => 'percent' },
131 });
132
133 return $self;
134 }
135
136 my $oid_ReadMegabytesPerSecond = '.1.3.6.1.4.1.526.20.3.2.0';
137 my $oid_WriteMegabytesPerSecond = '.1.3.6.1.4.1.526.20.3.3.0';
138 my $oid_MessagesPerSecond = '.1.3.6.1.4.1.526.20.3.4.0';
139 my $oid_OpenFiles = '.1.3.6.1.4.1.526.20.3.5.0';
140 my $oid_ActiveClientCount = '.1.3.6.1.4.1.526.20.3.6.0';
141 my $oid_MaximumClientCount = '.1.3.6.1.4.1.526.20.3.7.0';
142
143 sub manage_selection {
144 my ($self, %options) = @_;
145
146 my $results = $options{snmp}->get_leef(oids => [ $oid_ReadMegabytesPerSecond, $oid_WriteMegabytesPerSecond,
147 $oid_MessagesPerSecond, $oid_OpenFiles,
148 $oid_ActiveClientCount, $oid_MaximumClientCount ],
149 nothing_quit => 1);
150
151 $self->{global} = {};
152
153 $self->{global} = {
154 ReadMegabytesPerSecond => $results->{$oid_ReadMegabytesPerSecond} * 1024 * 1024,
155 WriteMegabytesPerSecond => $results->{$oid_WriteMegabytesPerSecond} * 1024 * 1024,
156 MessagesPerSecond => $results->{$oid_MessagesPerSecond},
157 OpenFiles => $results->{$oid_OpenFiles},
158 ActiveClientCount => $results->{$oid_ActiveClientCount},
159 MaximumClientCount => $results->{$oid_MaximumClientCount},
160 };
161 }
162
163 1;
164
165 __END__
166
167 =head1 MODE
168
169 Check client performances.
170
171 =over 8
172
173 =item B<--warning-*>
174
175 Warning threshold.
176 Can be: 'active-clients' (counter or %), 'open-files',
177 'processing-speed', 'read-throughput', 'write-throughput'.
178
179 =item B<--critical-*>
180
181 Critical threshold.
182 Can be: 'active-clients' (counter or %), 'open-files',
183 'processing-speed', 'read-throughput', 'write-throughput'.
184
185 =item B<--percent>
186
187 Set this option if you want to use percent on active clients thresholds.
188
189 =back
190
191 =cut