add plugin avaya telephony media gateway in snmp

This commit is contained in:
garnier-quentin 2019-04-25 16:42:15 +02:00
parent 9652316f93
commit 7dc06ee4cf
6 changed files with 662 additions and 0 deletions

View File

@ -0,0 +1,120 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::common::avaya::snmp::mode::cpu;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'cpu', type => 1, cb_prefix_output => 'prefix_cpu_output', message_multiple => 'All CPUs are ok' },
];
$self->{maps_counters}->{cpu} = [
{ label => 'usage', nlabel => 'cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu' }, { name => 'display' } ],
output_template => 'usage : %s %%',
perfdatas => [
{ label => 'cpu_usage', value => 'cpu_absolute', template => '%s',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_cpu_output {
my ($self, %options) = @_;
return "CPU '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments => {
});
return $self;
}
my $map_cpu_monitoring = { 1 => 'disabled', 2 => 'enabled' };
my $mapping = {
genCpuUtilizationEnableMonitoring => { oid => '.1.3.6.1.4.1.6889.2.1.11.1.1.1.1.2', map => $map_cpu_monitoring },
genCpuAverageUtilization => { oid => '.1.3.6.1.4.1.6889.2.1.11.1.1.1.1.5' },
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_genCpuUtilizationEntry = '.1.3.6.1.4.1.6889.2.1.11.1.1.1.1';
my $results = $options{snmp}->get_table(oid => $oid_genCpuUtilizationEntry, nothing_quit => 1);
$self->{cpu} = {};
foreach my $oid (keys %{$results}) {
next if ($oid !~ /^$mapping->{genCpuAverageUtilization}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
if ($result->{genCpuUtilizationEnableMonitoring} eq 'disabled') {
next;
}
$self->{cpu}->{$instance} = {
display => $instance,
cpu => $result->{genCpuAverageUtilization},
};
}
if (scalar(keys %{$self->{cpu}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found (or cpu monitoring is disabled).");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check CPU usage.
=over 8
=item B<--warning-usage>
Threshold warning.
=item B<--critical-usage>
Threshold critical.
=back
=cut

View File

@ -0,0 +1,166 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::common::avaya::snmp::mode::memory;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub custom_usage_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(
label => 'used', unit => 'B',
nlabel => $self->{nlabel},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
value => $self->{result_values}->{used},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1),
min => 0, max => $self->{result_values}->{total}
);
}
sub custom_usage_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_usage_output {
my ($self, %options) = @_;
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
return $msg;
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'};
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
$self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'memory', type => 1, cb_prefix_output => 'prefix_memory_output', message_multiple => 'All memory usages are ok' }
];
$self->{maps_counters}->{memory} = [
{ label => 'usage', nlabel => 'memory.usage.bytes', set => {
key_values => [ { name => 'display' }, { name => 'total' }, { name => 'used' } ],
closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
}
},
];
}
sub prefix_memory_output {
my ($self, %options) = @_;
if ($self->{multiple} == 1) {
return "Memory '" . $options{instance_value}->{display} . "' ";
}
return '';
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments => {
});
return $self;
}
my $mapping = {
genMemUtilizationPhyRam => { oid => '.1.3.6.1.4.1.6889.2.1.11.1.2.6.1.2' }, # in Bytes
genMemUtilizationPercentUsed => { oid => '.1.3.6.1.4.1.6889.2.1.11.1.2.6.1.3' },
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_genMemUtilizationEntry = '.1.3.6.1.4.1.6889.2.1.11.1.2.6.1';
my $results = $options{snmp}->get_table(oid => $oid_genMemUtilizationEntry, nothing_quit => 1);
$self->{memory} = {};
foreach my $oid (keys %{$results}) {
next if ($oid !~ /^$mapping->{genMemUtilizationPercentUsed}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
my $total = $result->{genMemUtilizationPhyRam};
my $used = sprintf('%d', $total * $result->{genMemUtilizationPercentUsed} / 100);
$self->{memory}->{$instance} = {
display => $instance,
used => $used,
total => $total
};
}
if (scalar(keys %{$self->{memory}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check memory usages.
=over 8
=item B<--warning-usage>
Threshold warning (in percent).
=item B<--critical-usage>
Threshold critical (in percent).
=back
=cut

View File

@ -0,0 +1,88 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::telephony::avaya::mediagateway::snmp::mode::components::alarm;
use strict;
use warnings;
sub load {}
my $bits_alarm = {
0 => 'at least two fans have been operating at less than 90% of their nominal speed for 5 minutes or more',
1 => 'the power supply fan has been operating at less than 90% of its nominal speed for 10 minutes or more, but less than 15 minutes',
2 => 'the power supply fan has been operating at less than 90% of its nominal speed for 15 minutes or more',
4 => 'cmgCpuTemp has exceeded its warning threshold',
5 => 'mgDspTemp has exceeded its warning threshold',
7 => 'Power On Status Test failure -NCE, QUICC test failures on power up',
8 => 'The +5.1 v power supply to the MG processor is out of range',
9 => 'The +3.3 v power supply to the VoIP complexes is out of range',
10 => 'The +3.3 v power supply to the VoIP complexes is out of range',
11 => 'The +1.58 v power supply to the DSP units is out of range',
12 => 'The +2.5 v power supply to the 8260 processor is out of range',
13 => 'The -48 v auxiliary power supply to the endpoints is out of range',
14 => 'The +12 v power supply to the fans is out of range',
16 => 'Clock synchronization signal is lost',
17 => 'Clock synchronization signal warning. Only one clock syncronization signal source remains',
18 => 'Clock synchronization signal excessive switching',
19 => 'TDM Test Expansion Box 1 Failure',
20 => 'TDM Test Expansion Box 2 Failure',
21 => 'PoE Power Supply Base Box Failure',
22 => 'PoE Power Supply Expansion Box 1 Failure',
23 => 'PoE Power Supply Expansion Box 2 Failure',
};
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking alarms");
$self->{components}->{alarm} = { name => 'alarms', total => 0, skip => 0 };
return if ($self->check_filter(section => 'alarm'));
my $oid_cmgHardwareFaultMask = '.1.3.6.1.4.1.6889.2.9.1.1.10.12.0';
return if (!defined($self->{results}->{$oid_cmgHardwareFaultMask}));
$self->{results}->{$oid_cmgHardwareFaultMask} = oct("0b" . unpack('b*', $self->{results}->{$oid_cmgHardwareFaultMask}));
foreach (sort { $a <=> $b } keys %$bits_alarm) {
my $instance = $_;
my $status = 'disabled';
if (($self->{results}->{$oid_cmgHardwareFaultMask} & (1 << $_))) {
$status = 'enabled';
}
next if ($self->check_filter(section => 'alarm', instance => $instance));
$self->{components}->{alarm}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"alarm '%s' status is '%s' [instance: %s]",
$bits_alarm->{$_}, $status, $instance
)
);
my $exit = $self->get_severity(section => 'alarm', instance => $instance, value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Alarm '%s' status is '%s'",
$bits_alarm->{$_}, $status));
}
}
}
1;

