in reply to Re: ^3 Parse backup log
in thread Parse backup log

Sorry I only gave a snipet of the output of the command that runs at the begining of the script.....the command also spits out some stuff that I do not want matched. Check it out:
bash-2.03$ /usr/openv/netbackup/bin/admincmd/bpmedialist -summary | mo +re ********************************************************************** +********* MEDIA SUMMARY FOR SERVER sjzbkp004 ON Tue Apr 20 13:07:59 2004 ********************************************************************** +********* ACTIVE FULL SUSPENDED FROZEN IMPORTED 159 1782 0 14 0 Number of NON-ACTIVE media that: 8 - are non-active and not written yet ST0315 (FROZEN) ST0306 (FROZEN) ST0304 (FROZEN) ST0314 (FROZEN) ST0308 (FROZEN) ST0309 (FROZEN) ST0312 (FROZEN) ST4910 (FROZEN) 93 - will expire within 1 week ST2885 expires 04/20/2004 23:31 ST6200 expires 04/20/2004 23:37 ST6221 expires 04/21/2004 23:53 ST2819 expires 04/21/2004 00:01 ST2485 expires 04/20/2004 23:44 ST6216 expires 04/21/2004 00:01
So there are a few lines I never want matched. Sorry for the confusion.

Replies are listed 'Best First'.
Re: ^5 Parse backup log
by Belgarion (Chaplain) on Apr 20, 2004 at 20:18 UTC

    Do you want to match all tapes, or just the frozen ones? It would appear you only want to match frozen tapes. A match function like this:

    # # Go through each line of input and create entries for only tapes # matching the "FROZEN" status. # sub match { while (<IMAGES>) { next unless m/\(FROZEN\)/; # skip non-frozen tapes chomp; s/^\s+//; # remove any leading spaces create_entry(split(/\s+/)); } }
    would match only the frozen tapes and then run the create_entry() function for each match.

      I want to match all frozen tapes....let me play around with your code and Ill see what I get...oh and thanks a bunch for all your help.
      That seemed to work ok but did not match all the frozens:
      bash-2.03$ more frozen.html <HTML><HEAD><TITLE>Netbackup Frozen Tape Report</TITLE><H1><CENTER>HEV +A-ATL Frozen Tape Report</H1></CENTER></HEAD><BR><CENTER><FONT SIZE=5>Last updated: 04/20/104 <BR>at 1:54:43 PM </FONT></CENTER><BOD +Y BGCOLOR=white><BR><BR><CENTER><TABLE BORDER=4 WIDTH=60%><TR ALIGN=CENTER><TD>Media ID</TD><TD>Expiration Date</TD><TD>Expiration T +ime</TD></TR> <TR ALIGN=CENTER><TD COLSPAN=3>No currently expired FROZEN tapes</TD>< +/TR> <TR ALIGN=CENTER><TD COLSPAN=3>The following are FROZEN but NOT yet ex +pired</TD></TR> <TR ALIGN=CENTER><TD>ST0026</TD><TD>07/20/2004</TD><TD>22:13 </TD></TR><TR ALIGN=CENTER><TD>ST1606</TD><TD>07/14/2004</TD><TD>22:43 </TD></TR><TR ALIGN=CENTER><TD>ST2838</TD><TD>07/09/2004</TD><TD>20:46 </TD></TR><TR ALIGN=CENTER><TD>ST3574</TD><TD>07/19/2004</TD><TD>22:43 </TD></TR><TR ALIGN=CENTER><TD>ST4173</TD><TD>07/10/2004</TD><TD>20:30 </TD></TR><TR ALIGN=CENTER><TD>ST4782</TD><TD>06/19/2004</TD><TD>22:00 </TD></TR></TABLE></CENTER></BODY></HTML>
      bash-2.03$ /usr/openv/netbackup/bin/admincmd/bpmedialist -summary | gr +ep -i frozen ACTIVE FULL SUSPENDED FROZEN IMPORTED ST0315 (FROZEN) ST0306 (FROZEN) ST0304 (FROZEN) ST0314 (FROZEN) ST0308 (FROZEN) ST0309 (FROZEN) ST0312 (FROZEN) ST4910 (FROZEN) ST4782 expires 06/19/2004 22:00 (FROZEN) ST2838 expires 07/09/2004 20:46 (FROZEN) ST4173 expires 07/10/2004 20:30 (FROZEN) ST1606 expires 07/14/2004 22:43 (FROZEN) ST3574 expires 07/19/2004 22:43 (FROZEN) ST0026 expires 07/20/2004 22:13 (FROZEN)

        I would suggest changing your create_entry function to look like this:

        sub create_entry { # If only two fields are present, the index must # be "expired" (rather than expiring.) $_[1] = 'expired' if @_ == 2; my ($tape_id, @rest) = @_; push (@{$tape_index{$tape_id}}, [$tape_id, @rest]); }

        The problem you're experiencing is that when you have a line like:

        ST4910 (FROZEN)
        you are only getting two fields in your hash. The tape_id, and "(FROZEN)" for the expired field. You then are searching on the "expired" key, which is not present. By changing your create_entry function to the above, both the "expired" and "expires" keys will be properly created.