Forum Discussion

zippy's avatar
zippy
Level 6
17 years ago
Solved

Elapsed time script?

anyone know what command to use to get the elapsed time in minutes seconds?

 

this would be the same output as the Java screen in "client backups reports".

 

This goves me everything I need but the "Elapsed time"

bpimagelist -U -d 10/10/2008 18:00:00 -e 10/13/2008 06:00:00

 

This gives me the Elapesed tiem but in seconds adn in a cruddy output.

 

 bpimagelist -L -d 10/10/2008 18:00:00 -e 10/13/2008 06:00:00

 

 

  • James,

     

    I quickly scripted something for you.

     

    Run this and it will display the data in the following order

     

    Backed up Time/Date  |  Elapsed Seconds |  Expiration Date/Time |  KiloBytes | Files | Policy | Schedule Label |

     

    Hope this helps.

     

     

     

    #!/bin/sh
    BPIMG_CMD=/usr/openv/netbackup/bin/admincmd; export BPIMG_CMD
    BPDBM_CMD=/usr/openv/netbackup/bin; export BPDBM_PATH
    echo  " Backed up Time/Date  |  Elapsed Seconds |  Expiration Date/Time |  KiloBytes | Files | Policy | Schedule Label |"
    $BPIMG_CMD/bpimagelist -d 10/10/2008 18:00:00 -e 10/13/2008 06:00:00 | awk '($1 == "IMAGE"){print $14,$15,$16,$19,$20,$7,$11}' | while read bkptime elapsed bkpexpire kbytes files policy schedule
         do
            echo "`$BPDBM_CMD/bpdbm -ctime $bkptime | cut -d= -f2-20` | $elapsed  | `$BPDBM_CMD/bpdbm -ctime $bkpexpire | cut -d= -f2-20` | $kbytes | $files | $policy |  $schedule |"
         done

6 Replies

Replies have been turned off for this discussion
  • Sorry to say there isn't a NetBackup command that will do what you want without you knowing some scripting.

     

    Something like `bpimagelist -l | grep IMAGE | {insert quit a bit of awk/sprintf magic here}` would probably get you to your ultimate goal.

     

    This TechNote can help you sift through the fields, at least:

     

    DOCUMENTATION: What are the different fields in "bpimagelist -l" output?

     http://support.veritas.com/docs/193085

     

    Quickly scanning through that TechNote, I *believe* the field numbers in the IMAGE line(s) making up your `bpimagelist -U` output are 14, 16, 20, 19, 17, 12, and 7 respectively (with a lot of manipulation to convert numbers into meaningful dates/times/text).  You'll want to add field 15 to that.

  • James,

     

    I quickly scripted something for you.

     

    Run this and it will display the data in the following order

     

    Backed up Time/Date  |  Elapsed Seconds |  Expiration Date/Time |  KiloBytes | Files | Policy | Schedule Label |

     

    Hope this helps.

     

     

     

    #!/bin/sh
    BPIMG_CMD=/usr/openv/netbackup/bin/admincmd; export BPIMG_CMD
    BPDBM_CMD=/usr/openv/netbackup/bin; export BPDBM_PATH
    echo  " Backed up Time/Date  |  Elapsed Seconds |  Expiration Date/Time |  KiloBytes | Files | Policy | Schedule Label |"
    $BPIMG_CMD/bpimagelist -d 10/10/2008 18:00:00 -e 10/13/2008 06:00:00 | awk '($1 == "IMAGE"){print $14,$15,$16,$19,$20,$7,$11}' | while read bkptime elapsed bkpexpire kbytes files policy schedule
         do
            echo "`$BPDBM_CMD/bpdbm -ctime $bkptime | cut -d= -f2-20` | $elapsed  | `$BPDBM_CMD/bpdbm -ctime $bkpexpire | cut -d= -f2-20` | $kbytes | $files | $policy |  $schedule |"
         done

  • The smiley you after the word "IMAGE" should actually be a closed round bracket.

     

    You need copy the script into a file and run it with execute permissions.

     

     

  • thank you now i have to calculate the seconds and kilo's to hours min sec and meg
  • James, I find making repeated calls to bpdbm to convert a ctime into human readable a bit slow.  Also, bpdbm only exists on a master, and not on any flavour of media servers or Windows admin consoles.  And I don't think bpdbm will convert a datetime into a ctime.

     

    Here's some pointers for managing times in Solaris, not sure if they work on all Unix:

     

     

    $ # current time in norm format$ perl -e 'use POSIX qw(strftime); print strftime "%a %e %b %Y %H:%M:%S %Y \n", localtime ; 'Mon 12 Mar 2007 11:00:41 2007 $ # current time in ctime$ perl -e 'print time ; print "\n"' 1173697268$ # above ctime in normal format $ perl -e 'use POSIX qw(strftime); print strftime "%a %e %b %Y %H:%M:%S %Y \n", localtime(1173697268) ; 'Mon 12 Mar 2007 11:01:08 2007$ perl -e 'use POSIX qw(mktime) ; print mktime ( 0, 30, 10, 12, 11, 95); print "\n" ;'818764200$ perl -e 'use POSIX qw(strftime); print strftime "%a %e %b %Y %H:%M:%S %Y \n", localtime(818764200) ; ' Tue 12 Dec 1995 10:30:00 1995 $ perl -e 'use POSIX qw(mktime) ; print mktime ( 0, 30, 10, 12, 11, 95, 0, 0, 1); print "\n" ;' 818760600$ perl -e 'use POSIX qw(strftime); print strftime "%a %e %b %Y %H:%M:%S %Y \n", localtime(818760600) ; 'Tue 12 Dec 1995 09:30:00 1995 mktime variables: int tm_sec; /* seconds after the minute [0, 61] */ int tm_min; /* minutes after the hour [0, 59] */ int tm_hour; /* hour since midnight [0, 23] */ int tm_mday; /* day of the month [1, 31] */ int tm_mon; /* months since January [0, 11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday [0, 6] */ int tm_yday; /* days since January 1 [0, 365] */ int tm_isdst; /* flag for daylight savings time */

     

     

    I can supply some VBScript functions too, to convert to/from ctime/datetime.

  • Mark Lin posted a perl script that does this type of thing back in 2003 - you may be able to search and find it...

     

    I can paste it here of you need it.

    Message Edited by David McMullin on 10-20-2008 09:02 AM