View File

@ -0,0 +1,139 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::telephony::avaya::mediagateway::snmp::mode::controllerstatus;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions;
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf("controller registration state is '%s' [h248 link status: '%s']", $self->{result_values}->{registration_state}, $self->{result_values}->{h248_link_status});
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{registration_state} = $options{new_datas}->{$self->{instance} . '_cmgRegistrationState'};
$self->{result_values}->{h248_link_status} = $options{new_datas}->{$self->{instance} . '_cmgH248LinkStatus'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
];
$self->{maps_counters}->{global} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'cmgRegistrationState' }, { name => 'cmgH248LinkStatus' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&centreon::plugins::templates::catalog_functions::catalog_status_threshold,
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments => {
"unknown-status:s" => { name => 'unknown_status', default => '' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{h248_link_status} =~ /down/i || %{registration_state} =~ /notRegistred/i' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']);
}
my %map_registration_state = (
1 => 'registred',
2 => 'notRegistred',
);
my %map_h248_link_status = (
1 => 'up',
2 => 'down',
);
my $mapping = {
cmgRegistrationState => { oid => '.1.3.6.1.4.1.6889.2.9.1.3.1', map => \%map_registration_state },
cmgH248LinkStatus => { oid => '.1.3.6.1.4.1.6889.2.9.1.3.3', map => \%map_h248_link_status },
};
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_leef(
oids => [$mapping->{cmgRegistrationState}->{oid}, $mapping->{cmgH248LinkStatus}->{oid}],
nothing_quit => 1
);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0');
$self->{global} = { %$result };
}
1;
__END__
=head1 MODE
Check controller status.
=over 8
=item B<--unknown-status>
Set warning threshold for status (Default: '%{status} =~ /unknown/i').
Can used special variables like: %{h248_link_status}, %{registration_state}
=item B<--warning-status>
Set warning threshold for status (Default: '%{status} =~ /batteryLow/i').
Can used special variables like: %{h248_link_status}, %{registration_state}
=item B<--critical-status>
Set critical threshold for status (Default: '%{h248_link_status} =~ /down/i || %{registration_state} =~ /notRegistred/i').
Can used special variables like: %{h248_link_status}, %{registration_state}
=back
=cut

View File

@ -0,0 +1,98 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::telephony::avaya::mediagateway::snmp::mode::hardware;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(alarm)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
alarm => [
['enabled', 'CRITICAL'],
['disabled', 'OK'],
],
};
$self->{components_path} = 'hardware::telephony::avaya::mediagateway::snmp::mode::components';
$self->{components_module} = ['alarm'];
}
sub snmp_execute {
my ($self, %options) = @_;
my $oid_cmgHardwareFaultMask = '.1.3.6.1.4.1.6889.2.9.1.1.10.12.0';
$self->{results} = $options{snmp}->get_leef(oids => [$oid_cmgHardwareFaultMask]);
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments => {
});
return $self;
}
1;
__END__
=head1 MODE
Check hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'alarm'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=alarm)
Can also exclude specific instance: --filter=alarm,1
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='alarm,1,OK,enabled'
=back
=cut

View File

@ -0,0 +1,51 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::telephony::avaya::mediagateway::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'controller-status' => 'hardware::telephony::avaya::mediagateway::snmp::mode::controllerstatus',
'cpu' => 'centreon::common::avaya::snmp::mode::cpu',
'hardware' => 'hardware::telephony::avaya::mediagateway::snmp::mode::hardware',
'memory' => 'centreon::common::avaya::snmp::mode::memory',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check avaya mediagateway equipment in SNMP.
=cut