Debian Codegraph @

src/network/mitel/3300icp/snmp/mode/zapcalls.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 network::mitel::3300icp::snmp::mode::zapcalls;
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 set_counters {
30 my ($self, %options) = @_;
31
32 $self->{maps_counters_type} = [
33 { name => 'zap', type => 1, cb_prefix_output => 'prefix_zap_output', message_multiple => 'All zone access points are ok' },
34 ];
35
36 $self->{maps_counters}->{zap} = [
37 { label => 'admitted', set => {
38 key_values => [ { name => 'mitelBWMCumCACAdmissions', diff => 1 }, { name => 'display' } ],
39 output_template => 'Admitted calls: %s',
40 perfdatas => [
41 { label => 'admitted', value => 'mitelBWMCumCACAdmissions', template => '%s',
42 min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' },
43 ],
44 }
45 },
46 { label => 'rejected', set => {
47 key_values => [ { name => 'mitelBWMCumCACRejections', diff => 1 }, { name => 'display' } ],
48 output_template => 'Rejected calls: %s',
49 perfdatas => [
50 { label => 'rejected', value => 'mitelBWMCumCACRejections', template => '%s',
51 min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' },
52 ],
53 }
54 },
55 { label => 'rejection-ratio', set => {
56 key_values => [ { name => 'mitelBWMCumCACRejectionRatio' }, { name => 'display' } ],
57 output_template => 'Rejection ratio: %s%%',
58 perfdatas => [
59 { label => 'rejection_ratio', value => 'mitelBWMCumCACRejectionRatio', template => '%s',
60 min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' },
61 ],
62 }
63 },
64 ];
65 }
66
67 sub prefix_zap_output {
68 my ($self, %options) = @_;
69
70 return "Zone access point '" . $options{instance_value}->{display} . "' ";
71 }
72
73 sub new {
74 my ($class, %options) = @_;
75 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
76 bless $self, $class;
77
78 $options{options}->add_options(arguments =>
79 {
80 "filter-name:s" => { name => 'filter_name' },
81 });
82
83 return $self;
84 }
85
86 sub check_options {
87 my ($self, %options) = @_;
88 $self->SUPER::check_options(%options);
89 }
90
91 my $oid_mitelBWMCumZAPLabel = '.1.3.6.1.4.1.1027.4.1.1.2.5.1.1.2.1.4',
92 my $mapping = {
93 mitelBWMCumCACAdmissions => { oid => '.1.3.6.1.4.1.1027.4.1.1.2.5.1.1.2.1.5' },
94 mitelBWMCumCACRejections => { oid => '.1.3.6.1.4.1.1027.4.1.1.2.5.1.1.2.1.6' },
95 mitelBWMCumCACRejectionRatio => { oid => '.1.3.6.1.4.1.1027.4.1.1.2.5.1.1.2.1.7' },
96 };
97
98 sub manage_selection {
99 my ($self, %options) = @_;
100
101 $self->{zap} = {};
102 my $snmp_result = $options{snmp}->get_table(oid => $oid_mitelBWMCumZAPLabel, nothing_quit => 1);
103 foreach my $oid (keys %{$snmp_result}) {
104 $oid =~ /^$oid_mitelBWMCumZAPLabel\.(.*)$/;
105 my $instance = $1;
106 if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
107 $snmp_result->{$oid} !~ /$self->{option_results}->{filter_name}/) {
108 $self->{output}->output_add(long_msg => "skipping '" . $snmp_result->{$oid} . "'.", debug => 1);
109 next;
110 }
111
112 $self->{zap}->{$instance} = { display => $snmp_result->{$oid} };
113 }
114
115 $options{snmp}->load(oids => [ $mapping->{mitelBWMCumCACAdmissions}->{oid},
116 $mapping->{mitelBWMCumCACRejections}->{oid},
117 $mapping->{mitelBWMCumCACRejectionRatio}->{oid} ],
118 instances => [ keys %{$self->{zap}} ],
119 instance_regexp => '^(.*)$');
120 $snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
121
122 foreach (keys %{$self->{zap}}) {
123 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
124
125 foreach my $name (keys %{$mapping}) {
126 $self->{zap}->{$_}->{$name} = $result->{$name};
127 }
128 }
129
130 if (scalar(keys %{$self->{zap}}) <= 0) {
131 $self->{output}->add_option_msg(short_msg => "No zone access points found.");
132 $self->{output}->option_exit();
133 }
134
135 $self->{cache_name} = "mitel_3300icp_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
136 (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
137 }
138
139 1;
140
141 __END__
142
143 =head1 MODE
144
145 Check zone access points calls.
146
147 =over 8
148
149 =item B<--filter-name>
150
151 Filter by zone access points name (can be a regexp).
152
153 =item B<--warning-*>
154
155 Warning threshold.
156 Can be: 'admitted', 'rejected', 'rejection-ratio' (%).
157
158 =item B<--critical-*>
159
160 Critical threshold.
161 Can be: 'admitted', 'rejected', 'rejection-ratio' (%).
162
163 =back
164
165 =cut
166