add polycom groupseries plugin snmp

This commit is contained in:
garnier-quentin 2019-08-09 13:50:01 +02:00
parent 010e347e6a
commit e21ccd3d2f
10 changed files with 707 additions and 0 deletions

View File

@ -0,0 +1,70 @@
#
# 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::polycom::endpoint::snmp::mode::components::board;
use strict;
use warnings;
use centreon::common::polycom::endpoint::snmp::mode::components::resources qw($map_status);
my $mapping = {
hardwareUcBoardStatus => { oid => '.1.3.6.1.4.1.13885.101.1.3.12.1', map => $map_status },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{hardwareUcBoardStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "checking boards");
$self->{components}->{board} = {name => 'board', total => 0, skip => 0};
return if ($self->check_filter(section => 'board'));
return if (!defined($self->{results}->{ $mapping->{hardwareUcBoardStatus}->{oid} }) ||
scalar(keys %{$self->{results}->{ $mapping->{hardwareUcBoardStatus}->{oid} }}) <= 0);
my $instance = '0';
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{hardwareUcBoardStatus}->{oid} }, instance => $instance);
return if ($self->check_filter(section => 'board', instance => $instance));
$self->{components}->{board}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
'overall boards status is %s [instance: %s]',
$result->{hardwareUcBoardStatus}, $instance
)
);
my $exit = $self->get_severity(section => 'board', label => 'default', value => $result->{hardwareUcBoardStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg =>
sprintf('Overall boards status is %s', $result->{hardwareUcBoardStatus}
)
);
}
}
1;

View File

@ -0,0 +1,77 @@
#
# 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::polycom::endpoint::snmp::mode::components::camera;
use strict;
use warnings;
use centreon::common::polycom::endpoint::snmp::mode::components::resources qw($map_status);
my $mapping = {
hardwareCameraCamerasName => { oid => '.1.3.6.1.4.1.13885.101.1.3.6.2.1.2' },
hardwareCameraCamerasStatus => { oid => '.1.3.6.1.4.1.13885.101.1.3.6.2.1.3', map => $map_status },
};
my $oid_hardwareCameraCamerasEntry = '.1.3.6.1.4.1.13885.101.1.3.6.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_hardwareCameraCamerasEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "checking cameras");
$self->{components}->{camera} = {name => 'cameras', total => 0, skip => 0};
return if ($self->check_filter(section => 'camera'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hardwareCameraCamerasEntry}})) {
next if ($oid !~ /^$mapping->{hardwareCameraCamerasStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hardwareCameraCamerasEntry}, instance => $instance);
next if ($self->check_filter(section => 'camera', instance => $instance));
$self->{components}->{camera}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"camera '%s' status is '%s' [instance = %s]",
$result->{hardwareCameraCamerasName},
$result->{hardwareCameraCamerasStatus},
$instance,
)
);
my $exit = $self->get_severity(label => 'default', section => 'camera', instance => $instance, value => $result->{hardwareCameraCamerasStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Camera '%s' status is '%s'",
$result->{hardwareCameraCamerasName},
$result->{hardwareCameraCamerasStatus}
)
);
}
}
}
1;

View File

@ -0,0 +1,70 @@
#
# 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::polycom::endpoint::snmp::mode::components::global;
use strict;
use warnings;
use centreon::common::polycom::endpoint::snmp::mode::components::resources qw($map_status);
my $mapping = {
hardwareOverallStatus => { oid => '.1.3.6.1.4.1.13885.101.1.3.1', map => $map_status },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{hardwareOverallStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "checking global");
$self->{components}->{global} = {name => 'global', total => 0, skip => 0};
return if ($self->check_filter(section => 'global'));
return if (!defined($self->{results}->{ $mapping->{hardwareOverallStatus}->{oid} }) ||
scalar(keys %{$self->{results}->{ $mapping->{hardwareOverallStatus}->{oid} }}) <= 0);
my $instance = '0';
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{hardwareOverallStatus}->{oid} }, instance => $instance);
return if ($self->check_filter(section => 'global', instance => $instance));
$self->{components}->{global}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
'overall global status is %s [instance: %s]',
$result->{hardwareOverallStatus}, $instance
)
);
my $exit = $self->get_severity(section => 'global', label => 'default', value => $result->{hardwareOverallStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg =>
sprintf('Overall global status is %s', $result->{hardwareOverallStatus}
)
);
}
}
1;

View File

@ -0,0 +1,77 @@
#
# 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::polycom::endpoint::snmp::mode::components::microphone;
use strict;
use warnings;
use centreon::common::polycom::endpoint::snmp::mode::components::resources qw($map_status);
my $mapping = {
hardwareMicrophoneMicrophonesName => { oid => '.1.3.6.1.4.1.13885.101.1.3.5.2.1.2' },
hardwareMicrophoneMicrophonesStatus => { oid => '.1.3.6.1.4.1.13885.101.1.3.5.2.1.3', map => $map_status },
};
my $oid_hardwareMicrophoneMicrophonesEntry = '.1.3.6.1.4.1.13885.101.1.3.5.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_hardwareMicrophoneMicrophonesEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "checking microphones");
$self->{components}->{microphone} = {name => 'microphones', total => 0, skip => 0};
return if ($self->check_filter(section => 'microphone'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hardwareMicrophoneMicrophonesEntry}})) {
next if ($oid !~ /^$mapping->{hardwareMicrophoneMicrophonesStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hardwareMicrophoneMicrophonesEntry}, instance => $instance);
next if ($self->check_filter(section => 'microphone', instance => $instance));
$self->{components}->{microphone}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"microphone '%s' status is '%s' [instance = %s]",
$result->{hardwareMicrophoneMicrophonesName},
$result->{hardwareMicrophoneMicrophonesStatus},
$instance,
)
);
my $exit = $self->get_severity(label => 'default', section => 'microphone', instance => $instance, value => $result->{hardwareMicrophoneMicrophonesStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Microphone '%s' status is '%s'",
$result->{hardwareMicrophoneMicrophonesName},
$result->{hardwareMicrophoneMicrophonesStatus}
)
);
}
}
}
1;

