Networker

Re: [Networker] Volume location is incorrect

2005-01-26 06:50:36
Subject: Re: [Networker] Volume location is incorrect
From: Conrad Macina <conrad.macina AT PFIZER DOT COM>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Wed, 26 Jan 2005 06:48:55 -0500
Funny you should ask about that. We just encountered a smilar problem. If
you have a LOT of tapes with incorrect locations a script might help. If
it's a frequent issue you might want to run something like this at regular
intervals (e.g., weekly) to alert you to problems.

---------- <snip> ----------
#!/bin/ksh

# This script identifies tapes that mminfo reports as being in the jukebox
# but are not physically present there. It uses mminfo and sjirdtag.

SERVER=`grep -v "^#" /nsr/res/servers | head -1`        ;# NetWorker server
SNODE=`hostname`                        ;# Storage node is this host
JBLIST=/opt/pfizer/bin/jblist.ksh       ;# Script to list jukeboxes
SJIRDTAG=/etc/LGTOuscsi/sjirdtag        ;# Location of sjirdtag
if [ ! -x $SJIRDTAG ] ;then
   # sjirdtag is not in /etc/LGTOuscsi. Must be Legato v7+.
   SJIRDTAG=/usr/sbin/sjirdtag
fi
MMIFIL=/tmp/`basename $0`.mminfo        ;# File for mminfo output
SJIFIL=/tmp/`basename $0`.sjirdtag      ;# File for sjirdtag output

LOPT=0                                  ;# Assume we won't change locations
MAILTO=""                               ;# And won't send an e-mail report
while getopts lm: I
do
  case $I in
    l) LOPT=1                           ;# Change locations of missing tapes
       ;;
    m) MAILTO=$OPTARG                   ;# Who gets mail
       # Start the mail file
       MAILFIL=/tmp/`basename $0`.$$.mail
       echo "mail $MAILTO << !!" > $MAILFIL
       echo "To: $MAILTO" >> $MAILFIL
       echo "Subject: `basename $0` on `hostname` `date +%m/%d/%Y`" >> $MAILFIL
       echo "" >> $MAILFIL
       ;;
   \?) echo ""
       echo "`basename $0` identifies tapes that mminfo reports as being in the"
       echo "jukebox but are not physically present there. Besides mminfo, it"
       echo "uses sjirdtag."
       echo ""
       echo "Usage:   `basename $0` [-l] [-m <mailaddress>]"
       echo ""
       echo "Options:"
       echo "    -l = Change the location of any tapes found to be 'missing'"
       echo "    -m = Send mail to the given address instead of interacting"
       echo "         with the caller. Multiple addresses may be separated by"
       echo "         commas."
       echo ""
       echo "Example: `basename $0` -l -m joe.bloe AT pfizer DOT com"
       echo ""
       exit 1
       ;;
  esac
done

for JB in $($JBLIST -s $SERVER $SNODE | grep -v "ro")
do

  if [ "$SNODE" = "$SERVER" ] ;then
     JBNAME="${JB}"
  else
     JBNAME="rd=${SNODE}:${JB}"
  fi
  JBNAMESC=`echo $JBNAME | sed 's!:!\\\:!g'`    ;# Jukebox name with ":" escaped
  NSRJBFIL=/tmp/`basename $0`.${JB}.nsrjb-Cv
  CTLPORT=`echo "show control port\nprint type:nsr jukebox;name:$JBNAMESC" |
nsradmin -s $SERVER -i - | nawk -F ":" '{print $NF}' | tr -d '";'`

  # echo "SERVER=<$SERVER>, SNODE=<$SNODE>, SJIRDTAG=<$SJIRDTAG>,
