diff --git a/src/apps/backup/rubrik/restapi/custom/api.pm b/src/apps/backup/rubrik/restapi/custom/api.pm index fcb608b25..11059959a 100644 --- a/src/apps/backup/rubrik/restapi/custom/api.pm +++ b/src/apps/backup/rubrik/restapi/custom/api.pm @@ -404,7 +404,7 @@ sub get_cache_file_response { sub cache_jobs_monitoring { my ($self, %options) = @_; - my $datas = $self->get_jobs_monitoring(disable_cache => 1, limit => $options{limit}); + my $datas = $self->get_jobs_monitoring(disable_cache => 1, get_param => $options{get_param}); $self->write_cache_file( statefile => 'jobs_monitoring', response => $datas @@ -422,7 +422,7 @@ sub get_jobs_monitoring { return $self->request_api( endpoint => '/api/v1/job_monitoring', label => 'jobMonitoringInfoList', - get_param => ['limit=' . $options{limit}] + get_param => $options{get_param} ); } diff --git a/src/apps/backup/rubrik/restapi/mode/cache.pm b/src/apps/backup/rubrik/restapi/mode/cache.pm index 99568473f..b0277cf8a 100644 --- a/src/apps/backup/rubrik/restapi/mode/cache.pm +++ b/src/apps/backup/rubrik/restapi/mode/cache.pm @@ -31,7 +31,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'limit:s' => { name => 'limit' } + 'filter-job-type:s' => { name => 'filter_job_type' }, + 'limit:s' => { name => 'limit' } }); return $self; @@ -49,7 +50,12 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - $options{custom}->cache_jobs_monitoring(limit => $self->{option_results}->{limit}); + my $get_param = [ 'limit=' . $self->{option_results}->{limit} ]; + if (defined($self->{option_results}->{filter_job_type}) && $self->{option_results}->{filter_job_type} ne '') { + push @{$get_param}, 'job_type=' . $self->{option_results}->{filter_job_type}; + } + + $options{custom}->cache_jobs_monitoring(get_param => $get_param); $self->{output}->output_add( severity => 'OK', @@ -67,6 +73,10 @@ Create cache files (job mode could use it with --cache-use option). =over 8 +=item B<--filter-job-type> + +Filter jobs by job type. + =item B<--limit> Define the number of entries to retrieve for the pagination (default: 500). diff --git a/src/apps/backup/rubrik/restapi/mode/jobs.pm b/src/apps/backup/rubrik/restapi/mode/jobs.pm index 380adbda6..24ea815ec 100644 --- a/src/apps/backup/rubrik/restapi/mode/jobs.pm +++ b/src/apps/backup/rubrik/restapi/mode/jobs.pm @@ -92,9 +92,11 @@ sub job_long_output { my ($self, %options) = @_; return sprintf( - "checking job '%s' [type: %s]", + "checking job '%s' [type: %s] [object type: %s] [location name: %s]", $options{instance_value}->{name}, - $options{instance_value}->{jobType} + $options{instance_value}->{jobType}, + $options{instance_value}->{objectType}, + $options{instance_value}->{locationName} ); } @@ -217,6 +219,7 @@ sub new { 'filter-job-name:s' => { name => 'filter_job_name' }, 'filter-job-type:s' => { name => 'filter_job_type' }, 'filter-location-name:s' => { name => 'filter_location_name' }, + 'filter-object-type:s' => { name => 'filter_object_type' }, 'unit:s' => { name => 'unit', default => 's' }, 'limit:s' => { name => 'limit' } }); @@ -244,14 +247,15 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - my $jobs_exec = $options{custom}->get_jobs_monitoring(limit => $self->{option_results}->{limit}); + my $jobs_exec = $options{custom}->get_jobs_monitoring(get_param => [ 'limit=' . $self->{option_results}->{limit} ]); $self->{cache_exec}->read(statefile => 'rubrik_' . $self->{mode} . '_' . Digest::MD5::md5_hex( $options{custom}->get_connection_info() . '_' . (defined($self->{option_results}->{filter_job_id}) ? $self->{option_results}->{filter_job_id} : '') . '_' . (defined($self->{option_results}->{filter_job_name}) ? $self->{option_results}->{filter_job_name} : '') . '_' . - (defined($self->{option_results}->{filter_job_type}) ? $self->{option_results}->{filter_job_type} : '') + (defined($self->{option_results}->{filter_job_type}) ? $self->{option_results}->{filter_job_type} : '') . '_' . + (defined($self->{option_results}->{filter_object_type}) ? $self->{option_results}->{filter_object_type} : '') ) ); my $ctime = time(); @@ -267,6 +271,8 @@ sub manage_selection { $job_exec->{objectName} !~ /$self->{option_results}->{filter_job_name}/); next if (defined($self->{option_results}->{filter_job_type}) && $self->{option_results}->{filter_job_type} ne '' && $job_exec->{jobType} !~ /$self->{option_results}->{filter_job_type}/i); + next if (defined($self->{option_results}->{filter_object_type}) && $self->{option_results}->{filter_object_type} ne '' && + $job_exec->{objectType} !~ /$self->{option_results}->{filter_object_type}/i); next if (defined($self->{option_results}->{filter_location_name}) && $self->{option_results}->{filter_location_name} ne '' && $job_exec->{locationName} !~ /$self->{option_results}->{filter_location_name}/); @@ -276,6 +282,8 @@ sub manage_selection { $self->{jobs}->{ $job_exec->{objectId} } = { name => $job_exec->{objectName}, jobType => $job_exec->{jobType}, + objectType => $job_exec->{objectType}, + locationName => $job_exec->{locationName}, timers => {}, executions => {} }; @@ -289,7 +297,8 @@ sub manage_selection { if (!defined($_->{endTime}) && $_->{jobStatus} =~ /Active/i) { $older_running_exec = $_; } - if (!defined($last_exec) && $_->{jobStatus} !~ /Scheduled/i) { + + if ($_->{jobStatus} !~ /Scheduled|Canceled|Canceling|CancelingScheduled/i) { $last_exec = $_; } @@ -382,6 +391,10 @@ Filter jobs by job name. Filter jobs by job type. +=item B<--filter-object-type> + +Filter jobs by object type. + =item B<--filter-location-name> Filter jobs by location name.