Debian Codegraph @

src/network/sonus/sbc/snmp/mode/callstats.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::sonus::sbc::snmp::mode::callstats;
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_port_output {
30 my ($self, %options) = @_;
31
32 return "Port '" . $options{instance_value}->{display} . "' number of calls ";
33 }
34
35 sub set_counters {
36 my ($self, %options) = @_;
37
38 $self->{maps_counters_type} = [
39 { name => 'port', type => 1, cb_prefix_output => 'prefix_port_output', message_multiple => 'All ports call statistics are ok' }
40 ];
41
42 $self->{maps_counters}->{port} = [
43 { label => 'current', nlabel => 'port.calls.current.count', set => {
44 key_values => [ { name => 'current' }, { name => 'display' } ],
45 output_template => 'current: %s',
46 perfdatas => [
47 { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }
48 ]
49 }
50 },
51 { label => 'total', nlabel => 'port.calls.total.count', set => {
52 key_values => [ { name => 'total', diff => 1 }, { name => 'display' } ],
53 output_template => 'total: %s',
54 perfdatas => [
55 { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
56 ]
57 }
58 },
59 { label => 'connected', nlabel => 'port.calls.connected.count', set => {
60 key_values => [ { name => 'connected', diff => 1 }, { name => 'display' } ],
61 output_template => 'connected: %s',
62 perfdatas => [
63 { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
64 ]
65 }
66 },
67 { label => 'refused', nlabel => 'port.calls.refused.count', set => {
68 key_values => [ { name => 'refused', diff => 1 }, { name => 'display' } ],
69 output_template => 'refused: %s',
70 perfdatas => [
71 { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
72 ]
73 }
74 },
75 { label => 'errored', nlabel => 'port.calls.errored.count', set => {
76 key_values => [ { name => 'errored', diff => 1 }, { name => 'display' } ],
77 output_template => 'errored: %s',
78 perfdatas => [
79 { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
80 ]
81 }
82 },
83 { label => 'blocked', nlabel => 'port.calls.blocked.count', set => {
84 key_values => [ { name => 'blocked', diff => 1 }, { name => 'display' } ],
85 output_template => 'blocked: %s',
86 perfdatas => [
87 { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
88 ]
89 }
90 }
91 ];
92 }
93
94 sub new {
95 my ($class, %options) = @_;
96 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
97 bless $self, $class;
98
99 $options{options}->add_options(arguments => {});
100
101 return $self;
102 }
103
104 my $mapping = {
105 uxPTCurrentCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.5' },
106 uxPTTotalCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.6' },
107 uxPTConnectedCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.7' },
108 uxPTRefusedCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.8' },
109 uxPTErroredCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.9' },
110 uxPTBlockedCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.18' }
111 };
112 my $oid_uxPortTable = '.1.3.6.1.4.1.177.15.1.5.1.2.1';
113
114 sub manage_selection {
115 my ($self, %options) = @_;
116
117 my $snmp_result = $options{snmp}->get_table(
118 oid => $oid_uxPortTable,
119 nothing_quit => 1
120 );
121
122 foreach my $oid (keys %$snmp_result) {
123 next if ($oid !~ /^$mapping->{uxPTCurrentCalls}->{oid}\.(.*)$/);
124 my $instance = $1;
125 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
126
127 $self->{port}->{$instance} = {
128 current => $result->{uxPTCurrentCalls},
129 total => $result->{uxPTTotalCalls},
130 connected => $result->{uxPTConnectedCalls},
131 refused => $result->{uxPTRefusedCalls},
132 errored => $result->{uxPTErroredCalls},
133 blocked => $result->{uxPTBlockedCalls},
134 display => $instance
135 };
136 }
137
138 $self->{cache_name} = "sonus_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
139 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
140 }
141
142 1;
143
144 __END__
145
146 =head1 MODE
147
148 Check port call statistics.
149
150 =over 8
151
152 =item B<--warning-*> B<--critical-*>
153
154 Thresholds. Can be: 'current', 'total', 'connected', 'refused', 'errored', 'blocked'.
155
156 =back
157
158 =cut