| 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 apps::voip::asterisk::snmp::mode::channelusage; |
| 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 => 'global', type => 0 }, |
| 34 |
]; |
| 35 |
$self->{maps_counters}->{global} = [ |
| 36 |
{ label => 'channels-active', nlabel => 'channels.active.count', set => { |
| 37 |
key_values => [ { name => 'channels_active' } ], |
| 38 |
output_template => 'channels active: %s', |
| 39 |
perfdatas => [ |
| 40 |
{ label => 'channels_active', template => '%s', min => 0 } |
| 41 |
] |
| 42 |
} |
| 43 |
}, |
| 44 |
{ label => 'calls-active', nlabel => 'calls.active.count', set => { |
| 45 |
key_values => [ { name => 'calls_active' } ], |
| 46 |
output_template => 'calls active: %s', |
| 47 |
perfdatas => [ |
| 48 |
{ label => 'calls_active', template => '%s', min => 0 } |
| 49 |
] |
| 50 |
} |
| 51 |
}, |
| 52 |
{ label => 'calls-count', nlabel => 'calls.processed.count', set => { |
| 53 |
key_values => [ { name => 'calls_count', diff => 1 } ], |
| 54 |
output_template => 'calls count: %s', |
| 55 |
perfdatas => [ |
| 56 |
{ label => 'calls_count', template => '%s', min => 0 } |
| 57 |
] |
| 58 |
} |
| 59 |
} |
| 60 |
]; |
| 61 |
} |
| 62 |
|
| 63 |
sub new { |
| 64 |
my ($class, %options) = @_; |
| 65 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); |
| 66 |
bless $self, $class; |
| 67 |
|
| 68 |
$options{options}->add_options(arguments => |
| 69 |
{ |
| 70 |
}); |
| 71 |
|
| 72 |
return $self; |
| 73 |
} |
| 74 |
|
| 75 |
sub manage_selection { |
| 76 |
my ($self, %options) = @_; |
| 77 |
|
| 78 |
my $oid_astConfigCallsActive = '.1.3.6.1.4.1.22736.1.2.5.0'; |
| 79 |
my $oid_astConfigCallsProcessed = '.1.3.6.1.4.1.22736.1.2.6.0'; |
| 80 |
my $oid_astNumChannels = '.1.3.6.1.4.1.22736.1.5.1.0'; |
| 81 |
my $result = $options{snmp}->get_leef(oids => [$oid_astConfigCallsActive, $oid_astConfigCallsProcessed, $oid_astNumChannels], nothing_quit => 1); |
| 82 |
|
| 83 |
$self->{cache_name} = "asterisk_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . |
| 84 |
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); |
| 85 |
|
| 86 |
$self->{global} = { |
| 87 |
calls_active => $result->{$oid_astConfigCallsActive}, |
| 88 |
calls_count => $result->{$oid_astConfigCallsProcessed}, |
| 89 |
channels_active => $result->{$oid_astNumChannels}, |
| 90 |
}; |
| 91 |
} |
| 92 |
|
| 93 |
1; |
| 94 |
|
| 95 |
__END__ |
| 96 |
|
| 97 |
=head1 MODE |
| 98 |
|
| 99 |
Check channel usage. |
| 100 |
|
| 101 |
=over 8 |
| 102 |
|
| 103 |
=item B<--filter-counters> |
| 104 |
|
| 105 |
Only display some counters (regexp can be used). |
| 106 |
Example: --filter-counters='calls-active' |
| 107 |
|
| 108 |
=item B<--warning-*> |
| 109 |
|
| 110 |
Warning threshold. |
| 111 |
Can be: 'channels-active', 'calls-active', 'calls-count'. |
| 112 |
|
| 113 |
=item B<--critical-*> |
| 114 |
|
| 115 |
Critical threshold. |
| 116 |
Can be: 'channels-active', 'calls-active', 'calls-count'. |
| 117 |
|
| 118 |
=back |
| 119 |
|
| 120 |
=cut |