(plugin) network::cisco::meraki::cloudcontroller::restapi - add device.li… (#4486)

This commit is contained in:
qgarnier 2023-06-16 16:50:15 +02:00 committed by GitHub
parent e0922ef7f1
commit 0ad0ff3568
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 9 deletions

View File

@ -443,6 +443,9 @@ sub get_organization_uplink_loss_and_latency {
if (defined($datas)) { if (defined($datas)) {
foreach (@$datas) { foreach (@$datas) {
# sometimes uplink is undef. so we skip
next if (!defined($_->{uplink}));
$self->{datas}->{uplinks_loss_latency}->{ $options{orgId} }->{ $_->{serial} } = {} $self->{datas}->{uplinks_loss_latency}->{ $options{orgId} }->{ $_->{serial} } = {}
if (!defined($self->{datas}->{uplinks_loss_latency}->{ $options{orgId} }->{ $_->{serial} })); if (!defined($self->{datas}->{uplinks_loss_latency}->{ $options{orgId} }->{ $_->{serial} }));
$self->{datas}->{uplinks_loss_latency}->{ $options{orgId} }->{ $_->{serial} }->{ $_->{uplink} } = $_; $self->{datas}->{uplinks_loss_latency}->{ $options{orgId} }->{ $_->{serial} }->{ $_->{uplink} } = $_;

View File

@ -98,6 +98,7 @@ sub set_counters {
{ name => 'device_performance', type => 0, skipped_code => { -10 => 1 } }, { name => 'device_performance', type => 0, skipped_code => { -10 => 1 } },
{ name => 'device_connections', type => 0, cb_prefix_output => 'prefix_connection_output', skipped_code => { -10 => 1 } }, { name => 'device_connections', type => 0, cb_prefix_output => 'prefix_connection_output', skipped_code => { -10 => 1 } },
{ name => 'device_traffic', type => 0, cb_prefix_output => 'prefix_traffic_output', skipped_code => { -10 => 1, -11 => 1 } }, { name => 'device_traffic', type => 0, cb_prefix_output => 'prefix_traffic_output', skipped_code => { -10 => 1, -11 => 1 } },
{ name => 'device_links_counters', type => 0, skipped_code => { -10 => 1, -11 => 1 } },
{ name => 'device_links', display_long => 1, cb_prefix_output => 'prefix_link_output', message_multiple => 'All links are ok', type => 1, skipped_code => { -10 => 1 } }, { name => 'device_links', display_long => 1, cb_prefix_output => 'prefix_link_output', message_multiple => 'All links are ok', type => 1, skipped_code => { -10 => 1 } },
{ name => 'device_ports', display_long => 1, cb_prefix_output => 'prefix_port_output', message_multiple => 'All ports are ok', type => 1, skipped_code => { -10 => 1 } } { name => 'device_ports', display_long => 1, cb_prefix_output => 'prefix_port_output', message_multiple => 'All ports are ok', type => 1, skipped_code => { -10 => 1 } }
] ]
@ -144,7 +145,7 @@ sub set_counters {
{ template => '%s', min => 0, max => 'total' } { template => '%s', min => 0, max => 'total' }
] ]
} }
}, }
]; ];
$self->{maps_counters}->{device_status} = [ $self->{maps_counters}->{device_status} = [
@ -217,7 +218,7 @@ sub set_counters {
output_template => 'in: %s %s/s', output_template => 'in: %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }
] ]
} }
}, },
@ -226,7 +227,18 @@ sub set_counters {
output_template => 'out: %s %s/s', output_template => 'out: %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }
]
}
}
];
$self->{maps_counters}->{device_links_counters} = [
{ label => 'links-ineffective', nlabel => 'device.links.ineffective.count', display_ok => 0, set => {
key_values => [ { name => 'ineffective' } ],
output_template => 'links ineffective: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1 }
] ]
} }
} }
@ -356,6 +368,8 @@ sub add_uplink {
); );
if (defined($links)) { if (defined($links)) {
$self->{devices}->{ $options{serial} }->{device_links_counters} = { ineffective => 0 };
foreach (@$links) { foreach (@$links) {
my $interface = lc($_->{interface}); my $interface = lc($_->{interface});
$interface =~ s/\s+//g; $interface =~ s/\s+//g;
@ -363,6 +377,8 @@ sub add_uplink {
display => $interface, display => $interface,
link_status => lc($_->{status}) link_status => lc($_->{status})
}; };
$self->{devices}->{ $options{serial} }->{device_links_counters}->{ineffective}++
if ($_->{status} =~ /failed|Not Connected/i);
} }
} }
} }
@ -656,7 +672,7 @@ Thresholds.
Can be: 'total-online', 'total-online-prct', 'total-offline', 'total-offline-prct', 'total-alerting', Can be: 'total-online', 'total-online-prct', 'total-offline', 'total-offline-prct', 'total-alerting',
'traffic-in', 'traffic-out', 'connections-success', 'connections-auth', 'traffic-in', 'traffic-out', 'connections-success', 'connections-auth',
'connections-assoc', 'connections-dhcp', 'connections-dns', 'connections-assoc', 'connections-dhcp', 'connections-dns',
'load', 'link-latency' (ms), ''link-loss' (%), 'load', 'links-ineffective', 'link-latency' (ms), ''link-loss' (%),
'port-traffic-in', 'port-traffic-out'. 'port-traffic-in', 'port-traffic-out'.
=back =back

View File

@ -84,7 +84,9 @@ sub manage_selection {
status => $devices_statuses->{ $devices->{$_}->{serial} }->{status}, status => $devices_statuses->{ $devices->{$_}->{serial} }->{status},
public_ip => $devices_statuses->{ $devices->{$_}->{serial} }->{publicIp}, public_ip => $devices_statuses->{ $devices->{$_}->{serial} }->{publicIp},
network_name => $networks->{ $devices->{$_}->{networkId} }->{name}, network_name => $networks->{ $devices->{$_}->{networkId} }->{name},
organization_name => $organization_name organization_name => $organization_name,
model => $devices->{$_}->{model},
serial => $_
}; };
} }
@ -97,11 +99,13 @@ sub run {
my $devices = $self->manage_selection(%options); my $devices = $self->manage_selection(%options);
foreach (values %$devices) { foreach (values %$devices) {
$self->{output}->output_add(long_msg => sprintf( $self->{output}->output_add(long_msg => sprintf(
'[name: %s][status: %s][network name: %s][organization name: %s]', '[name: %s][status: %s][network name: %s][organization name: %s][model: %s][serial: %s]',
$_->{name}, $_->{name},
$_->{status}, $_->{status},
$_->{network_name}, $_->{network_name},
$_->{organization_name} $_->{organization_name},
$_->{model},
$_->{serial}
) )
); );
} }
@ -118,7 +122,7 @@ sub disco_format {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{output}->add_disco_format(elements => [ $self->{output}->add_disco_format(elements => [
'name', 'status', 'tags', 'organization_name', 'network_id', 'network_name' 'name', 'status', 'tags', 'organization_name', 'network_id', 'network_name', 'model', 'serial'
]); ]);
} }
@ -133,7 +137,9 @@ sub disco_show {
network_name => $_->{network_name}, network_name => $_->{network_name},
network_id => $_->{networkId}, network_id => $_->{networkId},
organization_name => $_->{organization_name}, organization_name => $_->{organization_name},
tags => defined($_->{tags}) ? join(',', @{$_->{tags}}) : '' tags => defined($_->{tags}) ? join(',', @{$_->{tags}}) : '',
model => $_->{model},
serial => $_->{serial}
); );
} }
} }