CTOR-305 [Plugin] [CommunityPR] New link-monitor mode on Fortinet Fortigate (#4882)

Co-authored-by: Lucie Dubrunfaut <ldubrunfaut@CNTR-P-PF3DNAR1>
This commit is contained in:
Lucie Dubrunfaut 2024-02-12 08:58:21 +01:00 committed by GitHub
parent 764c39801c
commit 68a17c7d7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 825 additions and 0 deletions

View File

@ -1,5 +1,9 @@
--filter-vdom
--force-counters32
Fortinet
Fortigate
OID
oneaccess-sys-mib
perfdata
SNMP
SSH

View File

@ -0,0 +1,246 @@
#
# Copyright 2024 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::common::fortinet::fortigate::snmp::mode::linkmonitor;
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 prefix_output {
my ($self, %options) = @_;
return sprintf(
"Link monitor '%s' [vdom: %s] [id: %s] ",
$options{instance_value}->{name},
$options{instance_value}->{vdom},
$options{instance_value}->{id}
);
}
sub custom_signal_perfdata {
my ($self) = @_;
my $instances = [];
foreach (@{$self->{instance_mode}->{custom_perfdata_instances}}) {
push @$instances, $self->{result_values}->{$_};
}
$self->{output}->perfdata_add(
nlabel => $self->{nlabel},
instances => $instances,
value => $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 => 'linkmonitor', type => 1, cb_prefix_output => 'prefix_output', message_multiple => 'All link monitors are ok' }
];
$self->{maps_counters}->{linkmonitor} = [
{ label => 'status',
type => 2,
critical_default => '%{state} eq "dead"',
set => {
key_values => [ { name => 'state' }, { name => 'vdom' }, { name => 'name' }, { name => 'id' } ],
output_template => 'state: %s',
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'latency', nlabel => 'linkmonitor.latency.milliseconds', set => {
key_values => [ { name => 'latency' }, { name => 'vdom' }, { name => 'name' }, { name => 'id' } ],
output_template => 'latency: %sms',
closure_custom_perfdata => $self->can('custom_signal_perfdata')
}
},
{ label => 'jitter', nlabel => 'linkmonitor.jitter.milliseconds', set => {
key_values => [ { name => 'jitter' }, { name => 'vdom' }, { name => 'name' }, { name => 'id' } ],
output_template => 'jitter: %sms',
closure_custom_perfdata => $self->can('custom_signal_perfdata')
}
},
{ label => 'packet-loss', nlabel => 'linkmonitor.packet.loss.percentage', set => {
key_values => [ { name => 'packet_loss' }, { name => 'vdom' }, { name => 'name' }, { name => 'id' } ],
output_template => 'packet loss: %.3f%%',
closure_custom_perfdata => $self->can('custom_signal_perfdata')
}
}
];
}
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-id:s' => { name => 'filter_id' },
'filter-name:s' => { name => 'filter_name' },
'filter-vdom:s' => { name => 'filter_vdom' },
'custom-perfdata-instances:s' => { name => 'custom_perfdata_instances' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (!defined($self->{option_results}->{custom_perfdata_instances}) || $self->{option_results}->{custom_perfdata_instances} eq '') {
$self->{option_results}->{custom_perfdata_instances} = '%(name) %(vdom)';
}
$self->{custom_perfdata_instances} = $self->custom_perfdata_instances(
option_name => '--custom-perfdata-instances',
instances => $self->{option_results}->{custom_perfdata_instances},
labels => { name => 1, vdom => 1, id=>1 }
);
}
my $mapping_status = { 0 => 'alive', 1 => 'dead' };
my $mapping = {
name => { oid => '.1.3.6.1.4.1.12356.101.4.8.2.1.2' }, # fgLinkMonitorName
state => { oid => '.1.3.6.1.4.1.12356.101.4.8.2.1.3', map => $mapping_status }, # fgLinkMonitorState
latency => { oid => '.1.3.6.1.4.1.12356.101.4.8.2.1.4' }, # fgLinkMonitorLatency
jitter => { oid => '.1.3.6.1.4.1.12356.101.4.8.2.1.5' }, # fgLinkMonitorJitter
packet_loss => { oid => '.1.3.6.1.4.1.12356.101.4.8.2.1.8' }, # fgLinkMonitorPacketLoss
vdom => { oid => '.1.3.6.1.4.1.12356.101.4.8.2.1.9' }, # fgLinkMonitorVdom
};
my $oid_MappingEntry = '.1.3.6.1.4.1.12356.101.4.8.2.1';
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_MappingEntry,
nothing_quit => 1
);
$self->{linkmonitor} = {};
foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{name}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
$instance !~ /$self->{option_results}->{filter_id}/) {
$self->{output}->output_add(long_msg => "With filter-id: $self->{option_results}->{filter_id} - Skipping link monitor '" . $snmp_result->{$oid} . " with id '" . $instance . "'.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$snmp_result->{$oid} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "With filter-name: $self->{option_results}->{filter_name} - Skipping link monitor '" . $snmp_result->{$oid} . " with id '" . $instance . "'.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_vdom}) && $self->{option_results}->{filter_vdom} ne '' &&
$result->{vdom} !~ /$self->{option_results}->{filter_vdom}/) {
$self->{output}->output_add(long_msg => "With filter-vdom: $self->{option_results}->{filter_vdom} - Skipping vdom '" . $result->{vdom} . "'.", debug => 1);
next;
}
# Remoove the "%" at the end of the result.
chop($result->{packet_loss});
$self->{linkmonitor}->{ $instance } = {
id => $instance,
name => $result->{name},
state => $result->{state},
latency => $result->{latency},
jitter => $result->{jitter},
packet_loss => $result->{packet_loss},
vdom => $result->{vdom}
};
}
return if (scalar(keys %{$self->{linkmonitor}}) <= 0);
# Returns : OK: if empty => User needs to set up filters to avoid this mysterious OK result.
}
1;
__END__
=head1 MODE
Check link monitor.
=over 8
=item B<--filter-id>
Filter link monitor by ID (can be a regexp).
=item B<--filter-name>
Filter link monitor by name (can be a regexp).
=item B<--filter-vdom>
Filter link monitor by virtual domain name (can be a regexp).
=item B<--custom-perfdata-instances>
Define perfdata instance (default: '%(name) %(vdom)').
You can use the following variables: %{name}, %{vdom}, %{id}
=item B<--unknown-status>
Define the conditions to match for the status to be UNKNOWN.
You can use the following variables: %{state}, %{vdom}, %{id}, %{name}
=item B<--warning-status>
Define the conditions to match for the status to be WARNING.
You can use the following variables: %{state}, %{vdom}, %{id}, %{name}
=item B<--critical-status>
Define the conditions to match for the status to be CRITICAL (Default: '%{state} eq "dead"').
You can use the following variables: %{state}, %{vdom}, %{id}, %{name}
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'latency', 'jitter', 'packet-loss'.
=back
=cut

