Adding missing __END__ et formatting

This commit is contained in:
BenPls 2019-10-24 11:30:41 +02:00 committed by GitHub
parent 34e718399b
commit afb7410ad8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 307 additions and 305 deletions

View File

@ -1,40 +1,40 @@
# #
# Copyright 2019 Centreon (http://www.centreon.com/) # Copyright 2019 Centreon (http://www.centreon.com/)
# #
# Centreon is a full-fledged industry-strength solution that meets # Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for # the needs in IT infrastructure and application monitoring for
# service performance. # service performance.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
package snmp_standard::mode::udpcon; package snmp_standard::mode::udpcon;
use base qw(centreon::plugins::mode); use base qw(centreon::plugins::mode);
use strict; use strict;
use warnings; use warnings;
my %map_addr_type = ( my %map_addr_type = (
0 => 'unknown', 0 => 'unknown',
1 => 'ipv4', 1 => 'ipv4',
2 => 'ipv6', 2 => 'ipv6',
3 => 'ipv4z', 3 => 'ipv4z',
4 => 'ipv6z', 4 => 'ipv6z',
16 => 'dns', 16 => 'dns',
); );
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);
bless $self, $class; bless $self, $class;
@ -51,9 +51,9 @@
$self->{applications} = {}; $self->{applications} = {};
$self->{states} = { listen => 0 }; $self->{states} = { listen => 0 };
return $self; return $self;
} }
sub get_ipv6 { sub get_ipv6 {
my ($self, %options) = @_; my ($self, %options) = @_;
my $ipv6 = ''; my $ipv6 = '';
@ -68,9 +68,9 @@
} }
return $ipv6; return $ipv6;
} }
sub get_from_rfc4022 { sub get_from_rfc4022 {
my ($self, %options) = @_; my ($self, %options) = @_;
my $oid_udpListenerProcess = '.1.3.6.1.2.1.7.7.1.8'; my $oid_udpListenerProcess = '.1.3.6.1.2.1.7.7.1.8';
@ -98,9 +98,9 @@
} }
return 1; return 1;
} }
sub get_from_rfc1213 { sub get_from_rfc1213 {
my ($self, %options) = @_; my ($self, %options) = @_;
my $oid_udpLocalAddress = '.1.3.6.1.2.1.7.5.1.1'; my $oid_udpLocalAddress = '.1.3.6.1.2.1.7.5.1.1';
@ -112,17 +112,17 @@
$self->{states}->{listen}++; $self->{states}->{listen}++;
push @{$self->{connections}}, "ipv4#$1#$2"; push @{$self->{connections}}, "ipv4#$1#$2";
} }
} }
sub build_connections { sub build_connections {
my ($self, %options) = @_; my ($self, %options) = @_;
if ($self->get_from_rfc4022() == 0) { if ($self->get_from_rfc4022() == 0) {
$self->get_from_rfc1213(); $self->get_from_rfc1213();
} }
} }
sub check_services { sub check_services {
my ($self, %options) = @_; my ($self, %options) = @_;
foreach my $service (@{$self->{option_results}->{service}}) { foreach my $service (@{$self->{option_results}->{service}}) {
@ -139,9 +139,9 @@
$self->{services}->{$tag} = { filter => ((defined($ipv) && $ipv ne '') ? $ipv : '.*?') . '#' . $self->{services}->{$tag} = { filter => ((defined($ipv) && $ipv ne '') ? $ipv : '.*?') . '#' .
((defined($filter_ip) && $filter_ip ne '') ? $filter_ip : '.*?') . '#' . ((defined($filter_ip) && $filter_ip ne '') ? $filter_ip : '.*?') . '#' .
((defined($port) && $port ne '') ? $port : '.*?') ((defined($port) && $port ne '') ? $port : '.*?'),
, builtin => 0,
builtin => 0, number => 0 }; number => 0 };
if (($self->{perfdata}->threshold_validate(label => 'warning-service-' . $tag, value => $warn)) == 0) { if (($self->{perfdata}->threshold_validate(label => 'warning-service-' . $tag, value => $warn)) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $warn . "' for service '$tag'."); $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $warn . "' for service '$tag'.");
$self->{output}->option_exit(); $self->{output}->option_exit();
@ -151,9 +151,9 @@
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
} }
} }
sub check_applications { sub check_applications {
my ($self, %options) = @_; my ($self, %options) = @_;
foreach my $app (@{$self->{option_results}->{application}}) { foreach my $app (@{$self->{option_results}->{application}}) {
@ -188,9 +188,9 @@
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
} }
} }
sub test_services { sub test_services {
my ($self, %options) = @_; my ($self, %options) = @_;
foreach my $tag (keys %{$self->{services}}) { foreach my $tag (keys %{$self->{services}}) {
@ -215,9 +215,9 @@
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-service-' . $tag), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-service-' . $tag),
min => 0); min => 0);
} }
} }
sub test_applications { sub test_applications {
my ($self, %options) = @_; my ($self, %options) = @_;
foreach my $tag (keys %{$self->{applications}}) { foreach my $tag (keys %{$self->{applications}}) {
@ -237,9 +237,9 @@
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-app-' . $tag), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-app-' . $tag),
min => 0); min => 0);
} }
} }
sub check_options { sub check_options {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->SUPER::init(%options); $self->SUPER::init(%options);
@ -253,9 +253,9 @@
} }
$self->check_services(); $self->check_services();
$self->check_applications(); $self->check_applications();
} }
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{snmp} = $options{snmp}; $self->{snmp} = $options{snmp};
@ -271,75 +271,77 @@
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
} }
1; 1;
__END__
=head1 MODE =head1 MODE
Check udp connections. Check udp connections.
=over 8 =over 8
=item B<--warning> =item B<--warning>
Threshold warning for total connections. Threshold warning for total connections.
=item B<--critical> =item B<--critical>
Threshold critical for total connections. Threshold critical for total connections.
=item B<--service> =item B<--service>
Check udp connections following rules: Check udp connections following rules:
tag,[type],[port],[filter-ip],[threshold-warning],[threshold-critical] tag,[type],[port],[filter-ip],[threshold-warning],[threshold-critical]
Example to test NTP connections on the server: --service="ntp,,123,1,2" Example to test NTP connections on the server: --service="ntp,,123,1,2"
=over 16 =over 16
=item <tag> =item <tag>
Name to identify service (must be unique and couldn't be 'total'). Name to identify service (must be unique and couldn't be 'total').
=item <type> =item <type>
regexp - can use 'ipv4', 'ipv6'. Empty means all. regexp - can use 'ipv4', 'ipv6'. Empty means all.
=item <filter-ip> =item <filter-ip>
regexp - can use to exclude or include some IPs. regexp - can use to exclude or include some IPs.
=item <threshold-*> =item <threshold-*>
nagios-perfdata - number of connections. nagios-perfdata - number of connections.
=back =back
=item B<--application> =item B<--application>
Check udp connections of mutiple services: Check udp connections of mutiple services:
tag,[services],[threshold-warning],[threshold-critical] tag,[services],[threshold-warning],[threshold-critical]
Example: Example:
--application="web,http|https,1,2" --application="web,http|https,1,2"
=over 16 =over 16
=item <tag> =item <tag>
Name to identify application (must be unique).
=item <services> Name to identify application (must be unique).
List of services (used the tag name. Separated by '|'). =item <services>
=item <threshold-*> List of services (used the tag name. Separated by '|').
nagios-perfdata - number of connections. =item <threshold-*>
=back nagios-perfdata - number of connections.
=back =back
=cut =back
=cut