diff --git a/src/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm b/src/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm index dd267e970..4291bbec3 100644 --- a/src/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm +++ b/src/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm @@ -284,13 +284,23 @@ sub call_datas { foreach my $orgId (keys %{$self->{datas}->{orgs}}) { $self->get_organization_uplink_loss_and_latency(orgId => $orgId); } + + if (defined($options{addDeviceClient}) && $options{addDeviceClient} == 1) { + $self->{datas}->{device_clients} = {}; + foreach my $serial (keys %{$self->{datas}->{devices}}) { + $self->{datas}->{device_clients}->{$serial} = $self->get_device_clients( + serial => $serial + ); + } + } + } } sub cache_datas { my ($self, %options) = @_; - $self->call_datas(cache => 1); + $self->call_datas(cache => 1, addDeviceClient => $options{add_clients} // 0); $self->write_cache_file(); return $self->{datas}; diff --git a/src/network/cisco/meraki/cloudcontroller/restapi/mode/cache.pm b/src/network/cisco/meraki/cloudcontroller/restapi/mode/cache.pm index 874d00a9c..6e57c3596 100644 --- a/src/network/cisco/meraki/cloudcontroller/restapi/mode/cache.pm +++ b/src/network/cisco/meraki/cloudcontroller/restapi/mode/cache.pm @@ -30,7 +30,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => {}); + $options{options}->add_options(arguments => { + 'add-clients' => { name => 'add_clients' }, + }); return $self; } @@ -38,7 +40,7 @@ sub new { sub manage_selection { my ($self, %options) = @_; - $options{custom}->cache_datas(); + $options{custom}->cache_datas(add_clients => $self->{option_results}->{add_clients} // 0); $self->{output}->output_add( severity => 'OK', short_msg => 'Cache files created successfully' diff --git a/src/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm b/src/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm index c699545fd..e646880ea 100644 --- a/src/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm +++ b/src/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm @@ -342,9 +342,15 @@ sub add_connection_stats { sub add_clients { my ($self, %options) = @_; - my $clients = $options{custom}->get_device_clients( - serial => $options{serial} - ); + my $clients; + if (defined($options{cache_datas})) { + $clients = $options{cache_datas}->{ $options{serial} }; + + } else { + $clients = $options{custom}->get_device_clients( + serial => $options{serial} + ); + } $self->{devices}->{ $options{serial} }->{device_traffic} = { display => $options{name}, @@ -526,9 +532,10 @@ sub manage_selection { } if (!defined($self->{option_results}->{skip_clients}) && $datas->{devices}->{$serial}->{model} =~ /^(?:MS|MG|MR|MX)/) { $self->add_clients( - custom => $options{custom}, - serial => $serial, - name => $datas->{devices}->{$serial}->{name} + custom => $options{custom}, + serial => $serial, + name => $datas->{devices}->{$serial}->{name}, + cache_datas => (defined($self->{option_results}->{cache_use}) && defined($datas->{device_clients})) ? $datas->{device_clients} : undef ); } if ($datas->{devices}->{$serial}->{model} =~ /^(?:MV|MS|MG|MR|MX)/) {