add versa sd-wan and ipsec modes
This commit is contained in:
parent
36e4fde356
commit
e5471a086c
|
@ -0,0 +1,208 @@
|
||||||
|
#
|
||||||
|
# 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::versa::snmp::mode::ipsec;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'ipsec', type => 1, cb_prefix_output => 'prefix_ipsec_output', message_multiple => 'All IPsec tunnels are ok' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{ipsec} = [
|
||||||
|
{ label => 'packets-in', nlabel => 'ipsec.packets.in.count', display_ok => 0, set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'in_pkts', diff => 1 }, { name => 'org_name' }
|
||||||
|
],
|
||||||
|
output_template => 'packets in: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'org_name' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'packets-invalid', nlabel => 'ipsec.packets.invalid.count', display_ok => 0, set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'invalid_pkts', diff => 1 }, { name => 'org_name' }
|
||||||
|
],
|
||||||
|
output_template => 'packets invalid: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'org_name' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'traffic-in', nlabel => 'ipsec.traffic.in.bytespersecond', set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'in_bytes', per_second => 1 }, { name => 'org_name' }
|
||||||
|
],
|
||||||
|
output_template => 'traffic in: %.2f %s/s',
|
||||||
|
output_change_bytes => 2,
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'org_name' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'packets-out', nlabel => 'ipsec.packets.out.count', display_ok => 0, set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'out_pkts', diff => 1 }, { name => 'org_name' }
|
||||||
|
],
|
||||||
|
output_template => 'packets out: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'org_name' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'traffic-out', nlabel => 'ipsec.traffic.out.bytespersecond', set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'out_bytes', per_second => 1 }, { name => 'org_name' }
|
||||||
|
],
|
||||||
|
output_template => 'traffic out: %.2f %s/s',
|
||||||
|
output_change_bytes => 2,
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'org_name' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'ike-disconnected', nlabel => 'ipsec.ike.disconnected.count', set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'ike_disconnected', diff => 1 }, { name => 'org_name' }
|
||||||
|
],
|
||||||
|
output_template => 'ike disconnected: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'org_name' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'filter-org:s' => { name => 'filter_org' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_ipsec_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"IPsec '%s' ",
|
||||||
|
$options{instance_value}->{org_name}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $mapping = {
|
||||||
|
in_pkts => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.9.1.1.5' }, # ipsecMibIpsecStatsInPkts
|
||||||
|
in_bytes => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.9.1.1.6' }, # ipsecMibIpsecStatsInBytes
|
||||||
|
invalid_pkts => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.9.1.1.5' }, # ipsecMibIpsecStatsInInvalid
|
||||||
|
out_pkts => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.9.1.1.14' }, # ipsecMibIpsecStatsOutPkts
|
||||||
|
out_bytes => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.9.1.1.15' }, # ipsecMibIpsecStatsOutBytes
|
||||||
|
ike_disconnected => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.9.1.1.42' } # ipsecMibIpsecStatsIkeDisconnects
|
||||||
|
};
|
||||||
|
my $oid_ipsecMibIpsecStatsOrgName = '.1.3.6.1.4.1.42359.2.2.1.2.1.9.1.1.2';
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
if ($options{snmp}->is_snmpv1()) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => 'Need to use SNMP v2c or v3.');
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $snmp_result = $options{snmp}->get_table(oid => $oid_ipsecMibIpsecStatsOrgName, nothing_quit => 1);
|
||||||
|
$self->{ipsec} = {};
|
||||||
|
foreach (keys %$snmp_result) {
|
||||||
|
/^$oid_ipsecMibIpsecStatsOrgName\.(.*)$/;
|
||||||
|
my $instance = $1;
|
||||||
|
my $org_name = $snmp_result->{$_};
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{filter_org}) && $self->{option_results}->{filter_org} ne '' &&
|
||||||
|
$org_name !~ /$self->{option_results}->{filter_org}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping ipsec '" . $org_name . "'.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{ipsec}->{$instance} = { org_name => $org_name };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scalar(keys %{$self->{ipsec}}) <= 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "No ipsec tunnels found.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$options{snmp}->load(oids => [
|
||||||
|
map($_->{oid}, values(%$mapping))
|
||||||
|
],
|
||||||
|
instances => [keys %{$self->{ipsec}}],
|
||||||
|
instance_regexp => '^(.*)$'
|
||||||
|
);
|
||||||
|
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
|
||||||
|
|
||||||
|
foreach (keys %{$self->{ipsec}}) {
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
|
||||||
|
|
||||||
|
$self->{ipsec}->{$_} = { %{$self->{ipsec}->{$_}}, %$result };
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{cache_name} = 'versanetworks_' . $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_org}) ? md5_hex($self->{option_results}->{filter_org}) : md5_hex('all'));
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check ipsec tunnels.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-counters>
|
||||||
|
|
||||||
|
Only display some counters (regexp can be used).
|
||||||
|
Example: --filter-counters='qos-policy-hit'
|
||||||
|
|
||||||
|
=item B<--filter-org>
|
||||||
|
|
||||||
|
Filter monitoring on 'org' -organization name- (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds.
|
||||||
|
Can be: 'packets-in', 'packets-invalid', 'traffic-in', 'packets-out',
|
||||||
|
'traffic-out', 'ike-disconnected'.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,110 @@
|
||||||
|
#
|
||||||
|
# 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::versa::snmp::mode::listipsec;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $oid_ipsecMibIpsecStatsOrgName = '.1.3.6.1.4.1.42359.2.2.1.2.1.9.1.1.2';
|
||||||
|
my $snmp_result = $options{snmp}->get_table(
|
||||||
|
oid => $oid_ipsecMibIpsecStatsOrgName,
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
my $result = {};
|
||||||
|
foreach (keys %$snmp_result) {
|
||||||
|
$result->{ $snmp_result->{$_} } = { org_name => $snmp_result->{$_} };
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $result = $self->manage_selection(snmp => $options{snmp});
|
||||||
|
foreach (sort keys %$result) {
|
||||||
|
$self->{output}->output_add(long_msg =>
|
||||||
|
sprintf(
|
||||||
|
'[org_name = %s]',
|
||||||
|
$result->{$_}->{org_name}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => 'List IPsec:'
|
||||||
|
);
|
||||||
|
$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 => ['org_name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub disco_show {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $result = $self->manage_selection(snmp => $options{snmp});
|
||||||
|
foreach (sort keys %$result) {
|
||||||
|
$self->{output}->add_disco_entry(
|
||||||
|
%{$result->{$_}}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
List IPsec tunnels.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,124 @@
|
||||||
|
#
|
||||||
|
# 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::versa::snmp::mode::listsdwan;
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
org_name => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.5' }, # sdwanPolicyOrgName
|
||||||
|
policy_name => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.6' }, # sdwanPolicyName
|
||||||
|
rule_name => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.7' } # sdwanPolicyRuleName
|
||||||
|
};
|
||||||
|
my $oid_sdwanPolicyEntry = '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1';
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $snmp_result = $options{snmp}->get_table(
|
||||||
|
oid => $oid_sdwanPolicyEntry,
|
||||||
|
start => $mapping_name->{org_name}->{oid},
|
||||||
|
end => $mapping_name->{rule_name}->{oid},
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
my $results = {};
|
||||||
|
foreach (keys %$snmp_result) {
|
||||||
|
next if (! /^$mapping_name->{org_name}->{oid}\.(.*)$/);
|
||||||
|
my $instance = $1;
|
||||||
|
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping_name, results => $snmp_result, instance => $instance);
|
||||||
|
$results->{$instance} = $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $results = $self->manage_selection(snmp => $options{snmp});
|
||||||
|
foreach (sort keys %$results) {
|
||||||
|
$self->{output}->output_add(long_msg =>
|
||||||
|
sprintf(
|
||||||
|
'[org_name = %s][policy_name = %s][rule_name = %s]',
|
||||||
|
$results->{$_}->{org_name},
|
||||||
|
$results->{$_}->{policy_name},
|
||||||
|
$results->{$_}->{rule_name}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => 'List SD-Wan:'
|
||||||
|
);
|
||||||
|
$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 => ['org_name', 'policy_name', 'rule_name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 SD-Wan rules.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -330,7 +330,7 @@ __END__
|
||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check policy usage.
|
Check QoS policies.
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,260 @@
|
||||||
|
#
|
||||||
|
# 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::versa::snmp::mode::sdwan;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
sub custom_bytespersecond_perfdata {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
$self->{output}->perfdata_add(
|
||||||
|
nlabel => $self->{nlabel},
|
||||||
|
unit => 'B/s',
|
||||||
|
instances => [
|
||||||
|
$self->{result_values}->{org_name},
|
||||||
|
$self->{result_values}->{policy_name},
|
||||||
|
$self->{result_values}->{rule_name}
|
||||||
|
],
|
||||||
|
value => sprintf('%.2f', $self->{result_values}->{ $self->{key_values}->[0]->{name} }),
|
||||||
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||||
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||||
|
min => 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_count_perfdata {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
$self->{output}->perfdata_add(
|
||||||
|
nlabel => $self->{nlabel},
|
||||||
|
instances => [
|
||||||
|
$self->{result_values}->{org_name},
|
||||||
|
$self->{result_values}->{policy_name},
|
||||||
|
$self->{result_values}->{rule_name}
|
||||||
|
],
|
||||||
|
value => sprintf('%s', $self->{result_values}->{ $self->{key_values}->[0]->{name} }),
|
||||||
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||||
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||||
|
min => 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'sdwan', type => 1, cb_prefix_output => 'prefix_sdwan_output', message_multiple => 'All SD-Wan are ok' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{sdwan} = [
|
||||||
|
{ label => 'hit', nlabel => 'sdwan.policy.hit.count', set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'hit_count', diff => 1 }, { name => 'org_name' },
|
||||||
|
{ name => 'policy_name' }, { name => 'rule_name' }
|
||||||
|
],
|
||||||
|
output_template => 'hits: %s',
|
||||||
|
closure_custom_perfdata => $self->can('custom_count_perfdata')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'packets-in', nlabel => 'sdwan.policy.packets.in.count', display_ok => 0, set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'in_pkts', diff => 1 }, { name => 'org_name' },
|
||||||
|
{ name => 'policy_name' }, { name => 'rule_name' }
|
||||||
|
],
|
||||||
|
output_template => 'packets in: %s',
|
||||||
|
closure_custom_perfdata => $self->can('custom_count_perfdata')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'traffic-in', nlabel => 'sdwan.policy.traffic.in.bytespersecond', set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'in_bytes', per_second => 1 }, { name => 'org_name' },
|
||||||
|
{ name => 'policy_name' }, { name => 'rule_name' }
|
||||||
|
],
|
||||||
|
output_template => 'traffic in: %.2f %s/s',
|
||||||
|
output_change_bytes => 2,
|
||||||
|
closure_custom_perfdata => $self->can('custom_bytespersecond_perfdata')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'packets-out', nlabel => 'sdwan.policy.packets.out.count', display_ok => 0, set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'out_pkts', diff => 1 }, { name => 'org_name' },
|
||||||
|
{ name => 'policy_name' }, { name => 'rule_name' }
|
||||||
|
],
|
||||||
|
output_template => 'packets out: %s',
|
||||||
|
closure_custom_perfdata => $self->can('custom_count_perfdata')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'traffic-out', nlabel => 'sdwan.policy.traffic.out.bytespersecond', set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'out_bytes', per_second => 1 }, { name => 'org_name' },
|
||||||
|
{ name => 'policy_name' }, { name => 'rule_name' }
|
||||||
|
],
|
||||||
|
output_template => 'traffic out: %.2f %s/s',
|
||||||
|
output_change_bytes => 2,
|
||||||
|
closure_custom_perfdata => $self->can('custom_bytespersecond_perfdata')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'filter-org:s' => { name => 'filter_org' },
|
||||||
|
'filter-rule:s' => { name => 'filter_rule' },
|
||||||
|
'filter-policy:s' => { name => 'filter_policy' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_sdwan_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"SD-Wan rule '%s' [org: %s] [policy: %s] ",
|
||||||
|
$options{instance_value}->{rule_name},
|
||||||
|
$options{instance_value}->{org_name},
|
||||||
|
$options{instance_value}->{policy_name}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $mapping_name = {
|
||||||
|
org_name => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.5' }, # sdwanPolicyOrgName
|
||||||
|
policy_name => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.6' }, # sdwanPolicyName
|
||||||
|
rule_name => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.7' } # sdwanPolicyRuleName
|
||||||
|
};
|
||||||
|
|
||||||
|
my $mapping_stats = {
|
||||||
|
hit_count => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.8' }, # sdwanPolicyHitCount
|
||||||
|
out_pkts => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.13' }, # sdwanPolicyTxPktsTunnel
|
||||||
|
out_bytes => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.14' }, # sdwanPolicyTxBytesTunnel
|
||||||
|
in_pkts => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.15' }, # sdwanPolicyRxPktsTunnel
|
||||||
|
in_bytes => { oid => '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1.16' } # sdwanPolicyRxBytesTunnel
|
||||||
|
};
|
||||||
|
my $oid_sdwanPolicyEntry = '.1.3.6.1.4.1.42359.2.2.1.2.1.10.1.1';
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $snmp_result = $options{snmp}->get_table(
|
||||||
|
oid => $oid_sdwanPolicyEntry,
|
||||||
|
start => $mapping_name->{org_name}->{oid},
|
||||||
|
end => $mapping_name->{rule_name}->{oid},
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
$self->{sdwan} = {};
|
||||||
|
foreach (keys %$snmp_result) {
|
||||||
|
next if (! /^$mapping_name->{org_name}->{oid}\.(.*)$/);
|
||||||
|
my $instance = $1;
|
||||||
|
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping_name, results => $snmp_result, instance => $instance);
|
||||||
|
if (defined($self->{option_results}->{filter_org}) && $self->{option_results}->{filter_org} ne '' &&
|
||||||
|
$result->{org_name} !~ /$self->{option_results}->{filter_org}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping '" . $result->{org_name} . "': no matching 'org' filter.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if (defined($self->{option_results}->{filter_policy}) && $self->{option_results}->{filter_policy} ne '' &&
|
||||||
|
$result->{policy_name} !~ /$self->{option_results}->{filter_policy}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping '" . $result->{policy_name} . "': no matching filter 'policy' .", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if (defined($self->{option_results}->{filter_rule}) && $self->{option_results}->{filter_rule} ne '' &&
|
||||||
|
$result->{rule_name} !~ /$self->{option_results}->{filter_rule}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping '" . $result->{rule_name} . "': no matching filter. 'rule' ", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{sdwan}->{$instance} = $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scalar(keys %{$self->{sdwan}}) <= 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "No SD-Wan rules found.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$options{snmp}->load(oids => [
|
||||||
|
map($_->{oid}, values(%$mapping_stats))
|
||||||
|
],
|
||||||
|
instances => [keys %{$self->{sdwan}}],
|
||||||
|
instance_regexp => '^(.*)$'
|
||||||
|
);
|
||||||
|
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
|
||||||
|
|
||||||
|
foreach (keys %{$self->{sdwan}}) {
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping_stats, results => $snmp_result, instance => $_);
|
||||||
|
|
||||||
|
$self->{sdwan}->{$_} = { %{$self->{sdwan}->{$_}}, %$result };
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{cache_name} = 'versanetworks_' . $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_org}) ? md5_hex($self->{option_results}->{filter_org}) : md5_hex('all')) . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_rule}) ? md5_hex($self->{option_results}->{filter_rule}) : md5_hex('all')) . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_policy}) ? md5_hex($self->{option_results}->{filter_policy}) : md5_hex('all'));
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check SD-Wan rules.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-counters>
|
||||||
|
|
||||||
|
Only display some counters (regexp can be used).
|
||||||
|
Example: --filter-counters='qos-policy-hit'
|
||||||
|
|
||||||
|
=item B<--filter-org>
|
||||||
|
|
||||||
|
Filter monitoring on 'org' -organization name- (can be a regexp).
|
||||||
|
An org may have 1 to n associated policies and rules
|
||||||
|
|
||||||
|
=item B<--filter-policy>
|
||||||
|
|
||||||
|
Filter monitoring on 'policy' -policy name- (can be a regexp).
|
||||||
|
A policy may have 1 to n associated rules
|
||||||
|
|
||||||
|
=item B<--filter-rule>
|
||||||
|
|
||||||
|
Filter monitoring on 'rule' -rule name- (can be a regexp)
|
||||||
|
Rules are unique
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds.
|
||||||
|
Can be: 'hit', 'packets-in', 'traffic-in', 'packets-out', 'traffic-out'.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -31,10 +31,14 @@ sub new {
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$self->{modes} = {
|
$self->{modes} = {
|
||||||
'devices' => 'network::versa::snmp::mode::devices',
|
'devices' => 'network::versa::snmp::mode::devices',
|
||||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
'list-ipsec' => 'network::versa::snmp::mode::listipsec',
|
||||||
'qos-policy' => 'network::versa::snmp::mode::qospolicy'
|
'list-sdwan' => 'network::versa::snmp::mode::listsdwan',
|
||||||
|
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||||
|
'ipsec' => 'network::versa::snmp::mode::ipsec',
|
||||||
|
'qos-policy' => 'network::versa::snmp::mode::qospolicy',
|
||||||
|
'sdwan' => 'network::versa::snmp::mode::sdwan'
|
||||||
};
|
};
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -46,7 +50,7 @@ __END__
|
||||||
|
|
||||||
=head1 PLUGIN DESCRIPTION
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
Check Versa Equipments in SNMP.
|
Check Versa equipments in SNMP.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue