mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-28 16:14:21 +02:00
enhance audiocodes trunk status
This commit is contained in:
parent
9815ebaaf7
commit
f90433d476
@ -73,6 +73,7 @@ sub new {
|
|||||||
|
|
||||||
# Dont load MIB
|
# Dont load MIB
|
||||||
$SNMP::auto_init_mib = 0;
|
$SNMP::auto_init_mib = 0;
|
||||||
|
$ENV{MIBS} = '';
|
||||||
# For snmpv v1 - get request retries when you have "NoSuchName"
|
# For snmpv v1 - get request retries when you have "NoSuchName"
|
||||||
$self->{RetryNoSuch} = 1;
|
$self->{RetryNoSuch} = 1;
|
||||||
# Dont try to translate OID (we keep value)
|
# Dont try to translate OID (we keep value)
|
||||||
|
@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
my $instance_mode;
|
my $instance_mode;
|
||||||
|
|
||||||
@ -84,12 +85,39 @@ sub set_counters {
|
|||||||
closure_custom_threshold_check => $self->can('custom_status_threshold'),
|
closure_custom_threshold_check => $self->can('custom_status_threshold'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{ label => 'avg-calls', set => {
|
||||||
|
key_values => [ { name => 'acPMTrunkUtilizationAverage' }, { name => 'display' } ],
|
||||||
|
output_template => 'Average calls : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'avg_calls', value => 'acPMTrunkUtilizationAverage_absolute', template => '%d',
|
||||||
|
min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'max-calls', set => {
|
||||||
|
key_values => [ { name => 'acPMTrunkUtilizationMax' }, { name => 'display' } ],
|
||||||
|
output_template => 'Max calls : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'max_calls', value => 'acPMTrunkUtilizationMax_absolute', template => '%d',
|
||||||
|
min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'count-calls', set => {
|
||||||
|
key_values => [ { name => 'acPMTrunkUtilizationTotal' }, { name => 'display' } ],
|
||||||
|
output_template => 'Count calls : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'count_calls', value => 'acPMTrunkUtilizationTotal_absolute', template => '%d',
|
||||||
|
min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
@ -132,39 +160,58 @@ my %map_dchannel = (0 => 'dChannelEstablished', 1 => 'dChannelNotEstablished', 1
|
|||||||
my %map_deactivate = (0 => 'notAvailable', 1 => 'deActivated', 2 => 'activated');
|
my %map_deactivate = (0 => 'notAvailable', 1 => 'deActivated', 2 => 'activated');
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
acTrunkStatusDChannel => { oid => '.1.3.6.1.4.1.5003.9.10.9.2.1.1.1.6', map => \%map_dchannel },
|
status => {
|
||||||
acTrunkStatusAlarm => { oid => '.1.3.6.1.4.1.5003.9.10.9.2.1.1.1.7', map => \%map_alarm },
|
acTrunkStatusDChannel => { oid => '.1.3.6.1.4.1.5003.9.10.9.2.1.1.1.6', map => \%map_dchannel },
|
||||||
acTrunkDeactivate => { oid => '.1.3.6.1.4.1.5003.9.10.9.1.1.1.1.1.11', map => \%map_deactivate },
|
acTrunkStatusAlarm => { oid => '.1.3.6.1.4.1.5003.9.10.9.2.1.1.1.7', map => \%map_alarm },
|
||||||
acTrunkName => { oid => '.1.3.6.1.4.1.5003.9.10.9.1.1.1.1.1.13' },
|
acTrunkDeactivate => { oid => '.1.3.6.1.4.1.5003.9.10.9.1.1.1.1.1.11', map => \%map_deactivate },
|
||||||
|
acTrunkName => { oid => '.1.3.6.1.4.1.5003.9.10.9.1.1.1.1.1.13' },
|
||||||
|
},
|
||||||
|
usage => {
|
||||||
|
acPMTrunkUtilizationAverage => { oid => '.1.3.6.1.4.1.5003.10.10.2.21.1.4' },
|
||||||
|
acPMTrunkUtilizationMax => { oid => '.1.3.6.1.4.1.5003.10.10.2.21.1.5' },
|
||||||
|
acPMTrunkUtilizationTotal => { oid => '.1.3.6.1.4.1.5003.10.10.2.21.1.12' },
|
||||||
|
}
|
||||||
};
|
};
|
||||||
my $oid_acTrunkStatusEntry = '.1.3.6.1.4.1.5003.9.10.9.2.1.1.1';
|
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{trunk} = {};
|
$self->{trunk} = {};
|
||||||
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
|
my $oids = [];
|
||||||
{ oid => $mapping->{acTrunkName}->{oid} },
|
foreach (keys %{$mapping}) {
|
||||||
{ oid => $mapping->{acTrunkDeactivate}->{oid} },
|
foreach my $name (keys %{$mapping->{$_}}) {
|
||||||
{ oid => $oid_acTrunkStatusEntry },
|
push @{$oids}, { oid => $mapping->{$_}->{$name}->{oid} };
|
||||||
], nothing_quit => 1, return_type => 1);
|
}
|
||||||
|
}
|
||||||
|
my $snmp_result = $options{snmp}->get_multiple_table(oids => $oids, nothing_quit => 1);
|
||||||
|
|
||||||
foreach my $oid (keys %{$snmp_result}) {
|
my $datas = { status => {}, usage => {} };
|
||||||
next if ($oid !~ /^$mapping->{acTrunkStatusAlarm}->{oid}\.(.*)$/);
|
foreach (keys %{$mapping}) {
|
||||||
|
foreach my $name (keys %{$mapping->{$_}}) {
|
||||||
|
$datas->{$_} = { %{$datas->{$_}}, %{$snmp_result->{ $mapping->{$_}->{$name}->{oid} }} };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (keys %{$snmp_result->{ $mapping->{status}->{acTrunkStatusAlarm}->{oid} }}) {
|
||||||
|
/\.(\d+)$/;
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
my $result = $options{snmp}->map_instance(mapping => $mapping->{status}, results => $datas->{status}, instance => $instance);
|
||||||
|
my $result2 = $options{snmp}->map_instance(mapping => $mapping->{usage}, results => $datas->{usage}, instance => $instance . '.0');
|
||||||
|
|
||||||
$self->{trunk}->{$instance} = {
|
$self->{trunk}->{$instance} = {
|
||||||
display => defined($result->{acTrunkName}) && $result->{acTrunkName} ne '' ? $result->{acTrunkName} : $instance,
|
display => defined($result->{acTrunkName}) && $result->{acTrunkName} ne '' ? $result->{acTrunkName} : $instance,
|
||||||
alarm => $result->{acTrunkStatusAlarm},
|
alarm => $result->{acTrunkStatusAlarm},
|
||||||
state => $result->{acTrunkDeactivate},
|
state => $result->{acTrunkDeactivate},
|
||||||
dchannel => $result->{acTrunkStatusDChannel} };
|
dchannel => $result->{acTrunkStatusDChannel},
|
||||||
|
%$result2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{trunk}}) <= 0) {
|
if (scalar(keys %{$self->{trunk}}) <= 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => "No trunk found.");
|
$self->{output}->add_option_msg(short_msg => "No trunk found.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{cache_name} = "audiocodes_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
@ -173,7 +220,7 @@ __END__
|
|||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check vpn status.
|
Check trunk status.
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
@ -187,6 +234,17 @@ Can used special variables like: %{display}, %{alarm}, %{dchannel}, %{state}
|
|||||||
Set critical threshold for status (Default: '%{state} =~ /activated/ and %{alarm} !~ /greenActive/i').
|
Set critical threshold for status (Default: '%{state} =~ /activated/ and %{alarm} !~ /greenActive/i').
|
||||||
Can used special variables like: %{display}, %{alarm}, %{dchannel}, %{state}
|
Can used special variables like: %{display}, %{alarm}, %{dchannel}, %{state}
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Threshold warning.
|
||||||
|
Can be: 'avg-calls', 'max-calls', 'count-calls'.
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Threshold critical.
|
||||||
|
Can be: 'avg-calls', 'max-calls', 'count-calls'.
|
||||||
|
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
Loading…
x
Reference in New Issue
Block a user