From d8d21424cdd3d36548d6076a2a44363d7de19893 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Tue, 15 Jun 2021 15:59:36 +0200 Subject: [PATCH] fix(oracle): rman-backup-age - epoch not numeric (#2878) --- database/oracle/mode/rmanbackupage.pm | 42 +++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/database/oracle/mode/rmanbackupage.pm b/database/oracle/mode/rmanbackupage.pm index 082ba3e3a..18f496dfe 100644 --- a/database/oracle/mode/rmanbackupage.pm +++ b/database/oracle/mode/rmanbackupage.pm @@ -78,32 +78,35 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{sql} = sqlmode object - $self->{sql} = $options{sql}; - $self->{sql}->connect(); + $options{sql}->connect(); my $query; if (defined($self->{option_results}->{incremental_level})) { - $query = q{SELECT v$rman_status.object_type, - ((max(v$rman_status.start_time) - date '1970-01-01')*24*60*60) as last_time, - SUM(v$backup_set_details.incremental_level) - FROM v$rman_status LEFT JOIN v$backup_set_details ON v$rman_status.session_recid = v$backup_set_details.session_recid - WHERE operation='BACKUP' - GROUP BY object_type, v$backup_set_details.session_recid ORDER BY last_time DESC + $query = q{ + SELECT v$rman_status.object_type, + ((max(v$rman_status.start_time) - date '1970-01-01')*24*60*60) as last_time, + SUM(v$backup_set_details.incremental_level) + FROM v$rman_status LEFT JOIN v$backup_set_details ON v$rman_status.session_recid = v$backup_set_details.session_recid + WHERE operation='BACKUP' + GROUP BY object_type, v$backup_set_details.session_recid ORDER BY last_time DESC }; } else { - $query = q{SELECT object_type, - ((max(start_time) - date '1970-01-01')*24*60*60) as last_time - FROM v$rman_status - WHERE operation='BACKUP' - GROUP BY object_type}; + $query = q{ + SELECT object_type, + ((max(start_time) - date '1970-01-01')*24*60*60) as last_time + FROM v$rman_status + WHERE operation='BACKUP' + GROUP BY object_type + }; } - $self->{sql}->query(query => $query); - my $result = $self->{sql}->fetchall_arrayref(); - $self->{sql}->disconnect(); + $options{sql}->query(query => $query); + my $result = $options{sql}->fetchall_arrayref(); + $options{sql}->disconnect(); - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("Rman backup age are ok.")); + $self->{output}->output_add( + severity => 'OK', + short_msg => sprintf("Rman backup age are ok.") + ); my $count_backups = 0; my $already_checked = {}; @@ -133,6 +136,7 @@ sub run { my ($type, $last_time) = @$row; next if (defined($self->{option_results}->{filter_type}) && $type !~ /$self->{option_results}->{filter_type}/); + $last_time =~ s/,/./g; my @values = localtime($last_time); my $dt = DateTime->new( year => $values[5] + 1900,