| 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::inin::ig::snmp::mode::stats; |
| 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 => 'global', type => 0, message_separator => ' - ' }, |
| 33 |
{ name => 'cg', type => 1, cb_prefix_output => 'prefix_cg_output', message_multiple => 'All channel groups are ok' } |
| 34 |
]; |
| 35 |
|
| 36 |
$self->{maps_counters}->{global} = [ |
| 37 |
{ label => 'sip-active-calls', set => { |
| 38 |
key_values => [ { name => 'SipActiveCallsCount' } ], |
| 39 |
output_template => 'SIP Current Active Calls : %s', |
| 40 |
perfdatas => [ |
| 41 |
{ label => 'sip_active_calls', value => 'SipActiveCallsCount', template => '%d', |
| 42 |
min => 0 }, |
| 43 |
], |
| 44 |
} |
| 45 |
}, |
| 46 |
{ label => 'tdm-active-calls', set => { |
| 47 |
key_values => [ { name => 'TdmActiveCallsCount' } ], |
| 48 |
output_template => 'TDM Current Active Calls : %s', |
| 49 |
perfdatas => [ |
| 50 |
{ label => 'tdm_active_calls', value => 'TdmActiveCallsCount', template => '%d', |
| 51 |
min => 0 }, |
| 52 |
], |
| 53 |
} |
| 54 |
}, |
| 55 |
]; |
| 56 |
$self->{maps_counters}->{cg} = [ |
| 57 |
{ label => 'channel-group-active-calls', set => { |
| 58 |
key_values => [ { name => 'i3IgChannelGroupActiveCallsCount' }, { name => 'display' } ], |
| 59 |
output_template => 'Current Active Calls : %s', |
| 60 |
perfdatas => [ |
| 61 |
{ label => 'channel_group_active_calls', value => 'i3IgChannelGroupActiveCallsCount', template => '%d', |
| 62 |
min => 0, label_extra_instance => 1, instance_use => 'display' }, |
| 63 |
], |
| 64 |
} |
| 65 |
}, |
| 66 |
]; |
| 67 |
} |
| 68 |
|
| 69 |
sub new { |
| 70 |
my ($class, %options) = @_; |
| 71 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 72 |
bless $self, $class; |
| 73 |
|
| 74 |
$options{options}->add_options(arguments => |
| 75 |
{ |
| 76 |
"filter-name:s" => { name => 'filter_name' }, |
| 77 |
}); |
| 78 |
|
| 79 |
return $self; |
| 80 |
} |
| 81 |
|
| 82 |
sub prefix_cg_output { |
| 83 |
my ($self, %options) = @_; |
| 84 |
|
| 85 |
return "Channel group '" . $options{instance_value}->{display} . "' "; |
| 86 |
} |
| 87 |
|
| 88 |
my $mapping = { |
| 89 |
i3IgChannelGroupName => { oid => '.1.3.6.1.4.1.2793.4.2.13.1.2' }, |
| 90 |
i3IgChannelGroupActiveCallsCount => { oid => '.1.3.6.1.4.1.2793.4.2.13.1.3' }, |
| 91 |
}; |
| 92 |
my $oid_i3IgInfo = '.1.3.6.1.4.1.2793.4.2'; |
| 93 |
my $oid_i3IgSipActiveCallsCount = '.1.3.6.1.4.1.2793.4.2.4'; |
| 94 |
my $oid_i3IgTdmActiveCallsCount = '.1.3.6.1.4.1.2793.4.2.7'; |
| 95 |
|
| 96 |
sub manage_selection { |
| 97 |
my ($self, %options) = @_; |
| 98 |
|
| 99 |
$self->{cg} = {}; |
| 100 |
my $snmp_result = $options{snmp}->get_table(oid => $oid_i3IgInfo, start => $oid_i3IgSipActiveCallsCount, |
| 101 |
nothing_quit => 1); |
| 102 |
|
| 103 |
foreach my $oid (keys %{$snmp_result}) { |
| 104 |
next if ($oid !~ /^$mapping->{i3IgChannelGroupActiveCallsCount}->{oid}\.(.*)$/); |
| 105 |
my $instance = $1; |
| 106 |
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); |
| 107 |
|
| 108 |
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && |
| 109 |
$result->{i3IgChannelGroupName} !~ /$self->{option_results}->{filter_name}/) { |
| 110 |
$self->{output}->output_add(long_msg => "skipping '" . $result->{i3IgSpanInfoSpanId} . "': no matching filter.", debug => 1); |
| 111 |
next; |
| 112 |
} |
| 113 |
|
| 114 |
$self->{cg}->{$instance} = { display => $result->{i3IgChannelGroupName}, %$result }; |
| 115 |
} |
| 116 |
|
| 117 |
$self->{global} = { |
| 118 |
SipActiveCallsCount => $snmp_result->{$oid_i3IgSipActiveCallsCount . '.0'}, |
| 119 |
TdmActiveCallsCount => $snmp_result->{$oid_i3IgTdmActiveCallsCount . '.0'}, |
| 120 |
}; |
| 121 |
} |
| 122 |
|
| 123 |
1; |
| 124 |
|
| 125 |
__END__ |
| 126 |
|
| 127 |
=head1 MODE |
| 128 |
|
| 129 |
Check statistics. |
| 130 |
|
| 131 |
=over 8 |
| 132 |
|
| 133 |
=item B<--filter-counters> |
| 134 |
|
| 135 |
Only display some counters (regexp can be used). |
| 136 |
Example: --filter-counters='^sip-active-calls$' |
| 137 |
|
| 138 |
=item B<--filter-name> |
| 139 |
|
| 140 |
Filter channel group name (can be a regexp). |
| 141 |
|
| 142 |
=item B<--warning-*> |
| 143 |
|
| 144 |
Warning threshold. |
| 145 |
Can be: 'sip-active-calls', 'tdm-active-calls', |
| 146 |
'channel-group-active-calls'. |
| 147 |
|
| 148 |
=item B<--critical-*> |
| 149 |
|
| 150 |
Critical threshold. |
| 151 |
Can be: 'sip-active-calls', 'tdm-active-calls', |
| 152 |
'channel-group-active-calls'. |
| 153 |
|
| 154 |
=back |
| 155 |
|
| 156 |
=cut |