Debian Codegraph @

src/hardware/devices/polycom/dma/snmp/mode/conferencemanager.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 hardware::devices::polycom::dma::snmp::mode::conferencemanager;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub custom_video_port_output {
29 my ($self, %options) = @_;
30
31 return sprintf(
32 'video ports [total: %s used: %s (%.2f%%) free: %s (%.2f%%)]',
33 $self->{result_values}->{vp_total},
34 $self->{result_values}->{vp_used},
35 $self->{result_values}->{vp_prct_used},
36 $self->{result_values}->{vp_free},
37 $self->{result_values}->{vp_prct_free}
38 );
39 }
40
41 sub custom_voice_port_output {
42 my ($self, %options) = @_;
43
44 return sprintf(
45 'voice ports [total: %s used: %s (%.2f%%) free: %s (%.2f%%)]',
46 $self->{result_values}->{vop_total},
47 $self->{result_values}->{vop_used},
48 $self->{result_values}->{vop_prct_used},
49 $self->{result_values}->{vop_free},
50 $self->{result_values}->{vop_prct_free}
51 );
52 }
53
54 sub set_counters {
55 my ($self, %options) = @_;
56
57 $self->{maps_counters_type} = [
58 { name => 'global', type => 0 },
59 { name => 'cluster', type => 1, cb_prefix_output => 'prefix_cluster_output', message_multiple => 'All clusters are ok', skipped_code => { -10 => 1 } }
60 ];
61
62 $self->{maps_counters}->{global} = [
63 { label => 'dma-total-conferences', nlabel => 'dma.conferences.active.count', set => {
64 key_values => [ { name => 'useConfMgrUsageCount' } ],
65 output_template => 'Total conferences : %s',
66 perfdatas => [
67 { template => '%d', min => 0, instance_use => 'display', template => '%d', min => 0 }
68 ]
69 }
70 }
71 ];
72
73 $self->{maps_counters}->{cluster} = [
74 { label => 'cluster-conferences', nlabel => 'dma.cluster.conferences.active.count', set => {
75 key_values => [ { name => 'useCMUsageActiveConfs' }, { name => 'display' } ],
76 output_template => 'current conferences : %s',
77 perfdatas => [
78 { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }
79 ]
80 }
81 },
82 { label => 'cluster-participants', nlabel => 'dma.cluster.participants.active.count', set => {
83 key_values => [ { name => 'useCMUsageActiveParts' }, { name => 'display' } ],
84 output_template => 'current participants : %s',
85 perfdatas => [
86 { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }
87 ]
88 }
89 },
90 { label => 'cluster-local-users', nlabel => 'dma.cluster.local.database.users.count', set => {
91 key_values => [ { name => 'useCMUsageLocalUsers' }, { name => 'display' } ],
92 output_template => 'local users : %s',
93 perfdatas => [
94 { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }
95 ]
96 }
97 },
98 { label => 'cluster-custom-rooms', nlabel => 'dma.cluster.custom.conference.rooms.count', set => {
99 key_values => [ { name => 'useCMUsageCustomConfRooms' }, { name => 'display' } ],
100 output_template => 'custom conference rooms : %s',
101 perfdatas => [
102 { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }
103 ]
104 }
105 },
106 { label => 'cluster-video-ports-usage', nlabel => 'dma.cluster.video.port.usage.count', set => {
107 key_values => [
108 { name => 'vp_used' }, { name => 'vp_free' }, { name => 'vp_prct_used' },
109 { name => 'vp_prct_free' }, { name => 'vp_total' }, { name => 'display' }
110 ],
111 closure_custom_output => $self->can('custom_video_port_output'),
112 perfdatas => [
113 { template => '%d', min => 0, max => 'total', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }
114 ]
115 }
116 },
117 { label => 'cluster-video-ports-free', display_ok => 0, nlabel => 'dma.cluster.video.port.free.count', set => {
118 key_values => [
119 { name => 'vp_free' }, { name => 'vp_used' }, { name => 'vp_prct_used' },
120 { name => 'vp_prct_free' }, { name => 'vp_total' }, { name => 'display' }
121 ],
122 closure_custom_output => $self->can('custom_video_port_output'),
123 perfdatas => [
124 { template => '%d', min => 0, max => 'total', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }
125 ]
126 }
127 },
128 { label => 'cluster-video-ports-prct', display_ok => 0, nlabel => 'dma.cluster.video.port.percentage', set => {
129 key_values => [ { name => 'vp_prct_used' }, { name => 'display' } ],
130 output_template => 'video ports used: %.2f %%',
131 perfdatas => [
132 { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }
133 ]
134 }
135 },
136 { label => 'cluster-voice-ports-usage', nlabel => 'dma.cluster.voice.port.usage.count', set => {
137 key_values => [
138 { name => 'vop_used' }, { name => 'vop_free' }, { name => 'vop_prct_used' },
139 { name => 'vop_prct_free' }, { name => 'vop_total' }, { name => 'display' }
140 ],
141 closure_custom_output => $self->can('custom_voice_port_output'),
142 perfdatas => [
143 { template => '%d', min => 0, max => 'total', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }
144 ]
145 }
146 },
147 { label => 'cluster-voice-ports-free', display_ok => 0, nlabel => 'dma.cluster.voice.port.free.count', set => {
148 key_values => [
149 { name => 'vop_free' }, { name => 'vop_used' }, { name => 'vop_prct_used' },
150 { name => 'vop_prct_free' }, { name => 'vop_total' }, { name => 'display' }
151 ],
152 closure_custom_output => $self->can('custom_voice_port_output'),
153 perfdatas => [
154 { template => '%d', min => 0, max => 'total', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }
155 ]
156 }
157 },
158 { label => 'cluster-voice-ports-prct', display_ok => 0, nlabel => 'dma.cluster.voice.port.percentage', set => {
159 key_values => [ { name => 'vop_prct_used' }, { name => 'display' } ],
160 output_template => 'voice ports used: %.2f %%',
161 perfdatas => [
162 { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }
163 ]
164 }
165 }
166 ];
167 }
168
169 sub new {
170 my ($class, %options) = @_;
171 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
172 bless $self, $class;
173
174 $options{options}->add_options(arguments => {
175 'filter-cluster:s' => { name => 'filter_cluster' }
176 });
177
178 return $self;
179 }
180
181 sub prefix_cluster_output {
182 my ($self, %options) = @_;
183
184 return "Cluster '" . $options{instance_value}->{display} . "' ";
185 }
186
187 my $mapping = {
188 useCMUsageClusterName => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.2' },
189 useCMUsageActiveConfs => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.3' },
190 useCMUsageActiveParts => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.4' },
191 useCMUsageTotalVideoPorts => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.5' },
192 useCMUsageUsedVideoPorts => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.6' },
193 useCMUsageTotalVoicePorts => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.7' },
194 useCMUsageUsedVoicePorts => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.8' },
195 useCMUsageLocalUsers => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.9' },
196 useCMUsageCustomConfRooms => { oid => '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1.10' },
197 };
198
199 my $oid_useConfMgrUsageEntry = '.1.3.6.1.4.1.13885.13.2.3.2.1.2.1';
200
201 sub manage_selection {
202 my ($self, %options) = @_;
203
204 my $oid_useConfMgrUsageCount = '.1.3.6.1.4.1.13885.13.2.3.2.1.1.0';
205 my $global_result = $options{snmp}->get_leef(oids => [$oid_useConfMgrUsageCount], nothing_quit => 1);
206
207 $self->{global} = { useConfMgrUsageCount => $global_result->{$oid_useConfMgrUsageCount} };
208
209 $self->{cluster} = {};
210 my $cluster_result = $options{snmp}->get_table(
211 oid => $oid_useConfMgrUsageEntry,
212 nothing_quit => 1
213 );
214
215 foreach my $oid (keys %{$cluster_result}) {
216 next if ($oid !~ /^$mapping->{useCMUsageClusterName}->{oid}\.(.*)$/);
217 my $instance = $1;
218 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $cluster_result, instance => $instance);
219
220 $result->{useCMUsageClusterName} = centreon::plugins::misc::trim($result->{useCMUsageClusterName});
221 if (defined($self->{option_results}->{filter_cluster}) && $self->{option_results}->{filter_cluster} ne '' &&
222 $result->{useCMUsageClusterName} !~ /$self->{option_results}->{filter_cluster}/) {
223 $self->{output}->output_add(long_msg => "skipping '" . $result->{useCMUsageClusterName} . "': no matching filter.", debug => 1);
224 next;
225 }
226
227 my ($video_port_used, $video_port_total) = ($result->{useCMUsageUsedVideoPorts},$result->{useCMUsageTotalVideoPorts});
228 my ($voice_port_used, $voice_port_total) = ($result->{useCMUsageUsedVoicePorts},$result->{useCMUsageTotalVoicePorts});
229
230 $self->{cluster}->{$instance} = {
231 display => $result->{useCMUsageClusterName},
232 vp_free => $video_port_total - $video_port_used,
233 vp_prct_free => ($video_port_total != 0) ? 100 - ($video_port_used * 100 / $video_port_total) : '0',
234 vp_prct_used => ($video_port_total != 0) ? $video_port_used * 100 / $video_port_total : '0',
235 vp_total => $video_port_total,
236 vp_used => $video_port_used,
237 vop_free => $voice_port_total - $voice_port_used,
238 vop_prct_free => ($voice_port_total != 0) ? 100 - ($voice_port_used * 100 / $voice_port_total) : '0',
239 vop_prct_used => ($voice_port_total != 0) ? $voice_port_used * 100 / $voice_port_total : '0',
240 vop_total => $voice_port_total,
241 vop_used => $voice_port_used,
242 %$result,
243 };
244 }
245
246 }
247
248 1;
249
250 __END__
251
252 =head1 MODE
253
254 Check conferences metrics.
255
256 =over 8
257
258 =item B<--filter-cluster>
259
260 Filter on one or several cluster (POSIX regexp)
261
262 =item B<--warning-* --critical-*>
263
264 TWarning & Critical Thresholds. Possible values:
265 [PER-CLUSTER] cluster-conferences, cluster-participants, cluster-local-users, cluster-custom-rooms,
266 cluster-video-ports-usage, cluster-video-ports-free, cluster-video-ports-prct,
267 cluster-voice-ports-usage, cluster-voice-ports-free, cluster-voice-ports-prct
268
269 [GLOBAL] dma-total-conferences
270
271 =back
272
273 =cut