View File

@ -0,0 +1,77 @@
#
# 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::polycom::endpoint::snmp::mode::components::nic;
use strict;
use warnings;
use centreon::common::polycom::endpoint::snmp::mode::components::resources qw($map_status);
my $mapping = {
hardwareNICNICsName => { oid => '.1.3.6.1.4.1.13885.101.1.3.10.2.1.2' },
hardwareNICNICsStatus => { oid => '.1.3.6.1.4.1.13885.101.1.3.10.2.1.6', map => $map_status },
};
my $oid_hardwareNICNICsEntry = '.1.3.6.1.4.1.13885.101.1.3.10.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_hardwareNICNICsEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "checking nics");
$self->{components}->{nic} = {name => 'nics', total => 0, skip => 0};
return if ($self->check_filter(section => 'nic'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hardwareNICNICsEntry}})) {
next if ($oid !~ /^$mapping->{hardwareNICNICsStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hardwareNICNICsEntry}, instance => $instance);
next if ($self->check_filter(section => 'nic', instance => $instance));
$self->{components}->{nic}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"nic '%s' status is '%s' [instance = %s]",
$result->{hardwareNICNICsName},
$result->{hardwareNICNICsStatus},
$instance,
)
);
my $exit = $self->get_severity(label => 'default', section => 'nic', instance => $instance, value => $result->{hardwareNICNICsStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Nic '%s' status is '%s'",
$result->{hardwareNICNICsName},
$result->{hardwareNICNICsStatus}
)
);
}
}
}
1;

View File

@ -0,0 +1,70 @@
#
# 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::polycom::endpoint::snmp::mode::components::ptc;
use strict;
use warnings;
use centreon::common::polycom::endpoint::snmp::mode::components::resources qw($map_status);
my $mapping = {
hardwarePTCStatus => { oid => '.1.3.6.1.4.1.13885.101.1.3.11.1', map => $map_status },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{hardwarePTCStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "checking polycom touch control");
$self->{components}->{ptc} = {name => 'ptc', total => 0, skip => 0};
return if ($self->check_filter(section => 'ptc'));
return if (!defined($self->{results}->{ $mapping->{hardwarePTCStatus}->{oid} }) ||
scalar(keys %{$self->{results}->{ $mapping->{hardwarePTCStatus}->{oid} }}) <= 0);
my $instance = '0';
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{hardwarePTCStatus}->{oid} }, instance => $instance);
return if ($self->check_filter(section => 'ptc', instance => $instance));
$self->{components}->{ptc}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
'overall polycom touch control status is %s [instance: %s]',
$result->{hardwarePTCStatus}, $instance
)
);
my $exit = $self->get_severity(section => 'ptc', label => 'default', value => $result->{hardwarePTCStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg =>
sprintf('Overall polycom touch control status is %s', $result->{hardwarePTCStatus}
)
);
}
}
1;

View File

@ -0,0 +1,36 @@
#
# 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::polycom::endpoint::snmp::mode::components::resources;
use strict;
use warnings;
use Exporter;
our $map_status;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw($map_status);
$map_status = {
1 => 'disabled', 2 => 'ok', 3 => 'failed',
};
1;

View File

@ -0,0 +1,97 @@
#
# 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::polycom::endpoint::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} = '^(?:global|microphone|camera|nic|ptc|board)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
default => [
['ok', 'OK'],
['disabled', 'OK'],
['failed', 'CRITICAL'],
],
};
$self->{components_path} = 'centreon::common::polycom::endpoint::snmp::mode::components';
$self->{components_module} = ['global', 'microphone', 'camera', 'nic', 'ptc', 'board'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1, no_absent => 1, force_new_perfdata => 1);
bless $self, $class;
$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: 'global', 'microphone', 'camera', 'nic', 'ptc', 'board'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=camera)
Can also exclude specific instance: --filter=camera,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='camera,WARNING,disabled'
=back
=cut

View File

@ -0,0 +1,84 @@
#
# 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::polycom::endpoint::snmp::mode::videoconferencing;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
];
$self->{maps_counters}->{global} = [
{ label => 'conferences-active', nlabel => 'videoconferencing.conferences.active.count', set => {
key_values => [ { name => 'NumberActiveConferences' } ],
output_template => 'Current Conferences : %s',
perfdatas => [
{ label => 'conferences_active', value => 'NumberActiveConferences_absolute', template => '%d', min => 0 },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_conferenceNumberActiveConferences = '.1.3.6.1.4.1.13885.101.1.5.1.0';
my $results = $options{snmp}->get_leef(oids => [$oid_conferenceNumberActiveConferences], nothing_quit => 1);
$self->{global} = { NumberActiveConferences => $results->{$oid_conferenceNumberActiveConferences} };
}
1;
__END__
=head1 MODE
Check video conferencing usage.
=over 8
=item B<--warning-conferences-active>
Threshold warning.
=item B<--critical-conferences-active>
Threshold critical.
=back
=cut

View File

@ -0,0 +1,49 @@
#
# 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::devices::polycom::groupseries::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}} = (
'hardware' => 'centreon::common::polycom::endpoint::snmp::mode::hardware',
'videoconferencing' => 'centreon::common::polycom::endpoint::snmp::mode::videoconferencing'
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Polycom GroupSeries equipments in SNMP.
=cut