mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 07:34:35 +02:00
enh(keysight-nvos): enhance ports mode and add license mode (#5304)
Co-authored-by: garnier-quentin <garnier.quentin@gmail.com> Refs: CTOR-289
This commit is contained in:
parent
b0e103adce
commit
bbbee4bb37
110
src/network/keysight/nvos/restapi/mode/license.pm
Normal file
110
src/network/keysight/nvos/restapi/mode/license.pm
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
#
|
||||||
|
# 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 network::keysight::nvos::restapi::mode::license;
|
||||||
|
|
||||||
|
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 'License expiration status: ' . $self->{result_values}->{status} . ' [info: ' . $self->{result_values}->{info} . ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0 }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{
|
||||||
|
label => 'status',
|
||||||
|
type => 2,
|
||||||
|
warning_default => '%{status} =~ /MINOR/i',
|
||||||
|
critical_default => '%{status} =~ /MAJOR|CRITICAL/i',
|
||||||
|
set => {
|
||||||
|
key_values => [ { name => 'status' }, { name => 'info' } ],
|
||||||
|
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 => {
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $result = $options{custom}->request_api(
|
||||||
|
method => 'GET',
|
||||||
|
endpoint => '/api/system/',
|
||||||
|
);
|
||||||
|
|
||||||
|
$self->{global} = {
|
||||||
|
status => $result->{subsystem_alarms}->{subsystem_alarms}->{'License Expiration Status'}->{state},
|
||||||
|
info => $result->{subsystem_alarms}->{subsystem_alarms}->{'License Expiration Status'}->{info}->[0]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Keysight license status.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--unknown-status>
|
||||||
|
|
||||||
|
Define the conditions to match for the status to be UNKNOWN.
|
||||||
|
You can use the following variables: %{status}
|
||||||
|
|
||||||
|
=item B<--warning-status>
|
||||||
|
|
||||||
|
Define the conditions to match for the status to be WARNING (default: '%{status} =~ /MINOR/i').
|
||||||
|
You can use the following variables: %{status}
|
||||||
|
|
||||||
|
=item B<--critical-status>
|
||||||
|
|
||||||
|
Define the conditions to match for the status to be CRITICAL (default: '%{status} =~ /MAJOR|CRITICAL/i').
|
||||||
|
You can use the following variables: %{status}
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
@ -87,7 +87,7 @@ sub run {
|
|||||||
sub disco_format {
|
sub disco_format {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->add_disco_format(elements => ['name', 'type', 'folder', 'application', 'ctm', 'status']);
|
$self->{output}->add_disco_format(elements => ['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub disco_show {
|
sub disco_show {
|
||||||
|
@ -52,17 +52,42 @@ sub manage_selection {
|
|||||||
|
|
||||||
my $results = [];
|
my $results = [];
|
||||||
foreach (@{$ports->{stats_snapshot}}) {
|
foreach (@{$ports->{stats_snapshot}}) {
|
||||||
next if ($_->{type} ne 'Port');
|
next if ($_->{type} !~ /Port/i);
|
||||||
|
|
||||||
my $info = $options{custom}->request_api(
|
my $type;
|
||||||
method => 'GET',
|
if ($_->{type} eq 'Port Group') {
|
||||||
endpoint => '/api/ports/' . $_->{default_name},
|
$type = $_->{type};
|
||||||
get_param => ['properties=enabled,license_status,link_status']
|
} elsif (defined($_->{tp_total_tx_count_bytes})) {
|
||||||
);
|
$type = "Tool Port";
|
||||||
|
} else {
|
||||||
|
$type = "Network Port";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $info;
|
||||||
|
if ($_->{type} eq 'Port Group') {
|
||||||
|
$info = $options{custom}->request_api(
|
||||||
|
method => 'GET',
|
||||||
|
endpoint => '/internal/port_groups/' . $_->{id},
|
||||||
|
get_param => ['properties=name,link_status']
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$info = $options{custom}->request_api(
|
||||||
|
method => 'GET',
|
||||||
|
endpoint => '/api/ports/' . $_->{id},
|
||||||
|
get_param => ['properties=name,enabled,license_status,link_status']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $adminStatus = 'none';
|
||||||
|
if (defined($info->{enabled})) {
|
||||||
|
$adminStatus = $info->{enabled} =~ /true|1/i ? 'enabled' : 'disabled';
|
||||||
|
}
|
||||||
|
|
||||||
push @$results, {
|
push @$results, {
|
||||||
name => $_->{default_name},
|
defaultName => $_->{default_name},
|
||||||
adminStatus => $info->{enabled} =~ /true|1/i ? 'enabled' : 'disabled',
|
name => $info->{name},
|
||||||
|
type => $type,
|
||||||
|
adminStatus => $adminStatus,
|
||||||
operationalStatus => $info->{link_status}->{link_up} =~ /true|1/i ? 'up' : 'down'
|
operationalStatus => $info->{link_status}->{link_up} =~ /true|1/i ? 'up' : 'down'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -77,8 +102,10 @@ sub run {
|
|||||||
foreach (@$results) {
|
foreach (@$results) {
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
long_msg => sprintf(
|
long_msg => sprintf(
|
||||||
'[name: %s][adminStatus: %s][operationalStatus: %s]',
|
'[defaultName: %s][name: %s][type: %s][adminStatus: %s][operationalStatus: %s]',
|
||||||
|
$_->{defaultName},
|
||||||
$_->{name},
|
$_->{name},
|
||||||
|
$_->{type},
|
||||||
$_->{adminStatus},
|
$_->{adminStatus},
|
||||||
$_->{operationalStatus}
|
$_->{operationalStatus}
|
||||||
)
|
)
|
||||||
@ -97,7 +124,7 @@ sub run {
|
|||||||
sub disco_format {
|
sub disco_format {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->add_disco_format(elements => ['name', 'type', 'folder', 'application', 'ctm', 'status']);
|
$self->{output}->add_disco_format(elements => ['defaultName', 'name', 'type', 'adminStatus', 'operationalStatus']);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub disco_show {
|
sub disco_show {
|
||||||
|
@ -41,8 +41,9 @@ sub port_long_output {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
"checking port '%s'",
|
"checking port '%s' [type: %s]",
|
||||||
$options{instance_value}->{name}
|
$options{instance_value}->{name},
|
||||||
|
$options{instance_value}->{type}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,23 +51,54 @@ sub prefix_port_output {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
"port '%s' ",
|
"port '%s' [type: %s] ",
|
||||||
$options{instance_value}->{name}
|
$options{instance_value}->{name},
|
||||||
|
$options{instance_value}->{type}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub prefix_traffic_output {
|
sub prefix_traffic_in_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'traffic in: ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_traffic_out_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return 'traffic out: ';
|
return 'traffic out: ';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub prefix_packet_output {
|
sub prefix_packet_other_port_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return 'packets ';
|
return 'packets ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub prefix_packet_network_port_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'packets ';
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
@ -76,8 +108,10 @@ sub set_counters {
|
|||||||
group => [
|
group => [
|
||||||
{ name => 'license', type => 0, skipped_code => { -10 => 1 } },
|
{ name => 'license', type => 0, skipped_code => { -10 => 1 } },
|
||||||
{ name => 'link', type => 0, skipped_code => { -10 => 1 } },
|
{ name => 'link', type => 0, skipped_code => { -10 => 1 } },
|
||||||
{ name => 'traffic', type => 0, cb_prefix_output => 'prefix_traffic_output', skipped_code => { -10 => 1 } },
|
{ name => 'traffic_in', type => 0, cb_prefix_output => 'prefix_traffic_in_output', skipped_code => { -10 => 1 } },
|
||||||
{ name => 'packet', type => 0, cb_prefix_output => 'prefix_packet_output', skipped_code => { -10 => 1 } }
|
{ name => 'traffic_out', type => 0, cb_prefix_output => 'prefix_traffic_out_output', skipped_code => { -10 => 1 } },
|
||||||
|
{ name => 'packet_network_port', type => 0, cb_prefix_output => 'prefix_packet_network_port_output', skipped_code => { -10 => 1 } },
|
||||||
|
{ name => 'packet_other_port', type => 0, cb_prefix_output => 'prefix_packet_other_port_output', skipped_code => { -10 => 1 } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@ -105,7 +139,7 @@ sub set_counters {
|
|||||||
critical_default => '%{adminStatus} eq "enabled" and %{operationalStatus} ne "up"',
|
critical_default => '%{adminStatus} eq "enabled" and %{operationalStatus} ne "up"',
|
||||||
set => {
|
set => {
|
||||||
key_values => [
|
key_values => [
|
||||||
{ name => 'adminStatus' }, { name => 'operationalStatus' } , { name => 'name' }
|
{ name => 'adminStatus' }, { name => 'operationalStatus' } , { name => 'name' }, { name => 'type' }
|
||||||
],
|
],
|
||||||
closure_custom_output => $self->can('custom_link_output'),
|
closure_custom_output => $self->can('custom_link_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
@ -114,7 +148,27 @@ sub set_counters {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{traffic} = [
|
$self->{maps_counters}->{traffic_in} = [
|
||||||
|
{ label => 'traffic-in-prct', nlabel => 'port.traffic.in.percentage', set => {
|
||||||
|
key_values => [ { name => 'traffic_in_util' } ],
|
||||||
|
output_template => '%.2f%%',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'traffic-in', nlabel => 'port.traffic.in.bytespersecond', set => {
|
||||||
|
key_values => [ { name => 'traffic_in', per_second => 1 } ],
|
||||||
|
output_template => '%.2f %s/s',
|
||||||
|
output_change_bytes => 1,
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', unit => 'B/s', min => 0, label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{traffic_out} = [
|
||||||
{ label => 'traffic-out-prct', nlabel => 'port.traffic.out.percentage', set => {
|
{ label => 'traffic-out-prct', nlabel => 'port.traffic.out.percentage', set => {
|
||||||
key_values => [ { name => 'traffic_out_util' } ],
|
key_values => [ { name => 'traffic_out_util' } ],
|
||||||
output_template => '%.2f%%',
|
output_template => '%.2f%%',
|
||||||
@ -134,7 +188,7 @@ sub set_counters {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{packet} = [
|
$self->{maps_counters}->{packet_other_port} = [
|
||||||
{ label => 'packets-out', nlabel => 'port.packets.out.count', set => {
|
{ label => 'packets-out', nlabel => 'port.packets.out.count', set => {
|
||||||
key_values => [ { name => 'packets_out', diff => 1 } ],
|
key_values => [ { name => 'packets_out', diff => 1 } ],
|
||||||
output_template => 'out: %s',
|
output_template => 'out: %s',
|
||||||
@ -168,6 +222,49 @@ sub set_counters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{packet_network_port} = [
|
||||||
|
{ label => 'packets-in', nlabel => 'port.packets.in.count', set => {
|
||||||
|
key_values => [ { name => 'packets_in', diff => 1 } ],
|
||||||
|
output_template => 'in: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'packets-pass', nlabel => 'port.packets.pass.count', set => {
|
||||||
|
key_values => [ { name => 'packets_pass', diff => 1 } ],
|
||||||
|
output_template => 'pass: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'packets-invalid', nlabel => 'port.packets.invalid.count', set => {
|
||||||
|
key_values => [ { name => 'packets_invalid', diff => 1 } ],
|
||||||
|
output_template => 'invalid: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'packets-deny', nlabel => 'port.packets.deny.count', set => {
|
||||||
|
key_values => [ { name => 'packets_deny', diff => 1 } ],
|
||||||
|
output_template => 'deny: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'packets-crc-alignment-errors', nlabel => 'port.crc.alignment.errors.count', set => {
|
||||||
|
key_values => [ { name => 'packets_crc_alignment_errors', diff => 1 } ],
|
||||||
|
output_template => 'crc alignment errors: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -176,7 +273,9 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'filter-name:s' => { name => 'filter_name' }
|
'filter-default-name:s' => { name => 'filter_default_name' },
|
||||||
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
|
'filter-type:s' => { name => 'filter_type' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
@ -194,45 +293,101 @@ sub manage_selection {
|
|||||||
|
|
||||||
$self->{ports} = {};
|
$self->{ports} = {};
|
||||||
foreach (@{$result->{stats_snapshot}}) {
|
foreach (@{$result->{stats_snapshot}}) {
|
||||||
next if ($_->{type} ne 'Port');
|
# Only need 'Port Group' and 'Port'
|
||||||
|
next if ($_->{type} !~ /Port/i);
|
||||||
|
|
||||||
|
my $type;
|
||||||
|
if ($_->{type} eq 'Port Group') {
|
||||||
|
$type = $_->{type};
|
||||||
|
} elsif (defined($_->{tp_total_tx_count_bytes})) {
|
||||||
|
$type = "Tool Port";
|
||||||
|
} else {
|
||||||
|
$type = "Network Port";
|
||||||
|
}
|
||||||
|
|
||||||
|
next if (defined($self->{option_results}->{filter_default_name}) && $self->{option_results}->{filter_default_name} ne '' &&
|
||||||
|
$_->{default_name} !~ /$self->{option_results}->{filter_default_name}/);
|
||||||
|
next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||||
|
$type !~ /$self->{option_results}->{filter_type}/);
|
||||||
|
|
||||||
|
my $info;
|
||||||
|
if ($_->{type} eq 'Port Group') {
|
||||||
|
$info = $options{custom}->request_api(
|
||||||
|
method => 'GET',
|
||||||
|
endpoint => '/internal/port_groups/' . $_->{id},
|
||||||
|
get_param => ['properties=name,link_status']
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$info = $options{custom}->request_api(
|
||||||
|
method => 'GET',
|
||||||
|
endpoint => '/api/ports/' . $_->{id},
|
||||||
|
get_param => ['properties=name,enabled,license_status,link_status']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
$_->{default_name} !~ /$self->{option_results}->{filter_name}/);
|
$info->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||||
|
|
||||||
my $info = $options{custom}->request_api(
|
my $name = $_->{default_name};
|
||||||
method => 'GET',
|
if (defined($info->{name}) && $info->{name} ne '') {
|
||||||
endpoint => '/api/ports/' . $_->{default_name},
|
$name = $info->{name};
|
||||||
get_param => ['properties=enabled,license_status,link_status']
|
}
|
||||||
);
|
|
||||||
|
|
||||||
$self->{ports}->{ $_->{default_name} } = {
|
my $adminStatus = 'none';
|
||||||
name => $_->{default_name},
|
if (defined($info->{enabled})) {
|
||||||
license => {
|
$adminStatus = $info->{enabled} =~ /true|1/i ? 'enabled' : 'disabled';
|
||||||
name => $_->{default_name},
|
}
|
||||||
status => lc($info->{license_status}),
|
|
||||||
},
|
$self->{ports}->{$name} = {
|
||||||
link => {
|
name => $name,
|
||||||
name => $_->{default_name},
|
type => $type,
|
||||||
adminStatus => $info->{enabled} =~ /true|1/i ? 'enabled' : 'disabled',
|
link => {
|
||||||
|
name => $name,
|
||||||
|
type => $type,
|
||||||
|
adminStatus => $adminStatus,
|
||||||
operationalStatus => $info->{link_status}->{link_up} =~ /true|1/i ? 'up' : 'down'
|
operationalStatus => $info->{link_status}->{link_up} =~ /true|1/i ? 'up' : 'down'
|
||||||
},
|
}
|
||||||
traffic => {
|
};
|
||||||
|
|
||||||
|
if (defined($info->{license_status})) {
|
||||||
|
$self->{ports}->{$name}->{license} = {
|
||||||
|
name => $name,
|
||||||
|
status => lc($info->{license_status})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type eq 'Port Group' || $type eq 'Tool Port') {
|
||||||
|
$self->{ports}->{$name}->{traffic_out} = {
|
||||||
traffic_out => $_->{tp_total_tx_count_bytes},
|
traffic_out => $_->{tp_total_tx_count_bytes},
|
||||||
traffic_out_util => $_->{tp_current_tx_utilization}
|
traffic_out_util => $_->{tp_current_tx_utilization}
|
||||||
},
|
};
|
||||||
packet => {
|
$self->{ports}->{$name}->{packet_other_port} = {
|
||||||
packets_out => $_->{tp_total_tx_count_packets},
|
packets_out => $_->{tp_total_tx_count_packets},
|
||||||
packets_dropped => $_->{tp_total_drop_count_packets},
|
packets_dropped => $_->{tp_total_drop_count_packets},
|
||||||
packets_insp => $_->{tp_total_insp_count_packets},
|
packets_insp => $_->{tp_total_insp_count_packets},
|
||||||
packets_pass => $_->{tp_total_pass_count_packets}
|
packets_pass => $_->{tp_total_pass_count_packets}
|
||||||
}
|
};
|
||||||
};
|
} else {
|
||||||
|
$self->{ports}->{$name}->{traffic_in} = {
|
||||||
|
traffic_in => $_->{np_total_rx_count_bytes},
|
||||||
|
traffic_in_util => $_->{np_current_rx_utilization}
|
||||||
|
};
|
||||||
|
$self->{ports}->{$name}->{packet_network_port} = {
|
||||||
|
packets_in => $_->{np_total_rx_count_packets},
|
||||||
|
packets_pass => $_->{np_total_pass_count_packets},
|
||||||
|
packets_invalid => $_->{np_total_rx_count_invalid_packets},
|
||||||
|
packets_deny => $_->{np_total_deny_count_packets},
|
||||||
|
packets_crc_alignment_errors => $_->{np_total_rx_count_crc_alignment_errors}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{cache_name} = 'keysight_nvos_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' .
|
$self->{cache_name} = 'keysight_nvos_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' .
|
||||||
md5_hex(
|
md5_hex(
|
||||||
(defined($self->{option_results}->{filter_counters}) ? $self->{option_results}->{filter_counters} : '') . '_' .
|
(defined($self->{option_results}->{filter_counters}) ? $self->{option_results}->{filter_counters} : '') . '_' .
|
||||||
(defined($self->{option_results}->{filter_name}) ? $self->{option_results}->{filter_name} : '')
|
(defined($self->{option_results}->{filter_default_name}) ? $self->{option_results}->{filter_default_name} : '') . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_name}) ? $self->{option_results}->{filter_name} : '') . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_type}) ? $self->{option_results}->{filter_type} : '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,10 +401,19 @@ Check ports.
|
|||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-default-name>
|
||||||
|
|
||||||
|
Filter ports by default name (can be a regexp).
|
||||||
|
|
||||||
=item B<--filter-name>
|
=item B<--filter-name>
|
||||||
|
|
||||||
Filter ports by name (can be a regexp).
|
Filter ports by name (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--filter-type>
|
||||||
|
|
||||||
|
Filter ports by type (can be a regexp).
|
||||||
|
You can use the following types: 'Network Port', 'Port Group' and 'Tool Port'
|
||||||
|
|
||||||
=item B<--unknown-license-status>
|
=item B<--unknown-license-status>
|
||||||
|
|
||||||
Define the conditions to match for the status to be UNKNOWN.
|
Define the conditions to match for the status to be UNKNOWN.
|
||||||
@ -283,7 +447,7 @@ You can use the following variables: %{adminStatus}, %{operationalStatus}, %{nam
|
|||||||
=item B<--warning-*> B<--critical-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Thresholds.
|
Thresholds.
|
||||||
Can be: 'traffic-out-prct', 'traffic-out', 'packets-out', 'packets-dropped',
|
Can be: 'traffic-in-prct', 'traffic-in', 'traffic-out-prct', 'traffic-out', 'packets-out', 'packets-in', 'packets-dropped',
|
||||||
'packets-pass', 'packets-insp'.
|
'packets-pass', 'packets-insp'.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
@ -32,6 +32,7 @@ sub new {
|
|||||||
$self->{modes} = {
|
$self->{modes} = {
|
||||||
'dynamic-filters' => 'network::keysight::nvos::restapi::mode::dynamicfilters',
|
'dynamic-filters' => 'network::keysight::nvos::restapi::mode::dynamicfilters',
|
||||||
'hardware' => 'network::keysight::nvos::restapi::mode::hardware',
|
'hardware' => 'network::keysight::nvos::restapi::mode::hardware',
|
||||||
|
'license' => 'network::keysight::nvos::restapi::mode::license',
|
||||||
'list-dynamic-filters' => 'network::keysight::nvos::restapi::mode::listdynamicfilters',
|
'list-dynamic-filters' => 'network::keysight::nvos::restapi::mode::listdynamicfilters',
|
||||||
'list-ports' => 'network::keysight::nvos::restapi::mode::listports',
|
'list-ports' => 'network::keysight::nvos::restapi::mode::listports',
|
||||||
'ports' => 'network::keysight::nvos::restapi::mode::ports',
|
'ports' => 'network::keysight::nvos::restapi::mode::ports',
|
||||||
|
367
tests/network/keysight/nvos/restapi/keysight.json
Normal file
367
tests/network/keysight/nvos/restapi/keysight.json
Normal file
File diff suppressed because one or more lines are too long
39
tests/network/keysight/nvos/restapi/license.robot
Normal file
39
tests/network/keysight/nvos/restapi/license.robot
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
*** Settings ***
|
||||||
|
Documentation Check the licenses status
|
||||||
|
|
||||||
|
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
|
||||||
|
|
||||||
|
Suite Setup Start Mockoon ${MOCKOON_JSON}
|
||||||
|
Suite Teardown Stop Mockoon
|
||||||
|
Test Timeout 120s
|
||||||
|
|
||||||
|
|
||||||
|
*** Variables ***
|
||||||
|
${MOCKOON_JSON} ${CURDIR}${/}keysight.json
|
||||||
|
|
||||||
|
${cmd} ${CENTREON_PLUGINS}
|
||||||
|
... --plugin=network::keysight::nvos::restapi::plugin
|
||||||
|
... --custommode=api
|
||||||
|
... --hostname=${HOSTNAME}
|
||||||
|
... --api-username=username
|
||||||
|
... --api-password=password
|
||||||
|
... --proto=http
|
||||||
|
... --port=${APIPORT}
|
||||||
|
|
||||||
|
|
||||||
|
*** Test Cases ***
|
||||||
|
license ${tc}
|
||||||
|
[Tags] network restapi
|
||||||
|
${command} Catenate
|
||||||
|
... ${cmd}
|
||||||
|
... --mode=license
|
||||||
|
... ${extraoptions}
|
||||||
|
|
||||||
|
Log ${cmd}
|
||||||
|
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
|
||||||
|
|
||||||
|
Examples: tc extraoptions expected_result --
|
||||||
|
... 1 --verbose OK: status : skipped (no value(s))
|
||||||
|
... 2 --unknown-status=\\\%{status} OK: status : skipped (no value(s))
|
||||||
|
... 3 --warning-status='\\\%{status} =~ /MINOR/i' OK: status : skipped (no value(s))
|
||||||
|
... 4 --critical-status='\\\%{status} =~ /MAJOR|CRITICAL/i' OK: status : skipped (no value(s))
|
48
tests/network/keysight/nvos/restapi/ports.robot
Normal file
48
tests/network/keysight/nvos/restapi/ports.robot
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
*** Settings ***
|
||||||
|
Documentation Check the ports status
|
||||||
|
|
||||||
|
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
|
||||||
|
|
||||||
|
Suite Setup Start Mockoon ${MOCKOON_JSON}
|
||||||
|
Suite Teardown Stop Mockoon
|
||||||
|
Test Timeout 120s
|
||||||
|
|
||||||
|
|
||||||
|
*** Variables ***
|
||||||
|
${MOCKOON_JSON} ${CURDIR}${/}keysight.json
|
||||||
|
|
||||||
|
${cmd} ${CENTREON_PLUGINS}
|
||||||
|
... --plugin=network::keysight::nvos::restapi::plugin
|
||||||
|
... --custommode=api
|
||||||
|
... --hostname=${HOSTNAME}
|
||||||
|
... --api-username=username
|
||||||
|
... --api-password=password
|
||||||
|
... --proto=http
|
||||||
|
... --port=${APIPORT}
|
||||||
|
|
||||||
|
|
||||||
|
*** Test Cases ***
|
||||||
|
ports ${tc}
|
||||||
|
[Tags] network restapi notauto
|
||||||
|
${command} Catenate
|
||||||
|
... ${cmd}
|
||||||
|
... --mode=ports
|
||||||
|
... ${extraoptions}
|
||||||
|
Log ${cmd}
|
||||||
|
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
|
||||||
|
|
||||||
|
Examples: tc extraoptions expected_result --
|
||||||
|
... 1 --verbose OK: All ports are ok | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.percentage'=0.00%;;;0;100 checking port 'P01' license status: valid link operational status: up [admin: enabled] checking port 'P12' license status: valid link operational status: up [admin: enabled] checking port 'P14' license status: valid link operational status: up [admin: enabled] traffic out: 0.00%, traffic-out : Buffer creation packets packets-out : Buffer creation, packets-dropped : Buffer creation, packets-pass : Buffer creation, packets-insp : Buffer creation checking port 'P17' license status: valid link operational status: up [admin: enabled] traffic out: 0.00%, traffic-out : Buffer creation packets packets-out : Buffer creation, packets-dropped : Buffer creation, packets-pass : Buffer creation, packets-insp : Buffer creation
|
||||||
|
... 2 --filter-name OK: All ports are ok | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 3 --unknown-license-status=\\\%{status} UNKNOWN: port 'P01' license status: valid - port 'P12' license status: valid - port 'P14' license status: valid - port 'P17' license status: valid | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 4 --warning-license-status='\\\%{status} =~ /invalid_software_version/' OK: All ports are ok | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 5 --critical-license-status=\\\%{name} CRITICAL: port 'P01' license status: valid - port 'P12' license status: valid - port 'P14' license status: valid - port 'P17' license status: valid | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 6 --unknown-link-status=\\\%{adminStatus} UNKNOWN: port 'P01' link operational status: up [admin: enabled] - port 'P12' link operational status: up [admin: enabled] - port 'P14' link operational status: up [admin: enabled] - port 'P17' link operational status: up [admin: enabled] | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 7 --warning-link-status=\\\%{name} WARNING: port 'P01' link operational status: up [admin: enabled] - port 'P12' link operational status: up [admin: enabled] - port 'P14' link operational status: up [admin: enabled] - port 'P17' link operational status: up [admin: enabled] | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 8 --critical-link-status='\\\%{adminStatus} eq "enabled" and \\\%{operationalStatus} ne "up"' OK: All ports are ok | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 9 --warning-traffic-out-prct --critical-traffic-out-prct OK: All ports are ok | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 10 --warning-packets-out --critical-packets-out OK: All ports are ok | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 11 --warning-traffic-out=0 --critical-traffic-out=100 OK: All ports are ok | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;0:0;0:100;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;0:0;0:100;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 12 --warning-packets-dropped=10 --critical-packets-dropped=0 OK: All ports are ok | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;0:10;0:0;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;0:10;0:0;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 13 --warning-packets-pass --critical-packets-pass OK: All ports are ok | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;;;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;;;0;
|
||||||
|
... 14 --warning-packets-insp=150 --critical-packets-insp=5 OK: All ports are ok | 'P14#port.traffic.out.percentage'=0.00%;;;0;100 'P14#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P14#port.packets.out.count'=0;;;0; 'P14#port.packets.dropped.count'=0;;;0; 'P14#port.packets.pass.count'=0;;;0; 'P14#port.packets.insp.count'=0;0:150;0:5;0; 'P17#port.traffic.out.percentage'=0.00%;;;0;100 'P17#port.traffic.out.bytespersecond'=0.00B/s;;;0; 'P17#port.packets.out.count'=0;;;0; 'P17#port.packets.dropped.count'=0;;;0; 'P17#port.packets.pass.count'=0;;;0; 'P17#port.packets.insp.count'=0;0:150;0:5;0;
|
@ -115,6 +115,7 @@ jobqueues
|
|||||||
journalctl
|
journalctl
|
||||||
kccevent
|
kccevent
|
||||||
keepass
|
keepass
|
||||||
|
Keysight
|
||||||
Kubernetes
|
Kubernetes
|
||||||
ldap
|
ldap
|
||||||
--legacy-api-beta
|
--legacy-api-beta
|
||||||
@ -165,6 +166,7 @@ NLCapacity
|
|||||||
--ntlmv2
|
--ntlmv2
|
||||||
NTLMv2
|
NTLMv2
|
||||||
NTP
|
NTP
|
||||||
|
NVOS
|
||||||
--oid
|
--oid
|
||||||
OID
|
OID
|
||||||
--oid-display
|
--oid-display
|
||||||
@ -197,8 +199,8 @@ queue-messages-inflighted
|
|||||||
RestAPI
|
RestAPI
|
||||||
RFC1628
|
RFC1628
|
||||||
RRDCached
|
RRDCached
|
||||||
SAS
|
|
||||||
Sansymphony
|
Sansymphony
|
||||||
|
SAS
|
||||||
scenarii
|
scenarii
|
||||||
--scope-datacenter
|
--scope-datacenter
|
||||||
sfp.temperature
|
sfp.temperature
|
||||||
|
Loading…
x
Reference in New Issue
Block a user