From 0677a27ab2d4e2b9ad22bebc2f86cf0917e0a0f6 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Thu, 28 Jan 2021 13:42:57 +0100 Subject: [PATCH] Athonet epc (#2546) --- .../epc/snmp/mode/interfacesdiameter.pm | 224 +++++++++ network/athonet/epc/snmp/mode/interfacesga.pm | 190 ++++++++ .../athonet/epc/snmp/mode/interfacesgtpc.pm | 178 +++++++ .../athonet/epc/snmp/mode/interfaceslte.pm | 455 ++++++++++++++++++ network/athonet/epc/snmp/mode/license.pm | 240 +++++++++ .../epc/snmp/mode/listinterfacesdiameter.pm | 130 +++++ .../athonet/epc/snmp/mode/listinterfacesga.pm | 121 +++++ .../epc/snmp/mode/listinterfacesgtpc.pm | 122 +++++ .../epc/snmp/mode/listinterfaceslte.pm | 117 +++++ network/athonet/epc/snmp/mode/lte.pm | 352 ++++++++++++++ network/athonet/epc/snmp/plugin.pm | 57 +++ 11 files changed, 2186 insertions(+) create mode 100644 network/athonet/epc/snmp/mode/interfacesdiameter.pm create mode 100644 network/athonet/epc/snmp/mode/interfacesga.pm create mode 100644 network/athonet/epc/snmp/mode/interfacesgtpc.pm create mode 100644 network/athonet/epc/snmp/mode/interfaceslte.pm create mode 100644 network/athonet/epc/snmp/mode/license.pm create mode 100644 network/athonet/epc/snmp/mode/listinterfacesdiameter.pm create mode 100644 network/athonet/epc/snmp/mode/listinterfacesga.pm create mode 100644 network/athonet/epc/snmp/mode/listinterfacesgtpc.pm create mode 100644 network/athonet/epc/snmp/mode/listinterfaceslte.pm create mode 100644 network/athonet/epc/snmp/mode/lte.pm create mode 100644 network/athonet/epc/snmp/plugin.pm diff --git a/network/athonet/epc/snmp/mode/interfacesdiameter.pm b/network/athonet/epc/snmp/mode/interfacesdiameter.pm new file mode 100644 index 000000000..aace63062 --- /dev/null +++ b/network/athonet/epc/snmp/mode/interfacesdiameter.pm @@ -0,0 +1,224 @@ +# +# Copyright 2020 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 network::athonet::epc::snmp::mode::interfacesdiameter; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'status: %s', + $self->{result_values}->{status} + ); +} + +sub custom_transport_status_output { + my ($self, %options) = @_; + + return sprintf( + 'transport status: %s [type: %s]', + $self->{result_values}->{transport_status}, + $self->{result_values}->{transport_type} + ); +} + +sub prefix_interface_output { + my ($self, %options) = @_; + + return sprintf( + "Diameter interface '%s' [local: %s] [peer: %s] ", + $options{instance_value}->{name}, + $options{instance_value}->{local_hostname}, + $options{instance_value}->{peer_hostname} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'interfaces', type => 1, cb_prefix_output => 'prefix_interface_output', message_multiple => 'All diameter interfaces are ok' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', nlabel => 'diameter.interfaces.total.count', display_ok => 0, set => { + key_values => [ { name => 'total' } ], + output_template => 'total interfaces: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{interfaces} = [ + { + label => 'status', type => 2, critical_default => '%{status} =~ /down/i', + set => { + key_values => [ { name => 'status' }, { name => 'name' } ], + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + }, + { + label => 'transport-status', type => 2, critical_default => '%{transport_status} =~ /down/i', + set => { + key_values => [ { name => 'transport_status' }, { name => 'transport_type' }, { name => 'name' } ], + closure_custom_output => $self->can('custom_transport_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; +} + +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 => { + 'filter-name:s' => { name => 'filter_name' } + }); + + return $self; +} + +my $map_status = { 0 => 'down', 1 => 'up' }; +my $map_transport_type = { 0 => 'sctp', 1 => 'tcp', 2 => 'udp' }; + +my $mapping = { + peer_hostname => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.4' }, # iDiameterPeerHostName + transport_type => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.8', map => $map_transport_type }, # iDiameterTransportType + transport_status => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.9', map => $map_status }, # iDiameterTransportState + status => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.10', map => $map_status } # iDiameterState +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_local_hostname = '.1.3.6.1.4.1.35805.10.2.12.2.1.2'; # iDiameterLocalHostName + my $snmp_result = $options{snmp}->get_table( + oid => $oid_local_hostname, + nothing_quit => 1 + ); + + $self->{interfaces} = {}; + foreach (keys %$snmp_result) { + /^$oid_local_hostname\.(\d+\.(.*))$/; + my $instance = $1; + my $name = $self->{output}->decode(join('', map(chr($_), split(/\./, $2)))); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); + next; + } + + $self->{interfaces}->{$instance} = { + name => $name, + local_hostname => $snmp_result->{$_} + }; + } + + $self->{global} = { total => scalar(keys %{$self->{interfaces}}) }; + + return if (scalar(keys %{$self->{interfaces}}) <= 0); + + $options{snmp}->load(oids => [ + map($_->{oid}, values(%$mapping)) + ], + instances => [keys %{$self->{interfaces}}], + instance_regexp => '^(.*)$' + ); + $snmp_result = $options{snmp}->get_leef(nothing_quit => 1); + + foreach (keys %{$self->{interfaces}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + + $self->{interfaces}->{$_} = { %{$self->{interfaces}->{$_}}, %$result }; + } +} + +1; + +__END__ + +=head1 MODE + +Check diameter interfaces. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='transport' + +=item B<--filter-name> + +Filter interfaces by name (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{name} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{name} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /down/i'). +Can used special variables like: %{status}, %{name} + +=item B<--unknown-transport-status> + +Set unknown threshold for status. +Can used special variables like: %{transport_status}, %{transport_type}, %{name} + +=item B<--warning-transport-status> + +Set warning threshold for status. +Can used special variables like: %{transport_status}, %{transport_type}, %{name} + +=item B<--critical-transport-status> + +Set critical threshold for status (Default: '%{transport_status} =~ /down/i'). +Can used special variables like: %{transport_status}, %{transport_type}, %{name} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total'. + +=back + +=cut diff --git a/network/athonet/epc/snmp/mode/interfacesga.pm b/network/athonet/epc/snmp/mode/interfacesga.pm new file mode 100644 index 000000000..15ffc3ef4 --- /dev/null +++ b/network/athonet/epc/snmp/mode/interfacesga.pm @@ -0,0 +1,190 @@ +# +# Copyright 2020 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 network::athonet::epc::snmp::mode::interfacesga; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'status: %s', + $self->{result_values}->{status} + ); +} + +sub prefix_interface_output { + my ($self, %options) = @_; + + return sprintf( + "Ga interface '%s' [local: %s] [peer: %s] [type: %s] ", + $options{instance_value}->{name}, + $options{instance_value}->{local_address}, + $options{instance_value}->{peer_address}, + $options{instance_value}->{type} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'interfaces', type => 1, cb_prefix_output => 'prefix_interface_output', message_multiple => 'All ga interfaces are ok' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', nlabel => 'diameter.interfaces.total.count', display_ok => 0, set => { + key_values => [ { name => 'total' } ], + output_template => 'total interfaces: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{interfaces} = [ + { + label => 'status', type => 2, critical_default => '%{status} =~ /down/i', + set => { + key_values => [ + { name => 'status' }, { name => 'peer_address' }, + { name => 'local_address' }, { name => 'name' } ], + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; +} + +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 => { + 'filter-name:s' => { name => 'filter_name' }, + 'filter-local-address:s' => { name => 'filter_local_address' }, + 'filter-peer-address:s' => { name => 'filter_peer_address' } + }); + + return $self; +} + +my $map_status = { 0 => 'down', 1 => 'up' }; +my $map_transport_type = { 0 => 'sctp', 1 => 'tcp', 2 => 'udp' }; + +my $mapping = { + local_address => { oid => '.1.3.6.1.4.1.35805.10.2.12.10.1.2' }, # iGaLinkLocalAddress + peer_address => { oid => '.1.3.6.1.4.1.35805.10.2.12.10.1.3' }, # iGaLinkPeerAddress + type => { oid => '.1.3.6.1.4.1.35805.10.2.12.10.1.4', map => $map_transport_type }, # iGaLinkTransportType + status => { oid => '.1.3.6.1.4.1.35805.10.2.12.10.1.5', map => $map_status }, # iGaLinkState + name => { oid => '.1.3.6.1.4.1.35805.10.2.12.10.1.7' }, # iGaLinkName +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_gaLinksEntry = '.1.3.6.1.4.1.35805.10.2.12.10.1'; + my $snmp_result = $options{snmp}->get_table( + oid => $oid_gaLinksEntry, + nothing_quit => 1 + ); + + $self->{interfaces} = {}; + foreach (keys %$snmp_result) { + next if (! /^$mapping->{local_address}->{oid}\.(.*)$/); + my $instance = $1; + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{name} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{name} . "': no matching filter.", debug => 1); + next; + } + if (defined($self->{option_results}->{filter_local_address}) && $self->{option_results}->{filter_local_address} ne '' && + $result->{local_address} !~ /$self->{option_results}->{filter_local_address}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{local_address} . "': no matching filter.", debug => 1); + next; + } + if (defined($self->{option_results}->{filter_peer_address}) && $self->{option_results}->{filter_peer_address} ne '' && + $result->{peer_address} !~ /$self->{option_results}->{filter_peer_address}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{peer_address} . "': no matching filter.", debug => 1); + next; + } + + $self->{interfaces}->{$instance} = $result; + } + + $self->{global} = { total => scalar(keys %{$self->{interfaces}}) }; +} + +1; + +__END__ + +=head1 MODE + +Check GA interfaces. + +=over 8 + +=item B<--filter-name> + +Filter interfaces by name (can be a regexp). + +=item B<--filter-local-address> + +Filter interfaces by local address (can be a regexp). + +=item B<--filter-peer-address> + +Filter interfaces by peer address (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{local_address}, %{peer_address}, %{name} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{local_address}, %{peer_address}, %{name} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /down/i'). +Can used special variables like: %{status}, %{local_address}, %{peer_address}, %{name} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total'. + +=back + +=cut diff --git a/network/athonet/epc/snmp/mode/interfacesgtpc.pm b/network/athonet/epc/snmp/mode/interfacesgtpc.pm new file mode 100644 index 000000000..d0f3f3a37 --- /dev/null +++ b/network/athonet/epc/snmp/mode/interfacesgtpc.pm @@ -0,0 +1,178 @@ +# +# Copyright 2020 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 network::athonet::epc::snmp::mode::interfacesgtpc; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'status: %s', + $self->{result_values}->{status} + ); +} + +sub prefix_interface_output { + my ($self, %options) = @_; + + return sprintf( + "Gtp control interface source '%s' destination '%s' [type: %s] ", + $options{instance_value}->{source_address}, + $options{instance_value}->{destination_address}, + $options{instance_value}->{type} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'interfaces', type => 1, cb_prefix_output => 'prefix_interface_output', message_multiple => 'All Gtp control interfaces are ok' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', nlabel => 'gtpc.interfaces.total.count', display_ok => 0, set => { + key_values => [ { name => 'total' } ], + output_template => 'total interfaces: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{interfaces} = [ + { + label => 'status', type => 2, critical_default => '%{status} =~ /down/i', + set => { + key_values => [ { name => 'status' }, { name => 'source_address' }, { name => 'destination_address' } ], + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; +} + +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 => { + 'filter-source-address:s' => { name => 'filter_source_address' }, + 'filter-destination-address:s' => { name => 'filter_destination_address' } + }); + + return $self; +} + +my $map_status = { 0 => 'down', 1 => 'up' }; +my $map_type = { 1 => 'gTPv1', 2 => 'gTPv2', 11 => 'gTPPrime' }; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_status = '.1.3.6.1.4.1.35805.10.2.12.9.1.6'; # gTPcState + my $snmp_result = $options{snmp}->get_table( + oid => $oid_status, + nothing_quit => 1 + ); + + $self->{interfaces} = {}; + foreach (keys %$snmp_result) { + /^$oid_status\.(.*)$/; + my $instance = $1; + my @indexes = split(/\./, $instance); + + my $source_address = $self->{output}->decode(join('', map(chr($_), splice(@indexes, 0, shift(@indexes)) ))); + my $destination_address = $self->{output}->decode(join('', map(chr($_), splice(@indexes, 0, shift(@indexes)) ))); + my $type = $map_type->{ $indexes[0] }; + + if (defined($self->{option_results}->{filter_source_address}) && $self->{option_results}->{filter_source_address} ne '' && + $source_address !~ /$self->{option_results}->{filter_source_address}/) { + $self->{output}->output_add(long_msg => "skipping '" . $source_address . "': no matching filter.", debug => 1); + next; + } + if (defined($self->{option_results}->{filter_destination_address}) && $self->{option_results}->{filter_destination_address} ne '' && + $destination_address !~ /$self->{option_results}->{filter_destination_address}/) { + $self->{output}->output_add(long_msg => "skipping '" . $destination_address . "': no matching filter.", debug => 1); + next; + } + + $self->{interfaces}->{$instance} = { + source_address => $source_address, + destination_address => $destination_address, + type => $type, + status => $map_status->{ $snmp_result->{$_} } + }; + } + + $self->{global} = { total => scalar(keys %{$self->{interfaces}}) }; +} + +1; + +__END__ + +=head1 MODE + +Check GTP control interfaces. + +=over 8 + +=item B<--filter-source-address> + +Filter interfaces by source address (can be a regexp). + +=item B<--filter-destination-address> + +Filter interfaces by destination address (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{source_address}, %{destination_address} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{source_address}, %{destination_address} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /down/i'). +Can used special variables like: %{status}, %{source_address}, %{destination_address} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total'. + +=back + +=cut diff --git a/network/athonet/epc/snmp/mode/interfaceslte.pm b/network/athonet/epc/snmp/mode/interfaceslte.pm new file mode 100644 index 000000000..1ca039356 --- /dev/null +++ b/network/athonet/epc/snmp/mode/interfaceslte.pm @@ -0,0 +1,455 @@ +# +# Copyright 2020 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 network::athonet::epc::snmp::mode::interfaceslte; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); +use Digest::MD5 qw(md5_hex); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'sctp status: %s [s1ap status: %s]', + $self->{result_values}->{sctp_status}, + $self->{result_values}->{s1ap_status} + ); +} + +sub custom_attach_req_output { + my ($self, %options) = @_; + + return sprintf( + 'attach requests total: %s success: %s (%.2f%%)', + $self->{result_values}->{attach_req_total}, + $self->{result_values}->{attach_req_success}, + $self->{result_values}->{prct_success} + ); +} + +sub custom_attach_req_calc { + my ($self, %options) = @_; + + $self->{result_values}->{attach_req_total} = $options{new_datas}->{$self->{instance} . '_attach_req_total'} - $options{old_datas}->{$self->{instance} . '_attach_req_total'}; + $self->{result_values}->{attach_req_success} = $options{new_datas}->{$self->{instance} . '_attach_req_success'} - $options{old_datas}->{$self->{instance} . '_attach_req_success'}; + $self->{result_values}->{prct_success} = 100; + if ($self->{result_values}->{attach_req_total} > 0) { + $self->{result_values}->{prct_success} = $self->{result_values}->{attach_req_success} * 100 / $self->{result_values}->{attach_req_total}; + } + return 0; +} + +sub custom_pdn_req_output { + my ($self, %options) = @_; + + return sprintf( + 'pdn context activation requests total: %s success: %s (%.2f%%)', + $self->{result_values}->{pdn_context_total}, + $self->{result_values}->{pdn_context_success}, + $self->{result_values}->{prct_success} + ); +} + +sub custom_pdn_req_calc { + my ($self, %options) = @_; + + $self->{result_values}->{pdn_context_total} = $options{new_datas}->{$self->{instance} . '_pdn_context_total'} - $options{old_datas}->{$self->{instance} . '_pdn_context_total'}; + $self->{result_values}->{pdn_context_success} = $options{new_datas}->{$self->{instance} . '_pdn_context_success'} - $options{old_datas}->{$self->{instance} . '_pdn_context_success'}; + $self->{result_values}->{prct_success} = 100; + if ($self->{result_values}->{pdn_context_total} > 0) { + $self->{result_values}->{prct_success} = $self->{result_values}->{pdn_context_success} * 100 / $self->{result_values}->{pdn_context_total}; + } + return 0; +} + +sub prefix_interface_output { + my ($self, %options) = @_; + + return sprintf( + "Lte interface '%s' [eNodeB ID: %s] ", + $options{instance_value}->{name}, + $options{instance_value}->{enbid} + ); +} + +sub interface_long_output { + my ($self, %options) = @_; + + return sprintf("checking lte interface '%s' [eNodeB ID: %s]", + $options{instance_value}->{name}, + $options{instance_value}->{enbid} + ); +} + +sub prefix_pdn_rej_output { + my ($self, %options) = @_; + + return 'pdn context requests reject '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'interfaces', type => 3, cb_prefix_output => 'prefix_interface_output', cb_long_output => 'interface_long_output', indent_long_output => ' ', message_multiple => 'All lte interfaces are ok', + group => [ + { name => 'global_status', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_traffic', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_users', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_attach_req', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_pdn_req', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_ue', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_pdn_rej', type => 0, cb_prefix_output => 'prefix_pdn_rej_output', skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', nlabel => 'lte.interfaces.total.count', display_ok => 0, set => { + key_values => [ { name => 'total' } ], + output_template => 'total interfaces: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{global_status} = [ + { + label => 'status', type => 2, critical_default => '%{sctp_status} =~ /down/i || %{s1ap_status} =~ /down/i', + set => { + key_values => [ { name => 'sctp_status' }, { name => 's1ap_status' }, { name => 'name' } ], + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; + + $self->{maps_counters}->{global_traffic} = [ + { label => 'packets-in', nlabel => 'lte.interface.packets.in.count', set => { + key_values => [ { name => 'packets_in', diff => 1 } ], + output_template => 'packets in: %s', + perfdatas => [ + { template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'packets-out', nlabel => 'lte.interface.packets.out.count', set => { + key_values => [ { name => 'packets_out', diff => 1 } ], + output_template => 'packets out: %s', + perfdatas => [ + { template => '%s', min => 0, label_extra_instance => 1 } + ] + } + } + ]; + + $self->{maps_counters}->{global_users} = [ + { label => 'users-connected', nlabel => 'lte.interface.users.connected.count', set => { + key_values => [ { name => 'users_connected' } ], + output_template => 'connected users: %s', + perfdatas => [ + { template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'users-idle', nlabel => 'lte.interface.users.idle.count', set => { + key_values => [ { name => 'users_idle' } ], + output_template => 'idle users: %s', + perfdatas => [ + { template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'sessions-active', nlabel => 'lte.interface.sessions.active.count', set => { + key_values => [ { name => 'sessions_active' } ], + output_template => 'active sessions: %s', + perfdatas => [ + { template => '%s', min => 0, label_extra_instance => 1 } + ] + } + } + ]; + + $self->{maps_counters}->{global_attach_req} = [ + { label => 'requests-attach-success', nlabel => 'lte.interface.requests.attach.success.count', set => { + key_values => [ { name => 'attach_req_success', diff => 1 }, { name => 'attach_req_total', diff => 1 } ], + closure_custom_calc => $self->can('custom_attach_req_calc'), + closure_custom_output => $self->can('custom_attach_req_output'), + perfdatas => [ + { template => '%s', min => 0, max => 'attach_req_total', label_extra_instance => 1 } + ] + } + }, + { label => 'requests-attach-success-prct', nlabel => 'lte.interface.requests.attach.success.percentage', display_ok => 0, set => { + key_values => [ { name => 'attach_req_success', diff => 1 }, { name => 'attach_req_total', diff => 1 } ], + closure_custom_calc => $self->can('custom_attach_req_calc'), + closure_custom_output => $self->can('custom_attach_req_output'), + threshold_use => 'prct_success', + perfdatas => [ + { value => 'prct_success', template => '%s', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] + } + } + ]; + + $self->{maps_counters}->{global_pdn_req} = [ + { label => 'requests-pdn-context-activation', nlabel => 'lte.interface.requests.pdn_context.activations.success.count', set => { + key_values => [ { name => 'pdn_context_success', diff => 1 }, { name => 'pdn_context_total', diff => 1 } ], + closure_custom_calc => $self->can('custom_pdn_req_calc'), + closure_custom_output => $self->can('custom_pdn_req_output'), + perfdatas => [ + { template => '%s', min => 0, max => 'pdn_context_total', label_extra_instance => 1 } + ] + } + }, + { label => 'requests-pdn-context-activation-prct', nlabel => 'lte.interface.requests.pdn_context.activations.success.percentage', display_ok => 0, set => { + key_values => [ { name => 'pdn_context_success', diff => 1 }, { name => 'pdn_context_total', diff => 1 } ], + closure_custom_calc => $self->can('custom_pdn_req_calc'), + closure_custom_output => $self->can('custom_pdn_req_output'), + threshold_use => 'prct_success', + perfdatas => [ + { value => 'prct_success', template => '%s', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] + } + } + ]; + + $self->{maps_counters}->{global_ue} = [ + { label => 'requests-ue-context-release-total', nlabel => 'lte.interface.requests.ue_context_release.total.count', set => { + key_values => [ { name => 'ue_release_req', diff => 1 } ], + output_template => 'ue context release requests: %s', + perfdatas => [ + { template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'requests-ue-context-release-radio-lost', nlabel => 'lte.interface.requests.ue_context_release.radio_lost.count', set => { + key_values => [ { name => 'ue_release_req_radio_lost', diff => 1 } ], + output_template => 'ue context release with radio lost requests: %s', + perfdatas => [ + { template => '%s', min => 0, label_extra_instance => 1 } + ] + } + } + ]; + + $self->{maps_counters}->{global_pdn_rej} = [ + { label => 'requests-pdn-context-rej-insufres', nlabel => 'lte.interface.requests.pdn_context.reject.insufficent_resources.count', set => { + key_values => [ { name => 'pdn_rej_insuf_res', diff => 1 } ], + output_template => 'insufficent resources: %s', + perfdatas => [ + { template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'requests-pdn-context-rej-noapn', nlabel => 'lte.interface.requests.pdn_context.reject.no_apn.count', set => { + key_values => [ { name => 'pdn_rej_no_apn', diff => 1 } ], + output_template => 'missing or unknown apn: %s', + perfdatas => [ + { template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'requests-pdn-context-rej-nosub', nlabel => 'lte.interface.requests.pdn_context.reject.not_subscribed.count', set => { + key_values => [ { name => 'pdn_rej_no_sub', diff => 1 } ], + output_template => 'not subscribed: %s', + perfdatas => [ + { template => '%s', min => 0, label_extra_instance => 1 } + ] + } + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + + return $self; +} + +my $map_status = { 0 => 'down', 1 => 'up' }; + +my $mapping = { + sctp_status => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.3', map => $map_status }, # iLteSCTPState + s1ap_status => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.4', map => $map_status }, # iLteS1APState + packets_in => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.5' }, # iLteLoadPktIn + packets_out => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.6' }, # iLteLoadPktOut + users_connected => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.7' }, # iLteConnectedUsers + users_idle => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.8' }, # iLteIdleUsers + sessions_active => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.9' }, # iLteActiveSessions + attach_req_total => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.11' }, # iLteTotalAttachReq + attach_req_success => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.12' }, # iLteSuccesfullAttach + pdn_context_total => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.14' }, # iLteTotalPDNActReq + pdn_context_success => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.15' }, # iLteActivatedPDNContext + ue_release_req => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.23' }, # iLteUERelReq + ue_release_req_radio_lost => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.24' }, # iLteUERelReqRadioLost + pdn_rej_insuf_res => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.25' }, # iLtePDNRejInsufRes + pdn_rej_no_apn => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.26' }, # iLtePDNRejNoApn + pdn_rej_no_sub => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.27' } # iLtePDNRejNoSubscribed +}; +my $mapping_name = { + name => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.28' }, # iLteHumanName + enbid => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.29' } # iLteENBId +}; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = 'athonet_epc_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); + + my $oid_lteInterfacesEntry = '.1.3.6.1.4.1.35805.10.2.2.99.1'; + my $snmp_result = $options{snmp}->get_table( + oid => $oid_lteInterfacesEntry, + start => $mapping_name->{name}->{oid}, + end => $mapping_name->{enbid}->{oid}, + nothing_quit => 1 + ); + + $self->{interfaces} = {}; + foreach (keys %$snmp_result) { + next if (! /^$mapping_name->{name}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping_name, results => $snmp_result, instance => $instance); + + next if (defined($self->{interfaces}->{ $result->{name} })); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{name} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{name} . "': no matching filter.", debug => 1); + next; + } + + $self->{interfaces}->{ $result->{name} } = { + %$result, + instance => $instance + }; + } + + $self->{global} = { total => scalar(keys %{$self->{interfaces}}) }; + + return if (scalar(keys %{$self->{interfaces}}) <= 0); + + $options{snmp}->load(oids => [ + map($_->{oid}, values(%$mapping)) + ], + instances => [map($_->{instance}, values(%{$self->{interfaces}}))], + instance_regexp => '^(.*)$' + ); + $snmp_result = $options{snmp}->get_leef(nothing_quit => 1); + + foreach (keys %{$self->{interfaces}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $self->{interfaces}->{$_}->{instance}); + + $self->{interfaces}->{$_}->{global_status} = { + name => $self->{interfaces}->{$_}->{name}, + sctp_status => $result->{sctp_status}, + s1ap_status => $result->{s1ap_status} + }; + $self->{interfaces}->{$_}->{global_traffic} = { + packets_in => $result->{packets_in}, + packets_out => $result->{packets_out} + }; + $self->{interfaces}->{$_}->{global_users} = { + users_connected => $result->{users_connected}, + users_idle => $result->{users_idle}, + sessions_active => $result->{sessions_active} + }; + $self->{interfaces}->{$_}->{global_attach_req} = { + attach_req_total => $result->{attach_req_total}, + attach_req_success => $result->{attach_req_success} + }; + $self->{interfaces}->{$_}->{global_pdn_req} = { + pdn_context_total => $result->{pdn_context_total}, + pdn_context_success => $result->{pdn_context_success} + }; + $self->{interfaces}->{$_}->{global_ue} = { + ue_release_req => $result->{ue_release_req}, + ue_release_req_radio_lost => $result->{ue_release_req_radio_lost} + }; + $self->{interfaces}->{$_}->{global_pdn_rej} = { + pdn_rej_insuf_res => $result->{pdn_rej_insuf_res}, + pdn_rej_no_apn => $result->{pdn_rej_no_apn}, + pdn_rej_no_sub => $result->{pdn_rej_no_sub} + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check lte interfaces. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='users' + +=item B<--filter-name> + +Filter interfaces by name (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{sctp_status}, %{s1ap_status}, %{name} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{sctp_status}, %{s1ap_status}, %{name} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{sctp_status} =~ /down/i || %{s1ap_status} =~ /down/i'). +Can used special variables like: %{sctp_status}, %{s1ap_status}, %{name} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total', 'users-connected', 'users-idle', 'sessions-active', +'packets-in', 'packets-out', +'requests-ue-context-release-total', 'requests-ue-context-release-radio-lost', +'requests-attach-success', 'requests-attach-success-prct', +'requests-pdn-context-activation', 'requests-pdn-context-activation-prct', +'requests-pdn-context-rej-insufres', 'requests-pdn-context-rej-noapn', 'requests-pdn-context-rej-nosub'. + +=back + +=cut diff --git a/network/athonet/epc/snmp/mode/license.pm b/network/athonet/epc/snmp/mode/license.pm new file mode 100644 index 000000000..3df4faa27 --- /dev/null +++ b/network/athonet/epc/snmp/mode/license.pm @@ -0,0 +1,240 @@ +# +# Copyright 2020 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 network::athonet::epc::snmp::mode::license; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; +use DateTime; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf('status is %s', $self->{result_values}->{status}); +} + +sub custom_license_users_output { + my ($self, %options) = @_; + + return sprintf( + 'active users total: %s used: %s (%.2f%%) free: %s (%.2f%%)', + $self->{result_values}->{users_total}, + $self->{result_values}->{users_used}, + $self->{result_values}->{users_prct_used}, + $self->{result_values}->{users_free}, + $self->{result_values}->{users_prct_free} + ); +} + +sub custom_license_sessions_output { + my ($self, %options) = @_; + + return sprintf( + 'active sessions total: %s used: %s (%.2f%%) free: %s (%.2f%%)', + $self->{result_values}->{sessions_total}, + $self->{result_values}->{sessions_used}, + $self->{result_values}->{sessions_prct_used}, + $self->{result_values}->{sessions_free}, + $self->{result_values}->{sessions_prct_free} + ); +} + +sub prefix_global_output { + my ($self, %options) = @_; + + return 'License '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' } + ]; + + $self->{maps_counters}->{global} = [ + { + label => 'status', + type => 2, + critical_default => '%{status} =~ /expired|invalid/i', + set => { + key_values => [ { name => 'status' } ], + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + }, + { label => 'expires-seconds', nlabel => 'license.expires.seconds', set => { + key_values => [ { name => 'expires_seconds' }, { name => 'expires_human' } ], + output_template => 'expires in %s', + output_use => 'expires_human', + perfdatas => [ + { template => '%d', min => 0, unit => 's' } + ] + } + }, + { label => 'license-users-usage', nlabel => 'license.users.active.usage.count', set => { + key_values => [ { name => 'users_used' }, { name => 'users_free' }, { name => 'users_prct_used' }, { name => 'users_prct_free' }, { name => 'users_total' } ], + closure_custom_output => $self->can('custom_license_users_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'users_total' } + ] + } + }, + { label => 'license-users-free', display_ok => 0, nlabel => 'license.users.active.free.count', set => { + key_values => [ { name => 'users_free' }, { name => 'users_used' }, { name => 'users_prct_used' }, { name => 'users_prct_free' }, { name => 'users_total' } ], + closure_custom_output => $self->can('custom_license_users_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'users_total' } + ] + } + }, + { label => 'license-users-usage-prct', display_ok => 0, nlabel => 'license.users.active.usage.percentage', set => { + key_values => [ { name => 'users_prct_used' }, { name => 'users_free' }, { name => 'users_used' }, { name => 'users_prct_free' }, { name => 'users_total' } ], + closure_custom_output => $self->can('custom_license_users_output'), + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'license-sessions-usage', nlabel => 'license.sessions.active.usage.count', set => { + key_values => [ { name => 'sessions_used' }, { name => 'sessions_free' }, { name => 'sessions_prct_used' }, { name => 'sessions_prct_free' }, { name => 'sessions_total' } ], + closure_custom_output => $self->can('custom_license_sessions_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'sessions_total' } + ] + } + }, + { label => 'license-sessions-free', display_ok => 0, nlabel => 'license.sessions.active.free.count', set => { + key_values => [ { name => 'sessions_free' }, { name => 'sessions_used' }, { name => 'sessions_prct_used' }, { name => 'sessions_prct_free' }, { name => 'sessions_total' } ], + closure_custom_output => $self->can('custom_license_sessions_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'sessions_total' } + ] + } + }, + { label => 'license-sessions-usage-prct', display_ok => 0, nlabel => 'license.sessions.active.usage.percentage', set => { + key_values => [ { name => 'sessions_prct_used' }, { name => 'sessions_used' }, { name => 'sessions_free' }, { name => 'sessions_prct_free' }, { name => 'sessions_total' } ], + closure_custom_output => $self->can('custom_license_sessions_output'), + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + ]; +} + +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; +} + +my $map_status = { 0 => 'ok', 1 => 'expired', 2 => 'invalid' }; + +my $mapping = { + users_connected => { oid => '.1.3.6.1.4.1.35805.10.2.99.1' }, # usersConnected + active_connections => { oid => '.1.3.6.1.4.1.35805.10.2.99.4' }, # activeConnections + max_active_users => { oid => '.1.3.6.1.4.1.35805.10.4.1' }, # maxActiveUsers + max_active_sessions => { oid => '.1.3.6.1.4.1.35805.10.4.2' }, # maxActiveSessions + expire_time => { oid => '.1.3.6.1.4.1.35805.10.4.4' }, # licenseExpireTime + status => { oid => '.1.3.6.1.4.1.35805.10.4.5', map => $map_status } # licenseStatus +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%$mapping)) ], + nothing_quit => 1 + ); + $self->{global} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0); + + #2035-3-30,7:43:58.0,+0:0 + if ($self->{global}->{expire_time} =~ /^\s*(\d+)-(\d+)-(\d+),(\d+):(\d+):(\d+)\.(\d+),(.*)/) { + my $dt = DateTime->new( + year => $1, + month => $2, + day => $3, + hour => $4, + minute => $5, + second => $6, + time_zone => $7 + ); + $self->{global}->{expires_seconds} = $dt->epoch() - time(); + $self->{global}->{expires_human} = centreon::plugins::misc::change_seconds(value => $self->{global}->{expires_seconds}); + } + + $self->{global}->{users_used} = $self->{global}->{users_connected}; + $self->{global}->{users_total} = $self->{global}->{max_active_users}; + $self->{global}->{users_free} = $self->{global}->{users_total} - $self->{global}->{users_used}; + $self->{global}->{users_prct_used} = $self->{global}->{users_used} * 100 / $self->{global}->{users_total}; + $self->{global}->{users_prct_free} = 100 - $self->{global}->{users_prct_used}; + + $self->{global}->{sessions_used} = $self->{global}->{active_connections}; + $self->{global}->{sessions_total} = $self->{global}->{max_active_sessions}; + $self->{global}->{sessions_free} = $self->{global}->{sessions_total} - $self->{global}->{sessions_used}; + $self->{global}->{sessions_prct_used} = $self->{global}->{sessions_used} * 100 / $self->{global}->{sessions_total}; + $self->{global}->{sessions_prct_free} = 100 - $self->{global}->{sessions_prct_used}; +} + +1; + +__END__ + +=head1 MODE + +Check license. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='users' + +=item B<--warning-status> + +Set warning threshold for status. +Can use special variables like: %{status} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /expired|invalid/i'). +Can use special variables like: %{status} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'expires-seconds', 'license-users-usage', 'license-users-free', 'license-users-usage-prct', +'license-sessions-usage', 'license-sessions-free', 'license-sessions-usage-prct'. + +=back + +=cut diff --git a/network/athonet/epc/snmp/mode/listinterfacesdiameter.pm b/network/athonet/epc/snmp/mode/listinterfacesdiameter.pm new file mode 100644 index 000000000..530a79e15 --- /dev/null +++ b/network/athonet/epc/snmp/mode/listinterfacesdiameter.pm @@ -0,0 +1,130 @@ +# +# Copyright 2020 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 network::athonet::epc::snmp::mode::listinterfacesdiameter; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my $map_status = { 0 => 'down', 1 => 'up' }; +my $map_transport_type = { 0 => 'sctp', 1 => 'tcp', 2 => 'udp' }; + +my $mapping = { + local_hostname => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.2' }, # iDiameterLocalHostName + local_realmname => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.3' }, # iDiameterLocalRealmName + peer_hostname => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.4' }, # iDiameterPeerHostName + peer_realmname => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.5' }, # iDiameterPeerRealmName + local_address => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.6' }, # iDiameterLocalAddress + peer_address => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.7' }, # iDiameterPeerAddress + transport_type => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.8', map => $map_transport_type }, # iDiameterTransportType + transport_status => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.9', map => $map_status }, # iDiameterTransportState + status => { oid => '.1.3.6.1.4.1.35805.10.2.12.2.1.10', map => $map_status } # iDiameterState +}; +my $oid_diameterInterfacesEntry = '.1.3.6.1.4.1.35805.10.2.12.2.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table( + oid => $oid_diameterInterfacesEntry, + start => $mapping->{local_hostname}->{oid}, + end => $mapping->{status}->{oid}, + nothing_quit => 1 + ); + + my $results = {}; + foreach (keys %$snmp_result) { + next if (! /^$mapping->{local_hostname}->{oid}\.(\d+\.(.*))$/); + my $instance = $1; + my $name = $self->{output}->decode(join('', map(chr($_), split(/\./, $2)))); + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + $results->{$name} = $result; + } + + return $results; +} + +sub run { + my ($self, %options) = @_; + + my $results = $self->manage_selection(snmp => $options{snmp}); + foreach my $name (sort keys %$results) { + $self->{output}->output_add(long_msg => + '[name = ' . $name . ']' . join('', map("[$_ = " . $results->{$name}->{$_} . ']', keys(%$mapping))) + ); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List diameter interfaces:' + ); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => ['name', keys %$mapping]); +} + +sub disco_show { + my ($self, %options) = @_; + + my $results = $self->manage_selection(snmp => $options{snmp}); + foreach (sort keys %$results) { + $self->{output}->add_disco_entry( + name => $_, + %{$results->{$_}} + ); + } +} + +1; + +__END__ + +=head1 MODE + +List diameter interfaces. + +=over 8 + +=back + +=cut diff --git a/network/athonet/epc/snmp/mode/listinterfacesga.pm b/network/athonet/epc/snmp/mode/listinterfacesga.pm new file mode 100644 index 000000000..4d16ba3e3 --- /dev/null +++ b/network/athonet/epc/snmp/mode/listinterfacesga.pm @@ -0,0 +1,121 @@ +# +# Copyright 2020 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 network::athonet::epc::snmp::mode::listinterfacesga; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my $map_status = { 0 => 'down', 1 => 'up' }; +my $map_transport_type = { 0 => 'sctp', 1 => 'tcp', 2 => 'udp' }; + +my $mapping = { + local_address => { oid => '.1.3.6.1.4.1.35805.10.2.12.10.1.2' }, # iGaLinkLocalAddress + peer_address => { oid => '.1.3.6.1.4.1.35805.10.2.12.10.1.3' }, # iGaLinkPeerAddress + type => { oid => '.1.3.6.1.4.1.35805.10.2.12.10.1.4', map => $map_transport_type }, # iGaLinkTransportType + status => { oid => '.1.3.6.1.4.1.35805.10.2.12.10.1.5', map => $map_status }, # iGaLinkState + name => { oid => '.1.3.6.1.4.1.35805.10.2.12.10.1.7' }, # iGaLinkName +}; +my $oid_gaLinksEntry = '.1.3.6.1.4.1.35805.10.2.12.10.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table( + oid => $oid_gaLinksEntry, + nothing_quit => 1 + ); + + my $results = {}; + foreach (keys %$snmp_result) { + next if (! /^$mapping->{local_address}->{oid}\.(.*)$/); + my $instance = $1; + + $results->{$instance} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + } + + return $results; +} + +sub run { + my ($self, %options) = @_; + + my $results = $self->manage_selection(snmp => $options{snmp}); + foreach my $name (sort keys %$results) { + $self->{output}->output_add(long_msg => + join('', map("[$_ = " . $results->{$name}->{$_} . ']', keys(%$mapping))) + ); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List ga interfaces:' + ); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => [keys %$mapping]); +} + +sub disco_show { + my ($self, %options) = @_; + + my $results = $self->manage_selection(snmp => $options{snmp}); + foreach (sort keys %$results) { + $self->{output}->add_disco_entry( + %{$results->{$_}} + ); + } +} + +1; + +__END__ + +=head1 MODE + +List GA interfaces. + +=over 8 + +=back + +=cut diff --git a/network/athonet/epc/snmp/mode/listinterfacesgtpc.pm b/network/athonet/epc/snmp/mode/listinterfacesgtpc.pm new file mode 100644 index 000000000..750e6f651 --- /dev/null +++ b/network/athonet/epc/snmp/mode/listinterfacesgtpc.pm @@ -0,0 +1,122 @@ +# +# Copyright 2020 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 network::athonet::epc::snmp::mode::listinterfacesgtpc; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my $map_status = { 0 => 'down', 1 => 'up' }; +my $map_type = { 1 => 'gTPv1', 2 => 'gTPv2', 11 => 'gTPPrime' }; + +my $mapping = { + source_address => { oid => '.1.3.6.1.4.1.35805.10.2.12.9.1.1' }, # gTPcAddressSource + destination_address => { oid => '.1.3.6.1.4.1.35805.10.2.12.9.1.3' }, # gTPcAddressDestination + type => { oid => '.1.3.6.1.4.1.35805.10.2.12.9.1.5', map => $map_type }, # gTPcGTPType + status => { oid => '.1.3.6.1.4.1.35805.10.2.12.9.1.6', map => $map_status } # gTPcState +}; +my $oid_gtpcInterfacesEntry = '.1.3.6.1.4.1.35805.10.2.12.9.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table( + oid => $oid_gtpcInterfacesEntry, + end => $mapping->{status}->{oid}, + nothing_quit => 1 + ); + + my $results = {}; + foreach (keys %$snmp_result) { + next if (! /^$mapping->{source_address}->{oid}\.(.*)$/); + my $instance = $1; + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + $results->{$instance} = $result; + } + + return $results; +} + +sub run { + my ($self, %options) = @_; + + my $results = $self->manage_selection(snmp => $options{snmp}); + foreach my $name (sort keys %$results) { + $self->{output}->output_add(long_msg => + join('', map("[$_ = " . $results->{$name}->{$_} . ']', keys(%$mapping))) + ); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List gtp control interfaces:' + ); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => [keys %$mapping]); +} + +sub disco_show { + my ($self, %options) = @_; + + my $results = $self->manage_selection(snmp => $options{snmp}); + foreach (sort keys %$results) { + $self->{output}->add_disco_entry( + %{$results->{$_}} + ); + } +} + +1; + +__END__ + +=head1 MODE + +List GTP control interfaces. + +=over 8 + +=back + +=cut diff --git a/network/athonet/epc/snmp/mode/listinterfaceslte.pm b/network/athonet/epc/snmp/mode/listinterfaceslte.pm new file mode 100644 index 000000000..ebfe7e6de --- /dev/null +++ b/network/athonet/epc/snmp/mode/listinterfaceslte.pm @@ -0,0 +1,117 @@ +# +# Copyright 2020 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 network::athonet::epc::snmp::mode::listinterfaceslte; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my $mapping = { + name => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.28' }, # iLteHumanName + enbid => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.29' } # iLteENBId +}; +my $oid_lteInterfacesEntry = '.1.3.6.1.4.1.35805.10.2.2.99.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table( + oid => $oid_lteInterfacesEntry, + start => $mapping->{name}->{oid}, + end => $mapping->{enbid}->{oid}, + nothing_quit => 1 + ); + + my $results = {}; + foreach (keys %$snmp_result) { + next if (! /^$mapping->{name}->{oid}\.(.*)$/); + my $instance = $1; + + $results->{$instance} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + } + + return $results; +} + +sub run { + my ($self, %options) = @_; + + my $results = $self->manage_selection(snmp => $options{snmp}); + foreach my $name (sort keys %$results) { + $self->{output}->output_add(long_msg => + join('', map("[$_ = " . $results->{$name}->{$_} . ']', keys(%$mapping))) + ); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List lte interfaces:' + ); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => [keys %$mapping]); +} + +sub disco_show { + my ($self, %options) = @_; + + my $results = $self->manage_selection(snmp => $options{snmp}); + foreach (sort keys %$results) { + $self->{output}->add_disco_entry( + %{$results->{$_}} + ); + } +} + +1; + +__END__ + +=head1 MODE + +List LTE interfaces. + +=over 8 + +=back + +=cut diff --git a/network/athonet/epc/snmp/mode/lte.pm b/network/athonet/epc/snmp/mode/lte.pm new file mode 100644 index 000000000..b40a3d593 --- /dev/null +++ b/network/athonet/epc/snmp/mode/lte.pm @@ -0,0 +1,352 @@ +# +# Copyright 2020 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 network::athonet::epc::snmp::mode::lte; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); +use Digest::MD5 qw(md5_hex); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'sctp status: %s [s1ap status: %s]', + $self->{result_values}->{sctp_status}, + $self->{result_values}->{s1ap_status} + ); +} + +sub custom_attach_req_output { + my ($self, %options) = @_; + + return sprintf( + 'attach requests total: %s success: %s (%.2f%%)', + $self->{result_values}->{attach_req_total}, + $self->{result_values}->{attach_req_success}, + $self->{result_values}->{prct_success} + ); +} + +sub custom_attach_req_calc { + my ($self, %options) = @_; + + $self->{result_values}->{attach_req_total} = $options{new_datas}->{$self->{instance} . '_attach_req_total'} - $options{old_datas}->{$self->{instance} . '_attach_req_total'}; + $self->{result_values}->{attach_req_success} = $options{new_datas}->{$self->{instance} . '_attach_req_success'} - $options{old_datas}->{$self->{instance} . '_attach_req_success'}; + $self->{result_values}->{prct_success} = 100; + if ($self->{result_values}->{attach_req_total} > 0) { + $self->{result_values}->{prct_success} = $self->{result_values}->{attach_req_success} * 100 / $self->{result_values}->{attach_req_total}; + } + return 0; +} + +sub custom_pdn_req_output { + my ($self, %options) = @_; + + return sprintf( + 'pdn context activation requests total: %s success: %s (%.2f%%)', + $self->{result_values}->{pdn_context_total}, + $self->{result_values}->{pdn_context_success}, + $self->{result_values}->{prct_success} + ); +} + +sub custom_pdn_req_calc { + my ($self, %options) = @_; + + $self->{result_values}->{pdn_context_total} = $options{new_datas}->{$self->{instance} . '_pdn_context_total'} - $options{old_datas}->{$self->{instance} . '_pdn_context_total'}; + $self->{result_values}->{pdn_context_success} = $options{new_datas}->{$self->{instance} . '_pdn_context_success'} - $options{old_datas}->{$self->{instance} . '_pdn_context_success'}; + $self->{result_values}->{prct_success} = 100; + if ($self->{result_values}->{pdn_context_total} > 0) { + $self->{result_values}->{prct_success} = $self->{result_values}->{pdn_context_success} * 100 / $self->{result_values}->{pdn_context_total}; + } + return 0; +} + +sub prefix_lte_output { + my ($self, %options) = @_; + + return 'Lte '; +} + +sub lte_long_output { + my ($self, %options) = @_; + + return 'checking lte'; +} + +sub prefix_pdn_rej_output { + my ($self, %options) = @_; + + return 'pdn context requests reject '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'lte', type => 3, cb_prefix_output => 'prefix_lte_output', cb_long_output => 'lte_long_output', indent_long_output => ' ', + group => [ + { name => 'global_traffic', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_users', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_attach_req', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_pdn_req', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_ue', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global_pdn_rej', type => 0, cb_prefix_output => 'prefix_pdn_rej_output', skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{global_traffic} = [ + { label => 'packets-in', nlabel => 'lte.packets.in.count', set => { + key_values => [ { name => 'packets_in', diff => 1 } ], + output_template => 'packets in: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + }, + { label => 'packets-out', nlabel => 'lte.packets.out.count', set => { + key_values => [ { name => 'packets_out', diff => 1 } ], + output_template => 'packets out: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{global_users} = [ + { label => 'users-connected', nlabel => 'lte.users.connected.count', set => { + key_values => [ { name => 'users_connected' } ], + output_template => 'connected users: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + }, + { label => 'users-idle', nlabel => 'lte.users.idle.count', set => { + key_values => [ { name => 'users_idle' } ], + output_template => 'idle users: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + }, + { label => 'sessions-active', nlabel => 'lte.sessions.active.count', set => { + key_values => [ { name => 'sessions_active' } ], + output_template => 'active sessions: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{global_attach_req} = [ + { label => 'requests-attach-success', nlabel => 'lte.requests.attach.success.count', set => { + key_values => [ { name => 'attach_req_success', diff => 1 }, { name => 'attach_req_total', diff => 1 } ], + closure_custom_calc => $self->can('custom_attach_req_calc'), + closure_custom_output => $self->can('custom_attach_req_output'), + perfdatas => [ + { template => '%s', min => 0, max => 'attach_req_total' } + ] + } + }, + { label => 'requests-attach-success-prct', nlabel => 'lte.requests.attach.success.percentage', display_ok => 0, set => { + key_values => [ { name => 'attach_req_success', diff => 1 }, { name => 'attach_req_total', diff => 1 } ], + closure_custom_calc => $self->can('custom_attach_req_calc'), + closure_custom_output => $self->can('custom_attach_req_output'), + threshold_use => 'prct_success', + perfdatas => [ + { value => 'prct_success', template => '%s', min => 0, max => 100, unit => '%' } + ] + } + } + ]; + + $self->{maps_counters}->{global_pdn_req} = [ + { label => 'requests-pdn-context-activation', nlabel => 'lte.requests.pdn_context.activations.success.count', set => { + key_values => [ { name => 'pdn_context_success', diff => 1 }, { name => 'pdn_context_total', diff => 1 } ], + closure_custom_calc => $self->can('custom_pdn_req_calc'), + closure_custom_output => $self->can('custom_pdn_req_output'), + perfdatas => [ + { template => '%s', min => 0, max => 'pdn_context_total' } + ] + } + }, + { label => 'requests-pdn-context-activation-prct', nlabel => 'lte.requests.pdn_context.activations.success.percentage', display_ok => 0, set => { + key_values => [ { name => 'pdn_context_success', diff => 1 }, { name => 'pdn_context_total', diff => 1 } ], + closure_custom_calc => $self->can('custom_pdn_req_calc'), + closure_custom_output => $self->can('custom_pdn_req_output'), + threshold_use => 'prct_success', + perfdatas => [ + { value => 'prct_success', template => '%s', min => 0, max => 100, unit => '%' } + ] + } + } + ]; + + $self->{maps_counters}->{global_ue} = [ + { label => 'requests-ue-context-release-total', nlabel => 'lte.requests.ue_context_release.total.count', set => { + key_values => [ { name => 'ue_release_req', diff => 1 } ], + output_template => 'ue context release requests: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + }, + { label => 'requests-ue-context-release-radio-lost', nlabel => 'lte.requests.ue_context_release.radio_lost.count', set => { + key_values => [ { name => 'ue_release_req_radio_lost', diff => 1 } ], + output_template => 'ue context release with radio lost requests: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{global_pdn_rej} = [ + { label => 'requests-pdn-context-rej-insufres', nlabel => 'lte.requests.pdn_context.reject.insufficent_resources.count', set => { + key_values => [ { name => 'pdn_rej_insuf_res', diff => 1 } ], + output_template => 'insufficent resources: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + }, + { label => 'requests-pdn-context-rej-noapn', nlabel => 'lte.requests.pdn_context.reject.no_apn.count', set => { + key_values => [ { name => 'pdn_rej_no_apn', diff => 1 } ], + output_template => 'missing or unknown apn: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + }, + { label => 'requests-pdn-context-rej-nosub', nlabel => 'lte.requests.pdn_context.reject.not_subscribed.count', set => { + key_values => [ { name => 'pdn_rej_no_sub', diff => 1 } ], + output_template => 'not subscribed: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +my $mapping = { + users_connected => { oid => '.1.3.6.1.4.1.35805.10.2.2.1' }, # lteUsersConnected + users_idle => { oid => '.1.3.6.1.4.1.35805.10.2.2.2' }, # lteUsersIdle + sessions_active => { oid => '.1.3.6.1.4.1.35805.10.2.2.4' }, # lteActiveConnections + packets_in => { oid => '.1.3.6.1.4.1.35805.10.2.2.5' }, # lteLoadPktInGi + packets_out => { oid => '.1.3.6.1.4.1.35805.10.2.2.6' }, # lteLoadPktOutGi + attach_req_total => { oid => '.1.3.6.1.4.1.35805.10.2.2.7' }, # lteTotalAttachReq + attach_req_success => { oid => '.1.3.6.1.4.1.35805.10.2.2.8' }, # lteSuccesfullAttach + pdn_context_total => { oid => '.1.3.6.1.4.1.35805.10.2.2.10' }, # lteTotalPDNActReq + pdn_context_success => { oid => '.1.3.6.1.4.1.35805.10.2.2.11' }, # lteActivatedPDNContext + ue_release_req => { oid => '.1.3.6.1.4.1.35805.10.2.2.19' }, # lteUERelReq + ue_release_req_radio_lost => { oid => '.1.3.6.1.4.1.35805.10.2.2.20' }, # lteUERelReqRadioLost + pdn_rej_insuf_res => { oid => '.1.3.6.1.4.1.35805.10.2.2.21' }, # ltePDNRejInsufRes + pdn_rej_no_apn => { oid => '.1.3.6.1.4.1.35805.10.2.2.22' }, # ltePDNRejNoApn + pdn_rej_no_sub => { oid => '.1.3.6.1.4.1.35805.10.2.2.23' } # ltePDNRejNoSubscribed +}; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = 'athonet_epc_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + my $snmp_result = $options{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%$mapping)) ], + nothing_quit => 1 + ); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0); + + $self->{lte}->{global}->{global_traffic} = { + packets_in => $result->{packets_in}, + packets_out => $result->{packets_out} + }; + $self->{lte}->{global}->{global_users} = { + users_connected => $result->{users_connected}, + users_idle => $result->{users_idle}, + sessions_active => $result->{sessions_active} + }; + $self->{lte}->{global}->{global_attach_req} = { + attach_req_total => $result->{attach_req_total}, + attach_req_success => $result->{attach_req_success} + }; + $self->{lte}->{global}->{global_pdn_req} = { + pdn_context_total => $result->{pdn_context_total}, + pdn_context_success => $result->{pdn_context_success} + }; + $self->{lte}->{global}->{global_ue} = { + ue_release_req => $result->{ue_release_req}, + ue_release_req_radio_lost => $result->{ue_release_req_radio_lost} + }; + $self->{lte}->{global}->{global_pdn_rej} = { + pdn_rej_insuf_res => $result->{pdn_rej_insuf_res}, + pdn_rej_no_apn => $result->{pdn_rej_no_apn}, + pdn_rej_no_sub => $result->{pdn_rej_no_sub} + }; +} + +1; + +__END__ + +=head1 MODE + +Check lte. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='users' + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total', 'users-connected', 'users-idle', 'sessions-active', +'packets-in', 'packets-out', +'requests-ue-context-release-total', 'requests-ue-context-release-radio-lost', +'requests-attach-success', 'requests-attach-success-prct', +'requests-pdn-context-activation', 'requests-pdn-context-activation-prct', +'requests-pdn-context-rej-insufres', 'requests-pdn-context-rej-noapn', 'requests-pdn-context-rej-nosub'. + +=back + +=cut diff --git a/network/athonet/epc/snmp/plugin.pm b/network/athonet/epc/snmp/plugin.pm new file mode 100644 index 000000000..b57549f2c --- /dev/null +++ b/network/athonet/epc/snmp/plugin.pm @@ -0,0 +1,57 @@ +# +# Copyright 2020 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 network::athonet::epc::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} = { + 'interfaces-diameter' => 'network::athonet::epc::snmp::mode::interfacesdiameter', + 'interfaces-lte' => 'network::athonet::epc::snmp::mode::interfaceslte', + 'interfaces-ga' => 'network::athonet::epc::snmp::mode::interfacesga', + 'interfaces-gtpc' => 'network::athonet::epc::snmp::mode::interfacesgtpc', + 'license' => 'network::athonet::epc::snmp::mode::license', + 'list-interfaces-diameter' => 'network::athonet::epc::snmp::mode::listinterfacesdiameter', + 'list-interfaces-ga' => 'network::athonet::epc::snmp::mode::listinterfacesga', + 'list-interfaces-gtpc' => 'network::athonet::epc::snmp::mode::listinterfacesgtpc', + 'list-interfaces-lte' => 'network::athonet::epc::snmp::mode::listinterfaceslte', + 'lte' => 'network::athonet::epc::snmp::mode::lte' + }; + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Athonet ePC in SNMP. + +=cut