mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-28 16:14:21 +02:00
enhance cisco meraki
This commit is contained in:
parent
b482ee2775
commit
0a30502e91
@ -137,6 +137,21 @@ sub get_cache_networks {
|
||||
return $self->{cache_networks};
|
||||
}
|
||||
|
||||
sub get_organization {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->cache_meraki_entities();
|
||||
my $organization_id;
|
||||
if (defined($options{network_id})) {
|
||||
$organization_id = $self->{cache_networks}->{ $options{network_id} }->{organizationId};
|
||||
}
|
||||
my $organization;
|
||||
$organization = $self->{cache_organizations}->{$organization_id}
|
||||
if (defined($organization_id) && defined($self->{cache_organizations}->{$organization_id}));
|
||||
|
||||
return $organization;
|
||||
}
|
||||
|
||||
sub get_organization_id {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -236,9 +236,11 @@ sub new {
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-device-name:s' => { name => 'filter_device_name' },
|
||||
'filter-network-id:s' => { name => 'filter_network_id' },
|
||||
'filter-tags:s' => { name => 'filter_tags' }
|
||||
'filter-device-name:s' => { name => 'filter_device_name' },
|
||||
'filter-network-id:s' => { name => 'filter_network_id' },
|
||||
'filter-organization-name:s' => { name => 'filter_organization_name' },
|
||||
'filter-organization-id:s' => { name => 'filter_organization_id' },
|
||||
'filter-tags:s' => { name => 'filter_tags' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
@ -359,6 +361,8 @@ sub manage_selection {
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_device_name}) ? md5_hex($self->{option_results}->{filter_device_name}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_network_id}) ? md5_hex($self->{option_results}->{filter_network_id}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_organization_id}) ? md5_hex($self->{option_results}->{filter_organization_id}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_organization_name}) ? md5_hex($self->{option_results}->{filter_organization_name}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_tags}) ? md5_hex($self->{option_results}->{filter_tags}) : md5_hex('all'));
|
||||
my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp');
|
||||
my $timespan = 300;
|
||||
@ -382,6 +386,18 @@ sub manage_selection {
|
||||
$self->{output}->output_add(long_msg => "skipping device '" . $_->{name} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
my $organization = $options{custom}->get_organization(network_id => $_->{networkId});
|
||||
if (defined($self->{option_results}->{filter_organization_id}) && $self->{option_results}->{filter_organization_id} ne '' &&
|
||||
$organization->{id} !~ /$self->{option_results}->{filter_organization_id}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping device '" . $_->{name} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{filter_organization_name}) && $self->{option_results}->{filter_organization_name} ne '' &&
|
||||
$organization->{name} !~ /$self->{option_results}->{filter_organization_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping device '" . $_->{name} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$devices->{ $_->{serial} } = $_->{model};
|
||||
}
|
||||
@ -476,6 +492,14 @@ Filter devices by name (Can be a regexp).
|
||||
|
||||
Filter devices by network id (Can be a regexp).
|
||||
|
||||
=item B<--filter-organization-id>
|
||||
|
||||
Filter devices by organization id (Can be a regexp).
|
||||
|
||||
=item B<--filter-organization-name>
|
||||
|
||||
Filter devices by organization name (Can be a regexp).
|
||||
|
||||
=item B<--filter-tags>
|
||||
|
||||
Filter devices by tags (Can be a regexp).
|
||||
|
Loading…
x
Reference in New Issue
Block a user