#!/usr/bin/perl -w # # Use on Veritas' NetBackup master server # # print out schedule information in format for import # to a spreadsheet. # my @DAYS = ( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", ); my @TYPE = ( "FULL", "Differential-Incremental", "Cumulative-Incremental", "User-Backup", "User-Archive", ); # this is the default install dir for netbackup class data # yes, readdir is more efficient... my @class = glob("/usr/openv/netbackup/db/class/*"); my $day_secs = 3600 * 24; # Orig -- print "CLASS,CLIENT,TYPE,SCHEDULE,DAY,DAYN,WINDOWSTART,WINDOWLENGTH,STRT_SECS,END_SECS\n"; print "POLICY,STORAGEUNIT,CLIENT,TYPE,SCHEDULE,DAY,DAYN,WINDOWSTART,WINDOWLENGTH,STRT_SECS,END_SECS\n"; foreach $cls (@class) { my @clients = (); my $sto = ''; my $tmp = $cls; $tmp =~ s,.*/,,; # get client list if ( -f "${cls}/clients" ) { open(IN,"<${cls}/clients") or die; while () { my ($clnt) = split(/ /,$_); push(@clients,$clnt); } close(IN); } else { push(@clients,"none"); } # get storage unit if ( -f "${cls}/info" ) { open(IN,"<${cls}/info") or die; while () { chomp; ($key,$sto) = split(/\s+/,$_); if ( $key eq "RESIDENCE" ) { last; } } close(IN); } my @scheds = glob("${cls}/schedule/*"); foreach $schd (@scheds) { my @days = (); my $type = ''; if ( -f "${schd}/days" ) { open (IN,"<${schd}/days") or die; while () { my $strt_secs = 0; my $end_secs = 0; chomp; ($dy,$start,$duration) = split(/\s+/,$_); next if $duration == 0; $strt_secs = ($dy * $day_secs) + $start; $end_secs = $strt_secs + $duration; $dy = "$DAYS[$dy],$dy"; $start = secs($start); $duration = secs($duration); push(@days,"$dy,$start,$duration,$strt_secs,$end_secs"); } close(IN); } if ( -f "${schd}/info" ) { open (IN,"<${schd}/info") or die; while () { chomp; ($key,$type) = split(/\s+/,$_); if ( $key eq "SCHED_TYPE" ) { last; } } close(IN); } $type = $TYPE[$type]; my $schd_tmp = $schd; $schd_tmp =~ s,.*/,,; foreach $clnt (@clients) { foreach $start_stop (@days) { # output comma delimited lines # orig print "$tmp,$clnt,$type,$schd_tmp,$start_stop\n"; print "$tmp,$sto,$clnt,$type,$schd_tmp,$start_stop\n"; } } #print "Schedule: $schd\n"; } } sub secs { my $hr = ''; my $min = ''; my $sec = ''; my $tm = shift; # convert from sec's to hr:min:sec for printout if ( $tm > 59 ) { my $hr = 0; my $sec = $tm % 60; my $min = $tm / 60; if ( $min > 59 ) { my $tmp = $min % 60; $hr = $min / 60; $min = $tmp; } $tm = sprintf "%02d:%02d:%02d",$hr,$min,$sec; } else { $tm = sprintf "%02d:%02d:%02d",0,0,$tm; } return $tm; } #END OF SCRIPT