View File

@ -0,0 +1,147 @@
#
# Copyright 2024 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::common::fortinet::fortigate::snmp::mode::listlinkmonitors;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
my $mapping_status = { 0 => 'alive', 1 => 'dead' };
my $mapping = {
name => { oid => '.1.3.6.1.4.1.12356.101.4.8.2.1.2' }, # fgLinkMonitorName
state => { oid => '.1.3.6.1.4.1.12356.101.4.8.2.1.3', map => $mapping_status }, # fgLinkMonitorState
vdom => { oid => '.1.3.6.1.4.1.12356.101.4.8.2.1.9' } # fgLinkMonitorVdom
};
my $oid_table = '.1.3.6.1.4.1.12356.101.4.8.2';
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'filter-state:s' => { name => 'filter_state' },
'filter-vdom:s' => { name => 'filter_vdom' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(oid => $oid_table, start => $mapping->{name}, end => $mapping->{state}, nothing_quit => 1);
foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$snmp_result})) {
next if ($oid !~ /^$mapping->{name}->{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_state}) && $self->{option_results}->{filter_state} ne '' &&
$result->{state} !~ /$self->{option_results}->{filter_state}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{state} . "': no matching filter.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_vdom}) && $self->{option_results}->{filter_vdom} ne '' &&
$result->{vdom} !~ /$self->{option_results}->{filter_vdom}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{vdom} . "': no matching filter.", debug => 1);
next;
}
push @{$self->{linkmonitor}}, $result;
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
if (scalar(keys @{$self->{linkmonitor}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No link monitor found matching.");
$self->{output}->option_exit();
}
foreach (sort @{$self->{linkmonitor}}) {
$self->{output}->output_add(long_msg => sprintf("[Name = %s] [Vdom = %s] [State = %s]", $_->{name}, $_->{vdom}, $_->{state}));
}
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List link monitors:'
);
$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', 'vdom', 'state']);
}
sub disco_show {
my ($self, %options) = @_;
$self->manage_selection(%options);
foreach (sort @{$self->{linkmonitor}}) {
$self->{output}->add_disco_entry(name => $_->{name}, vdom => $_->{vdom}, state => $_->{state});
}
}
1;
__END__
=head1 MODE
List link monitors.
=over 8
=item B<--filter-name>
Filter link monitor by name (can be a regexp).
=item B<--filter-state>
Filter link monitor by state (can be a regexp).
=item B<--filter-vdom>
Filter link monitor by virtual domain name (can be a regexp).
=back
=cut

