=pod Name: OracleRMAN.pm Author: "Paul C. DeLong" Date: (checking to see if Subversion supports auto-filled tags) Conent-Encoding: EBCDIC (no, not really) =cut package OracleRMAN; use strict; use warnings; sub BackupStatus { shift; # discarding object/package name - we just don't care my( $hand, @errors ); my( $path, $hours, $name, @IgnoreErrors ) = split ',', shift; my @NotErrors = qw( RMAN-00571 RMAN-00569 ); push @NotErrors, @IgnoreErrors; my @stats = stat $path; return "UNKNOWN The specified log file does not exist: ${path}" unless @stats; return "WARNING The file exists, but is empty." unless $stats[7]; open $hand, $path; return "UNKNOWN Failed to open log file: ${path}" unless $hand; foreach( readline $hand ) { next unless m/\b((?:RMAN|ORA)-\d*)/; next if grep { $1 eq $_ } @NotErrors; chomp; push @errors, $_; } ( $name ) = ( $path =~ m/_(\w+)\./ ) unless $name; if( @errors ) { my $tmp = join ', ', @errors; return "CRITICAL The following errors occurred for database $name during the RMAN backup process: ${tmp}"; } my $mtime = $stats[9]; if( time > $mtime + 3600 * $hours ) { my $tmp = scalar gmtime $mtime; return "CRITICAL $name was last successfully backed-up on $tmp GMT" } return "OK $name has completed a recent RMAN backup without any errors."; } 1;