| 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 centreon::common::cisco::standard::snmp::mode::voicecall; |
| 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 => 'gavg', type => 0, cb_prefix_output => 'prefix_gavg_output', message_separator => ' ', skipped_code => { -10 => 1 } }, |
| 33 |
{ name => 'ctype', type => 1, cb_prefix_output => 'prefix_ctype_output', message_multiple => 'All connection types are ok', skipped_code => { -10 => 1 } } |
| 34 |
]; |
| 35 |
|
| 36 |
$self->{maps_counters}->{gavg} = [ |
| 37 |
{ label => 'active-1m-average', nlabel => 'calls.active.1m.average.count', set => { |
| 38 |
key_values => [ { name => 'active_1m_average' } ], |
| 39 |
output_template => '%.2f (1m)', |
| 40 |
perfdatas => [ |
| 41 |
{ value => 'active_1m_average', template => '%.2f', min => 0 }, |
| 42 |
], |
| 43 |
} |
| 44 |
}, |
| 45 |
{ label => 'active-5m-average', nlabel => 'calls.active.5m.average.count', set => { |
| 46 |
key_values => [ { name => 'active_5m_average' } ], |
| 47 |
output_template => '%.2f (5m)', |
| 48 |
perfdatas => [ |
| 49 |
{ value => 'active_5m_average', template => '%.2f', min => 0 }, |
| 50 |
], |
| 51 |
} |
| 52 |
}, |
| 53 |
{ label => 'active-15m-average', nlabel => 'calls.active.15m.average.count', set => { |
| 54 |
key_values => [ { name => 'active_15m_average' } ], |
| 55 |
output_template => '%.2f (15m)', |
| 56 |
perfdatas => [ |
| 57 |
{ value => 'active_15m_average', template => '%.2f', min => 0 }, |
| 58 |
], |
| 59 |
} |
| 60 |
}, |
| 61 |
]; |
| 62 |
|
| 63 |
$self->{maps_counters}->{ctype} = [ |
| 64 |
{ label => 'connection-calls-active', nlabel => 'connection.calls.active.count', set => { |
| 65 |
key_values => [ { name => 'active_calls' }, { name => 'display' } ], |
| 66 |
output_template => 'active calls %s', |
| 67 |
perfdatas => [ |
| 68 |
{ value => 'active_calls', template => '%s', |
| 69 |
min => 0, label_extra_instance => 1 }, |
| 70 |
], |
| 71 |
} |
| 72 |
}, |
| 73 |
]; |
| 74 |
} |
| 75 |
|
| 76 |
sub prefix_gavg_output { |
| 77 |
my ($self, %options) = @_; |
| 78 |
|
| 79 |
return 'Calls active '; |
| 80 |
} |
| 81 |
|
| 82 |
sub prefix_ctype_output { |
| 83 |
my ($self, %options) = @_; |
| 84 |
|
| 85 |
return "Connection type '" . $options{instance_value}->{display} . "' "; |
| 86 |
} |
| 87 |
|
| 88 |
sub new { |
| 89 |
my ($class, %options) = @_; |
| 90 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); |
| 91 |
bless $self, $class; |
| 92 |
|
| 93 |
$options{options}->add_options(arguments => { |
| 94 |
}); |
| 95 |
|
| 96 |
return $self; |
| 97 |
} |
| 98 |
|
| 99 |
sub manage_selection { |
| 100 |
my ($self, %options) = @_; |
| 101 |
|
| 102 |
my %map_con_type = ( |
| 103 |
1 => 'h323', 2 => 'sip', 3 => 'mgcp', |
| 104 |
4 => 'sccp', 5 => 'multicast', |
| 105 |
6 => 'cacontrol', 7 => 'telephony', |
| 106 |
); |
| 107 |
my $oid_cvCallVolConnActiveConnection = '.1.3.6.1.4.1.9.9.63.1.3.8.1.1.2'; |
| 108 |
my $oid_cvActiveCallStatsAvgVal_min = '.1.3.6.1.4.1.9.9.63.1.4.3.3.1.4.2'; |
| 109 |
|
| 110 |
my $snmp_result = $options{snmp}->get_multiple_table( |
| 111 |
oids => [ |
| 112 |
{ oid => $oid_cvCallVolConnActiveConnection }, |
| 113 |
{ oid => $oid_cvActiveCallStatsAvgVal_min } |
| 114 |
], |
| 115 |
nothing_quit => 1 |
| 116 |
); |
| 117 |
|
| 118 |
$self->{ctype} = {}; |
| 119 |
foreach (keys %{$snmp_result->{ $oid_cvCallVolConnActiveConnection }}) { |
| 120 |
/\.(\d+)$/; |
| 121 |
$self->{ctype}->{$map_con_type{$1}} = { |
| 122 |
display => $map_con_type{$1}, |
| 123 |
active_calls => $snmp_result->{ $oid_cvCallVolConnActiveConnection }->{$_}, |
| 124 |
}; |
| 125 |
} |
| 126 |
|
| 127 |
my %definitions_avg = ( |
| 128 |
'active_1m_average' => [1, 1, 1, 0, 0], |
| 129 |
'active_5m_average' => [1, 5, 5, 0, 0], |
| 130 |
'active_15m_average' => [1, 15, 15, 0, 0], |
| 131 |
); |
| 132 |
foreach my $oid (keys %{$snmp_result->{ $oid_cvActiveCallStatsAvgVal_min }}) { |
| 133 |
$oid =~ /\.(\d+)$/; |
| 134 |
my $interval = $1; |
| 135 |
foreach (values %definitions_avg) { |
| 136 |
if ($interval >= $_->[0] && $interval <= $_->[1]) { |
| 137 |
$_->[3]++; |
| 138 |
$_->[4] += $snmp_result->{ $oid_cvActiveCallStatsAvgVal_min }->{$oid}; |
| 139 |
} |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
$self->{gavg} = {}; |
| 144 |
foreach (keys %definitions_avg) { |
| 145 |
next if ($definitions_avg{$_}->[2] != $definitions_avg{$_}->[3]); |
| 146 |
$self->{gavg}->{$_} = $definitions_avg{$_}->[4] / $definitions_avg{$_}->[2]; |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
1; |
| 151 |
|
| 152 |
__END__ |
| 153 |
|
| 154 |
=head1 MODE |
| 155 |
|
| 156 |
Check call traffic statistics (CISCO-VOICE-DIAL-CONTROL-MIB) |
| 157 |
|
| 158 |
=over 8 |
| 159 |
|
| 160 |
=item B<--warning-*> B<--critical-*> |
| 161 |
|
| 162 |
Thresholds. |
| 163 |
Can be: 'active-1m-average', 'active-5m-average', 'active-15m-average', |
| 164 |
'connection-calls-active'. |
| 165 |
|
| 166 |
=back |
| 167 |
|
| 168 |
=cut |