View File

@ -38,7 +38,9 @@ sub new {
'hardware' => 'centreon::common::fortinet::fortigate::snmp::mode::hardware',
'interfaces' => 'centreon::common::fortinet::fortigate::snmp::mode::interfaces',
'ips-stats' => 'centreon::common::fortinet::fortigate::snmp::mode::ipsstats',
'link-monitor' => 'centreon::common::fortinet::fortigate::snmp::mode::linkmonitor',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'list-link-monitors' => 'centreon::common::fortinet::fortigate::snmp::mode::listlinkmonitors',
'list-virtualdomains' => 'centreon::common::fortinet::fortigate::snmp::mode::listvirtualdomains',
'memory' => 'centreon::common::fortinet::fortigate::snmp::mode::memory',
'sessions' => 'centreon::common::fortinet::fortigate::snmp::mode::sessions',

View File

@ -0,0 +1,408 @@
*** Settings ***
Documentation Network Fortinet Fortigate SNMP plugin
Library OperatingSystem
Library String
Test Timeout 120s
*** Variables ***
${CENTREON_PLUGINS} ${CURDIR}${/}..${/}..${/}..${/}src${/}centreon_plugins.pl
${CMD} perl ${CENTREON_PLUGINS} --plugin=network::fortinet::fortigate::snmp::plugin
# Test simple usage of the linkmonitor mode
&{fortinet_fortigate_linkmonitor_test1}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;;;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;;;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;;;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with filter-id option set to 3
&{fortinet_fortigate_linkmonitor_test2}
... filterid=3
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead | 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with filter-name option set to MonitorWAN1
&{fortinet_fortigate_linkmonitor_test3}
... filterid=
... filtername='MonitorWAN1'
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=OK: Link monitor 'MonitorWAN1' [vdom: root] [id: 1] state: alive, latency: 39.739ms, jitter: 0.096ms, packet loss: 0.000% | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;;0;
# Test linkmonitor mode with filter-vdom option set to 'root'
&{fortinet_fortigate_linkmonitor_test4}
... filterid=
... filtername=
... filtervdom='root'
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;;;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;;;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;;;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with custom-perf-data-instances option set to '%(name) %(id)'
&{fortinet_fortigate_linkmonitor_test5}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances='%(name) %(id)'
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead | 'MonitorWAN1~1#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~1#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~1#linkmonitor.packet.loss.percentage'=0;;;0; 'MonitorWAN2~2#linkmonitor.latency.milliseconds'=46.446;;;0; 'MonitorWAN2~2#linkmonitor.jitter.milliseconds'=1.868;;;0; 'MonitorWAN2~2#linkmonitor.packet.loss.percentage'=1;;;0; 'MonitorWAN3~3#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~3#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~3#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with unknown-status option set to '%{state} eq "alive"'
&{fortinet_fortigate_linkmonitor_test6}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus='\%{state} eq "alive"'
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead UNKNOWN: Link monitor 'MonitorWAN1' [vdom: root] [id: 1] state: alive - Link monitor 'MonitorWAN2' [vdom: root] [id: 2] state: alive | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;;;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;;;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;;;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with warning-status option set to '%{state} eq "alive"'
&{fortinet_fortigate_linkmonitor_test7}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus='\%{state} eq "alive"'
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead WARNING: Link monitor 'MonitorWAN1' [vdom: root] [id: 1] state: alive - Link monitor 'MonitorWAN2' [vdom: root] [id: 2] state: alive | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;;;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;;;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;;;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with critical-status option set to '%{state} eq "alive"'
&{fortinet_fortigate_linkmonitor_test8}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus='\%{state} eq "alive"'
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN1' [vdom: root] [id: 1] state: alive - Link monitor 'MonitorWAN2' [vdom: root] [id: 2] state: alive | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;;;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;;;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;;;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with warning-latency option set to 40
&{fortinet_fortigate_linkmonitor_test9}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=40
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead WARNING: Link monitor 'MonitorWAN2' [vdom: root] [id: 2] latency: 46.446ms | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;0:40;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;0:40;;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;;;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;;;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;0:40;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with critical-latency option set to 40
&{fortinet_fortigate_linkmonitor_test10}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=40
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN2' [vdom: root] [id: 2] latency: 46.446ms - Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;0:40;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;;0:40;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;;;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;;;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;0:40;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with warning-jitter option set to 1
&{fortinet_fortigate_linkmonitor_test11}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=1
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead WARNING: Link monitor 'MonitorWAN2' [vdom: root] [id: 2] jitter: 1.868ms | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;0:1;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;;;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;0:1;;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;;;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;0:1;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with critical-jitter option set to 1
&{fortinet_fortigate_linkmonitor_test12}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=1
... warningpacketloss=
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN2' [vdom: root] [id: 2] jitter: 1.868ms - Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;0:1;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;;;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;;0:1;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;;;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;0:1;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;;0;
# Test linkmonitor mode with warning-packetloss option set to 0.5
&{fortinet_fortigate_linkmonitor_test13}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=0.5
... criticalpacketloss=
... result=CRITICAL: Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead, packet loss: 100.000% WARNING: Link monitor 'MonitorWAN2' [vdom: root] [id: 2] packet loss: 1.000% | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;0:0.5;;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;;;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;;;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;0:0.5;;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;0:0.5;;0;
# Test linkmonitor mode with critical-packetloss option set to 0.5
&{fortinet_fortigate_linkmonitor_test14}
... filterid=
... filtername=
... filtervdom=
... customperfdatainstances=
... unknownstatus=
... warningstatus=
... criticalstatus=
... warninglatency=
... criticallatency=
... warningjitter=
... criticaljitter=
... warningpacketloss=
... criticalpacketloss=0.5
... result=CRITICAL: Link monitor 'MonitorWAN2' [vdom: root] [id: 2] packet loss: 1.000% - Link monitor 'MonitorWAN3' [vdom: root] [id: 3] state: dead, packet loss: 100.000% | 'MonitorWAN1~root#linkmonitor.latency.milliseconds'=39.739;;;0; 'MonitorWAN1~root#linkmonitor.jitter.milliseconds'=0.096;;;0; 'MonitorWAN1~root#linkmonitor.packet.loss.percentage'=0;;0:0.5;0; 'MonitorWAN2~root#linkmonitor.latency.milliseconds'=46.446;;;0; 'MonitorWAN2~root#linkmonitor.jitter.milliseconds'=1.868;;;0; 'MonitorWAN2~root#linkmonitor.packet.loss.percentage'=1;;0:0.5;0; 'MonitorWAN3~root#linkmonitor.latency.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.jitter.milliseconds'=0.000;;;0; 'MonitorWAN3~root#linkmonitor.packet.loss.percentage'=100;;0:0.5;0;
@{fortinet_fortigate_linkmonitor_tests}
... &{fortinet_fortigate_linkmonitor_test1}
... &{fortinet_fortigate_linkmonitor_test2}
... &{fortinet_fortigate_linkmonitor_test3}
... &{fortinet_fortigate_linkmonitor_test4}
... &{fortinet_fortigate_linkmonitor_test5}
... &{fortinet_fortigate_linkmonitor_test6}
... &{fortinet_fortigate_linkmonitor_test7}
... &{fortinet_fortigate_linkmonitor_test8}
... &{fortinet_fortigate_linkmonitor_test9}
... &{fortinet_fortigate_linkmonitor_test10}
... &{fortinet_fortigate_linkmonitor_test11}
... &{fortinet_fortigate_linkmonitor_test12}
... &{fortinet_fortigate_linkmonitor_test13}
... &{fortinet_fortigate_linkmonitor_test14}
# Test simple usage of the list-linkmonitors mode
&{fortinet_fortigate_listlinkmonitors_test1}
... filterstate=
... filtername=
... filtervdom=
... result=List link monitors: \n[Name = MonitorWAN1] [Vdom = root] [State = alive]\n[Name = MonitorWAN2] [Vdom = root] [State = alive]\n[Name = MonitorWAN3] [Vdom = root] [State = dead]
# Test list-linkmonitors mode with filter-name option set to MonitorWAN1
&{fortinet_fortigate_listlinkmonitors_test2}
... filterstate=
... filtername='MonitorWAN1'
... filtervdom=
... result=List link monitors: \n[Name = MonitorWAN1] [Vdom = root] [State = alive]
# Test list-linkmonitors mode with filter-state option set to alive
&{fortinet_fortigate_listlinkmonitors_test3}
... filterstate='alive'
... filtername=
... filtervdom=
... result=List link monitors: \n[Name = MonitorWAN1] [Vdom = root] [State = alive]\n[Name = MonitorWAN2] [Vdom = root] [State = alive]
# Test list-linkmonitors mode with filter-vdom option set to root
&{fortinet_fortigate_listlinkmonitors_test4}
... filterstate=
... filtername=
... filtervdom='root'
... result=List link monitors: \n[Name = MonitorWAN1] [Vdom = root] [State = alive]\n[Name = MonitorWAN2] [Vdom = root] [State = alive]\n[Name = MonitorWAN3] [Vdom = root] [State = dead]
@{fortinet_fortigate_listlinkmonitors_tests}
... &{fortinet_fortigate_listlinkmonitors_test1}
... &{fortinet_fortigate_listlinkmonitors_test2}
... &{fortinet_fortigate_listlinkmonitors_test3}
... &{fortinet_fortigate_listlinkmonitors_test4}
*** Test Cases ***
Network Fortinet Fortigate SNMP link monitor
[Documentation] Network Fortinet Fortigate SNMP link-monitor
[Tags] network Fortinet Fortigate snmp
FOR ${fortinet_fortigate_linkmonitor_test} IN @{fortinet_fortigate_linkmonitor_tests}
${command} Catenate
... ${CMD}
... --mode=link-monitor
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --snmp-community=network-fortinet-fortigate-linkmonitor
${length} Get Length ${fortinet_fortigate_linkmonitor_test.filterid}
IF ${length} > 0
${command} Catenate ${command} --filter-id=${fortinet_fortigate_linkmonitor_test.filterid}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.filtername}
IF ${length} > 0
${command} Catenate ${command} --filter-name=${fortinet_fortigate_linkmonitor_test.filtername}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.filtervdom}
IF ${length} > 0
${command} Catenate ${command} --filter-vdom=${fortinet_fortigate_linkmonitor_test.filtervdom}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.customperfdatainstances}
IF ${length} > 0
${command} Catenate ${command} --custom-perfdata-instances=${fortinet_fortigate_linkmonitor_test.customperfdatainstances}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.unknownstatus}
IF ${length} > 0
${command} Catenate ${command} --unknown-status=${fortinet_fortigate_linkmonitor_test.unknownstatus}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.warningstatus}
IF ${length} > 0
${command} Catenate ${command} --warning-status=${fortinet_fortigate_linkmonitor_test.warningstatus}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.criticalstatus}
IF ${length} > 0
${command} Catenate ${command} --critical-status=${fortinet_fortigate_linkmonitor_test.criticalstatus}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.warninglatency}
IF ${length} > 0
${command} Catenate ${command} --warning-latency=${fortinet_fortigate_linkmonitor_test.warninglatency}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.criticallatency}
IF ${length} > 0
${command} Catenate ${command} --critical-latency=${fortinet_fortigate_linkmonitor_test.criticallatency}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.warningjitter}
IF ${length} > 0
${command} Catenate ${command} --warning-jitter=${fortinet_fortigate_linkmonitor_test.warningjitter}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.criticaljitter}
IF ${length} > 0
${command} Catenate ${command} --critical-jitter=${fortinet_fortigate_linkmonitor_test.criticaljitter}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.warningpacketloss}
IF ${length} > 0
${command} Catenate ${command} --warning-packet-loss=${fortinet_fortigate_linkmonitor_test.warningpacketloss}
END
${length} Get Length ${fortinet_fortigate_linkmonitor_test.criticalpacketloss}
IF ${length} > 0
${command} Catenate ${command} --critical-packet-loss=${fortinet_fortigate_linkmonitor_test.criticalpacketloss}
END
${output} Run ${command}
Log To Console . no_newline=true
${output} Strip String ${output}
Should Be Equal As Strings
... ${output}
... ${fortinet_fortigate_linkmonitor_test.result}
... Wrong result output for:${\n}Command: ${\n}${command}${\n}${\n}Expected output: ${\n}${fortinet_fortigate_linkmonitor_test.result}${\n}${\n}Obtained output:${\n}${output}${\n}${\n}${\n}
... values=False
END
Network Fortinet Fortigate SNMP list link monitor
[Documentation] Network Fortinet Fortigate SNMP list-linkmonitors
[Tags] network Fortinet Fortigate snmp
FOR ${fortinet_fortigate_listlinkmonitors_test} IN @{fortinet_fortigate_listlinkmonitors_tests}
${command} Catenate
... ${CMD}
... --mode=list-link-monitors
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --snmp-community=network-fortinet-fortigate-linkmonitor
${length} Get Length ${fortinet_fortigate_listlinkmonitors_test.filterstate}
IF ${length} > 0
${command} Catenate ${command} --filter-state=${fortinet_fortigate_listlinkmonitors_test.filterstate}
END
${length} Get Length ${fortinet_fortigate_listlinkmonitors_test.filtername}
IF ${length} > 0
${command} Catenate ${command} --filter-name=${fortinet_fortigate_listlinkmonitors_test.filtername}
END
${length} Get Length ${fortinet_fortigate_listlinkmonitors_test.filtervdom}
IF ${length} > 0
${command} Catenate ${command} --filter-vdom=${fortinet_fortigate_listlinkmonitors_test.filtervdom}
END
${output} Run ${command}
Log To Console . no_newline=true
${output} Strip String ${output}
Should Be Equal As Strings
... ${output}
... ${fortinet_fortigate_listlinkmonitors_test.result}
... Wrong result output for:${\n}Command: ${\n}${command}${\n}${\n}Expected output: ${\n}${fortinet_fortigate_listlinkmonitors_test.result}${\n}${\n}Obtained output:${\n}${output}${\n}${\n}${\n}
... values=False
END