JBNAMESC=<$JBNAMESC>, CTLPORT=<$CTLPORT>"

  # Tapes that mminfo thinks are in the jukebox
  if [ -z "$MAILTO" ] ;then
     echo "Obtaining jukebox $JB contents from NetWorker ... \c"
  fi
  mminfo -s $SERVER -r "volume" -q "location=$JBNAME" > $MMIFIL
  MMICT=`wc -l $MMIFIL | awk '{print $1}'`
  if [ -z "$MAILTO" ] ;then
     echo "Done."
     echo "$MMICT Tapes found"
  else
     echo "mminfo found $MMICT Tapes in jukebox $JB" >> $MAILFIL
  fi

  # What's REALLY in the jukebox
  if [ -z "$MAILTO" ] ;then
     echo "Obtaining jukebox $JB contents from library. ... \c"
  fi
  $SJIRDTAG $CTLPORT > $SJIFIL
  SJICT=`grep -c "^[     ]*VolumeTag=<[A-Z][A-Z][0-9][0-9][0-9][0-9] *>"
$SJIFIL`
  if [ -z "$MAILTO" ] ;then
     echo "Done."
     echo "$SJICT Tapes found"
  else
     echo "sjirdtag found $SJICT Tapes in jukebox $JB\n" >> $MAILFIL
  fi

  # Compare
  ANOMALIES=""                          ;# List of anomalies
  N_ANOM=0                              ;# Count of anomalies
  for T in `cat $MMIFIL`
  do
    # VolumeTag=<MP6196                          >
    X=`grep -c "^[       ]*VolumeTag=<$T *>" $SJIFIL`
    if [ $X = 0 ] ;then
       ANOMALIES="$ANOMALIES $T"
       (( N_ANOM += 1 ))
    fi
  done

  if [ $N_ANOM = 0 ] ;then
     echo "Jukebox $JB is clean. No tapes missing.\n" >> $MAILFIL
  else
     echo "$N_ANOM Tapes missing from jukebox $JB:" >> $MAILFIL
     echo $ANOMALIES >> $MAILFIL
     echo "" >> $MAILFIL
     if [ $LOPT != 0 ] ;then
        for T in $ANOMALIES
        do
          mmlocate -s $SERVER -n $T -u ' '
          ST=$?
          if [ $ST = 0 ] ;then
             echo "Location of tape $T changed to blank" >> $MAILFIL
          else
             echo "***** ERROR: Attempt to change location of $T FAILED with
status $ST" >> $MAILFIL
             if [ -z "$MAILTO" ] ;then
                echo "ENTER to continue, Ctrl-C to abort: \c"
                read IT
             # End of test for user interaction
             fi
          # End of test for mmlocate exit status
          fi
       # End of loop through anomalous tapes
       done
     # End of test for L-option (change tape locations)
     fi
  # End of test for existence of anomalies
  fi
# End of main loop through all jukeboxes on this system
done

if [ -n "$MAILTO" ] ;then
   # Put the finishing touches on the report and send it
   echo "" >> $MAILFIL                  ;# An extra blank line
   echo "!!" >> $MAILFIL                ;# End the "here document"
   chmod 777 $MAILFIL                   ;# Make the mail file executable
   $MAILFIL                             ;# Run it to send the mail
   rm $MAILFIL                          ;# Delete it
fi
---------- <snip> ----------

Disclaimer: Not warranted, nor supported, nor guaranteed suitable for any
purpose (although if you print it out on large enough paper it might be
suitable for wrapping fish). It hasn't been fully tested. My cut-and-paste
technique messed up the line breaks; I've tried to fix them but I may have
missed some. Constructive comments ("it might work better if you ...") are
welcome, criticism of my scripting technique ("this is garbage") is not. And
the most powerful disclaimer of all: This script was written in a hurry.

Conrad Macina,
Pfizer, Inc.



On Wed, 26 Jan 2005 11:54:24 +1100, Preston de Guise
<enterprise.backup AT GMAIL DOT COM> wrote:

>Hi Jessica,
>
>> I'm using the following command to determine what types can be relabeled:
>> /usr/sbin/mminfo -a -q 'pool=GERDaily,volrecycle,location=GERLibA' -r
>> 'pool,volume,written,%used,state,location' | sort -k 1,2 | more
>>
>> Unfortunately it's showing that some tapes are in tape library GERLibA but
>> nsrjb -C -j GERLibA does a tape with that label in the library.  How do I
>> correct this so that media accurately reflects what's in the library.
>
>Typically this happens when media is manually pulled from the library,
>as nsrjb is meant to clear the location field during an export
>operation.
>
>To adjust the location field, run the command:
>
>mmlocate -u -n volume Location
>
>e.g.,:
>
>mmlocate -u -n 800841 Shelf
>
>Would adjust volume 800841 so that its location read "Shelf".
>
>Cheers,
>
>-Preston de Guise.
>
>--
>Note: To sign off this list, send a "signoff networker" command via email
>to listserv AT listserv.temple DOT edu or visit the list's Web site at
>http://listserv.temple.edu/archives/networker.html where you can
>also view and post messages to the list. Questions regarding this list
>should be sent to stan AT temple DOT edu
>=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

--
Note: To sign off this list, send a "signoff networker" command via email
to listserv AT listserv.temple DOT edu or visit the list's Web site at
http://listserv.temple.edu/archives/networker.html where you can
also view and post messages to the list. Questions regarding this list
should be sent to stan AT temple DOT edu
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

<Prev in Thread] Current Thread [Next in Thread>