update variable filter meraki

This commit is contained in:
garnier-quentin 2020-04-01 15:03:13 +02:00
parent f4cb98c749
commit 1763b2f600
2 changed files with 10 additions and 10 deletions

View File

@ -217,7 +217,7 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'filter-device-name:s' => { name => 'filter_device_name' },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /alerting/i' },
@ -244,7 +244,7 @@ sub manage_selection {
$self->{cache_name} = 'meraki_' . $self->{mode} . '_' . $options{custom}->get_token() . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
(defined($self->{option_results}->{filter_device_name}) ? md5_hex($self->{option_results}->{filter_device_name}) : md5_hex('all'));
my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp');
my $timespan = 300;
$timespan = time() - $last_timestamp if (defined($last_timestamp));
@ -252,8 +252,8 @@ sub manage_selection {
my $cache_devices = $options{custom}->get_cache_devices();
my $devices = {};
foreach (values %$cache_devices) {
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$_->{name} !~ /$self->{option_results}->{filter_name}/) {
if (defined($self->{option_results}->{filter_device_name}) && $self->{option_results}->{filter_device_name} ne '' &&
$_->{name} !~ /$self->{option_results}->{filter_device_name}/) {
$self->{output}->output_add(long_msg => "skipping device '" . $_->{name} . "': no matching filter.", debug => 1);
next;
}
@ -327,7 +327,7 @@ Check devices.
=over 8
=item B<--filter-name>
=item B<--filter-device-name>
Filter device name (Can be a regexp).

View File

@ -114,7 +114,7 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' }
'filter-network-name:s' => { name => 'filter_network_name' }
});
return $self;
@ -125,14 +125,14 @@ sub manage_selection {
$self->{cache_name} = 'meraki_' . $self->{mode} . '_' . $options{custom}->get_token() . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
(defined($self->{option_results}->{filter_network_name}) ? md5_hex($self->{option_results}->{filter_network_name}) : md5_hex('all'));
my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp');
my $timespan = 300;
$timespan = time() - $last_timestamp if (defined($last_timestamp));
my $cache_networks = $options{custom}->get_cache_networks();
my $connections = $options{custom}->get_networks_connection_stats(timespan => $timespan, filter_name => $self->{option_results}->{filter_name});
my $clients = $options{custom}->get_networks_clients(timespan => $timespan, filter_name => $self->{option_results}->{filter_name});
my $connections = $options{custom}->get_networks_connection_stats(timespan => $timespan, filter_name => $self->{option_results}->{filter_network_name});
my $clients = $options{custom}->get_networks_clients(timespan => $timespan, filter_name => $self->{option_results}->{filter_network_name});
$self->{networks} = {};
foreach my $id (keys %$connections) {
@ -170,7 +170,7 @@ Check networks.
=over 8
=item B<--filter-name>
=item B<--filter-network-name>
Filter network name (Can be a regexp).