View File

@ -0,0 +1,18 @@
.1.3.6.1.4.1.12356.101.4.8.2.1.2.1 = STRING: "MonitorWAN1"
.1.3.6.1.4.1.12356.101.4.8.2.1.2.2 = STRING: "MonitorWAN2"
.1.3.6.1.4.1.12356.101.4.8.2.1.2.3 = STRING: "MonitorWAN3"
.1.3.6.1.4.1.12356.101.4.8.2.1.3.1 = STRING: "0"
.1.3.6.1.4.1.12356.101.4.8.2.1.3.2 = STRING: "0"
.1.3.6.1.4.1.12356.101.4.8.2.1.3.3 = STRING: "1"
.1.3.6.1.4.1.12356.101.4.8.2.1.4.1 = STRING: "39.739"
.1.3.6.1.4.1.12356.101.4.8.2.1.4.2 = STRING: "46.446"
.1.3.6.1.4.1.12356.101.4.8.2.1.4.3 = STRING: "0.000"
.1.3.6.1.4.1.12356.101.4.8.2.1.5.1 = STRING: "0.096"
.1.3.6.1.4.1.12356.101.4.8.2.1.5.2 = STRING: "1.868"
.1.3.6.1.4.1.12356.101.4.8.2.1.5.3 = STRING: "0.000"
.1.3.6.1.4.1.12356.101.4.8.2.1.8.1 = STRING: "0%"
.1.3.6.1.4.1.12356.101.4.8.2.1.8.2 = STRING: "1%"
.1.3.6.1.4.1.12356.101.4.8.2.1.8.3 = STRING: "100%"
.1.3.6.1.4.1.12356.101.4.8.2.1.9.1 = STRING: "root"
.1.3.6.1.4.1.12356.101.4.8.2.1.9.2 = STRING: "root"
.1.3.6.1.4.1.12356.101.4.8.2.1.9.3 = STRING: "root"