That's essentially the same things I had to do, the timeout and the changing of
the wording returned from mtx.  The only other thing I had to change was the 
case test at line that read:

    [$firstslot-$lastslot])
          load=$1
          ;;

Because of the wording of the [test]), the highest slot number you can have
would be 9.  Since I have 30, I had to change it to the below:

   $[${whichslot}])

       if [ $whichslot -gt $lastslot ] || [ $whichslot -lt $firstslot ]; then
           echo "0 Slot $whichslot is out of range ($firstslot - $lastslot)"
           exit 1
       else
           loadslot=$whichslot
       fi
       ;;


This was because if your $lastslot > 9, the test doesn't work right.  For me,
$lastslot is 30, so the test was saying " [1-30]) which is "1-3 _or_ 0" in 
shell pattern matching.  It took me forever to notice this, and I pulled some
hair out wondering why I couldn't load a tape higher than slot 3.

Thanks...

On Thu, 01 Feb 2001, Doug Munsinger wrote:

> Jason -
> 
> having just been through "changer hell" I'm copying some mail I just sent 
> to Joe Rhett re: chg-zd-mtx and barcodes -
> MAYBE it will help resolve what you are going through now.
> 
> I fought with chg-scsi and chg-zd-mtx for about a week before dropping back 
> and getting chg-manual to fully work first.
> 
> Here's what I just finished:
> Hope this helps.
> 
> --doug
> 
> ___________________________________________________________________________
> 
> 
> Joe -
> 
> I downloaded the improved mtx script from the link you gave in this post -
> MUCH THANKS as the site also gave specific instructions for placing
> at <amanda-src>/client-src/chg-zd-mtx.sh.in
> and then run configure.  This came very close to working as is.
> 
> The timing worked well as I was already re-installing 2.4.2p1 upgrades 
> anyway...
> 
> I found two flaws in the code for my specific tape drive and changer.
> I have an Ecrix VXA autopak library with a single Ecrix VXA tape unit 
> installed - with a barcode reader.
> 
> I managed to get chg-manual running consistently and getting good backups 
> first, which let me know that the tape drive and amanda were doing well, 
> before attempting for a second time to get the changer to cooperate.
> I also installed mtx 1.2.10 and tested and verified this would work... So 
> at least I could get an e-mail that the tape needed changing and then log 
> in and accomplish that from home...
> 
> What I changed to make the chg-zd-mtx script work was to add a TIMEOUT 
> variable to use in a sleep command in loadslot as follows:
>                  # Now rewind and check
>                  echo "         -> rewind $loadslot" >> $DBGFILE
>                  echo "         -> sleeping TIMEOUT: $TIMEOUT 
> seconds..." >> $DBGFILE
>                  sleep $TIMEOUT
>                  echo "         -> rewind..." >> $DBGFILE
>                  $MT $MTF $tape rewind
>                  echo "$loadslot" > $slotfile
>                  echo "$loadslot $tape"
>                  exit 0
> 
> Otherwise I would consistently get
> "/dev/nst0: Input/output error"
> on any rewind or tape change by the script
> 
> This MOSTLY allowed the script to work, except -
> I have a barcode reader.
> The result of an mtx status command with a barcode reader is different than 
> without - at least when the tapes have barcodes -
> here's what the mtx -f /dev/sg1 status result looks like (with barcode)
> 
> Data Transfer Element 0:Full (Storage Element 11 Loaded):VolumeTag = 000009
>        Storage Element 1:Full :VolumeTag=000000
>        Storage Element 2:Full :VolumeTag=000001
>        Storage Element 3:Full :VolumeTag=000002
>        Storage Element 4:Full :VolumeTag=000003
>        Storage Element 5:Full
>        Storage Element 6:Full
>        Storage Element 7:Full
>        Storage Element 8:Full
>        Storage Element 9:Full
>        Storage Element 10:Full
>        Storage Element 11:Empty
>        Storage Element 12:Full
>        Storage Element 13:Full
>        Storage Element 14:Full
>        Storage Element 15:Full
> 
> which caused the sed command to give back:
> [amanda@ford amanda]$ mtx -f /dev/sg1 status | sed -n 's/Data Transfer 
> Element 0:Empty/-1/p;s/Data Transfer Element 0:Full (Storage Element \(.\) 
> Loaded)/\1/p'
> 1:VolumeTag = 000000
> which won't work...
> 
> here's the change:
> readstatus() {
>          EMP_FULL=`$MTX status | grep "Data Transfer Element" | awk '{ 
> print $4 }' | awk -F: '{print $2 }'`
>          if [ $EMP_FULL = "Empty" ]; then
>                  usedslot="-1"
>          fi
>          if [ $EMP_FULL = "Full" ]; then
>                  usedslot=`$MTX status | grep "Data Transfer Element" | awk 
> '{ print $7 }'`
>          fi
> ........
> 
> I'll include the full script below this.
> 
> I thought this might come in handy and might also be something you would 
> want to include in the upkeep of chg-zd-mtx.
> 
> --doug
> 
> Doug Munsinger
> 
> egenera, Inc.
> [EMAIL PROTECTED]
> 563 Main Street, Bolton, MA  01740
> Tel: 508-786-9444 ext. 2612
> OR 508-481-5493
> fax: 978 779-9730
> 
> 
> 
> 
> 
> At 03:54 PM 1/31/2001 -0800, Joe Rhett wrote:
> >Are you using the latest MTX version?
> >
> >Is the problem mtx itself? (Can you run "mtx load x", "mtx unload x" etc?
> >
> >Or is the problem with the changer script? Are you using the latest
> >version? You can get it at
> >         http://www.noc.isite.net/?Projects
> >
> >On Wed, Jan 31, 2001 at 07:32:44PM -0000, [EMAIL PROTECTED] 
> >wrote:
> > > I'm new to amanda and really can use some help installing a new
> > > changer. The new unit is a Overland Minilibrary (15-slot) with 1
> > > DLT-7000 drive. Our old unit is working fine but our filesystems have
> > > grown a lot. The new unit is a model 7115.
> > >
> > > The problem appears to be my mtx configuration. Any help is greatly
> > > appreciated!!!
> > >
> > > Sam Lauro
> >
> >--
> >Joe Rhett                                         Chief Technology Officer
> >[EMAIL PROTECTED]                                      ISite Services, Inc.
> >
> >PGP keys and contact information:          http://www.noc.isite.net/Staff/
> 
> 
> Full revised chg-zd-mtx script:
> 
> #!/bin/sh
> #
> # Exit Status:
> # 0 Alles Ok
> # 1 Illegal Request
> # 2 Fatal Error
> #
> # Contributed by Eric DOUTRELEAU <[EMAIL PROTECTED]>
> # This is supposed to work with Zubkoff/Dandelion version of mtx
> #
> # Modified by Joe Rhett <[EMAIL PROTECTED]>
> # to work with MTX 1.2.9 by Eric Lee Green http://mtx.sourceforge.net
> #
> # modified 010201 by doug munsinger ([EMAIL PROTECTED]) to
> #       1) add timeout for loadslot routine at rewind command to
> #               remove "/dev/nst0: Input/output error" see TIMEOUT below to set
> #       2) re-write the readstatus "sed" command as awks instead to parse 
> correctly even
> #               when a barcode reader is present
> 
> # You may need to customize these things
> 
> #timeout variable - if you are getting something like "/dev/nst0: 
> Input/output error"
> #       your tape drive may need this - mine was an Ecrix VXA and this made 
> the rewind
> #       commands in the loadslot routine actually function
> TIMEOUT=30
> 
> MT=/bin/mt
> MTF=-f
> MTX=/usr/local/bin/mtx
> firstslot=1
> lastslot=14                     # Don't forget to leave out the cleaning tape.
> cleanslot=15                    # Which slot contains your cleaning tape?
> 
> # Does your tape driver require a 'mt offline' before mtx unload?
> OFFLINE_BEFORE_UNLOAD=0
> 
> # Do you want to clean the drive after a certain number of accesses?
> # NOTE - This is unreliable, since 'accesses' aren't 'uses', and we
> #        have no reliable way to count this. A single amcheck could
> #        generate as many accesses as slots you have, plus 1.
> # ALSO NOTE - many modern tape loaders handle this automatically.
> #
> AUTOCLEAN=0                             # Set to '1' or greater to enable
> autocleancount=99
> # No user-level customized required beyond this point.
> 
> # Paths
> prefix=/usr/local
> exec_prefix=${prefix}
> sbindir=${exec_prefix}/sbin
> libexecdir=${exec_prefix}/libexec
> 
> # try to hit all the possibilities here
> PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb:/usr/local/bin
> export PATH
> 
> if [ -d "/tmp/amanda" ]; then
>          DBGFILE=/tmp/amanda/chg-egen-mtx.debug
> else
>          DBGFILE=/tmp/chg-egen-mtx.debug
> fi
> 
> USE_VERSION_SUFFIXES="no"
> if test "$USE_VERSION_SUFFIXES" = "yes"; then
>          SUF="-2.4.2p1"
> else
>          SUF=
> fi
> 
> myname=$0
> tape=`amgetconf$SUF tapedev`
> TAPE=`amgetconf$SUF changerdev`; export TAPE # for mtx command
> if [ "$tape" = "/dev/null" -o "$TAPE" = "/dev/null" ]; then
>          echo "Both tapedev and changerdev must be specified in config file";
>          exit 2;
> fi
> 
> changerfile=`amgetconf$SUF changerfile`
> 
> cleanfile=$changerfile-clean
> accessfile=$changerfile-access
> slotfile=$changerfile-slot
> [ ! -f $cleanfile ] && echo 0 > $cleanfile
> [ ! -f $accessfile ] && echo 0 > $accessfile
> [ ! -f $slotfile ] && echo 0 > $slotfile
> cleancount=`cat $cleanfile`
> accesscount=`cat $accessfile`
> 
> # Routines start here
> readstatus() {
>          EMP_FULL=`$MTX status | grep "Data Transfer Element" | awk '{ 
> print $4 }' | awk -F: '{print $2 }'`
>          if [ $EMP_FULL = "Empty" ]; then
>                  usedslot="-1"
>          fi
>          if [ $EMP_FULL = "Full" ]; then
>                  usedslot=`$MTX status | grep "Data Transfer Element" | awk 
> '{ print $7 }'`
>          fi
> #       usedslot=`$MTX status |
> #               sed -n 's/Data Transfer Element 0:Empty/-1/p;s/Data 
> Transfer Element 0:Full (Storage Element \(.\) Loaded)/\1/p'`
> #
> #       if [ "$usedslot" -eq "-1" ]; then
> #               echo '-1' > $slotfile
> #       fi
>          echo "STATUS -> currently loaded slot = $usedslot" >> $DBGFILE
> }
> 
> 
> eject() {
>          readstatus
>          echo "EJECT -> ejecting tape from slot $usedslot" >> $DBGFILE
>          if [ $usedslot -gt 0 ]; then
>                  if [ $OFFLINE_BEFORE_UNLOAD -gt 0 ]; then
>                          $MT $MTF $tape offline
>                  fi
>                  $MTX unload $usedslot 2>/dev/null
>                  echo "0 $tape"
>                  exit 0
>          else
>                  echo "0 Drive was not loaded"
>                  exit 1
>          fi
> }
> 
> reset() {
>          $myname -eject >/dev/null
>          echo "RESET -> loading tape from slot 1" >> $DBGFILE
>          result=`$MTX load 1 2>&1`
>          if [ $? -eq 0 ]; then
>                  echo "1 $tape"
>                  exit 0
>          else
>                  echo "1 $result"
>                  exit 1
>          fi
> }
> 
> loadslot() {
>          readstatus
> 
>          whichslot=$1
>          echo "LOADSLOT -> load tape from slot $whichslot" >> $DBGFILE
>          case $whichslot in
>                  current)
>                          if [ $usedslot -lt 0 ]; then
>                                  loadslot=$firstslot
>                          else
>                                  echo "$usedslot $tape"
>                                  exit 0
>                          fi
>                          ;;
>                  next|advance)
>                          if [ $usedslot -lt 0 ]; then
>                                  loadslot=$firstslot
>                          else
>                                  loadslot=`expr $usedslot + 1`
>                                  if [ $loadslot -gt $lastslot ]; then
>                                          loadslot=$firstslot
>                                  fi
>                          fi
>                          ;;
>                  prev)
>                          loadslot=`expr $usedslot - 1`
>                          if [ $loadslot -lt $firstslot ]; then
>                                  loadslot=$lastslot
>                          fi
>                          ;;
>                  first)
>                          loadslot=$firstslot
>                          ;;
>                  last)
>                          loadslot=$lastslot
>                          ;;
>                  [${firstslot}-${lastslot}])
>                          loadslot=$1
>                          ;;
>                  clean)
>                          loadslot=$cleanslot
>                          ;;
>                  *)
>                          echo "0 illegal request"
>                          exit 1
>                          ;;
>          esac
> 
>          # Is this already the current slot?
>          if [ $loadslot = $usedslot ]; then
>                  echo "$usedslot $tape"
>                  exit 0
>          fi
> 
>          # Is this a cleaning request?
>          if [ $loadslot = $cleanslot ]; then
>                  expr $cleancount + 1 > $cleanfile
>                  echo 0 > $accessfile
>          else
>                  expr $accesscount + 1 > $accessfile
>                  if [ $AUTOCLEAN -gt 0  -a  $accesscount -gt 
> $autocleancount ]; then
>                          $myname -slot clean >/dev/null
> 
>                          # Slot $cleanslot might contain an ordinary tape 
> rather than a cleaning
>                          # tape. A cleaning tape *MIGHT* auto-eject; an 
> ordinary tape does not.
>                          # We therefore have to read the status again to 
> check what actually happened.
>                          readstatus
>                  fi
>          fi
> 
>          # Unload any previous tape
>          if [ $usedslot -ne "-1" ]; then
>                  echo "         -> unload $usedslot" >> $DBGFILE
>                  if [ $OFFLINE_BEFORE_UNLOAD -gt 0 ]; then
>                          $MT $MTF $tape offline
>                  fi
>                  result=`$MTX unload $usedslot 2>&1`
>                  status=$?
>                  echo "         -> status $status, result '$result'" >> 
> $DBGFILE
>                  if [ $status -ne 0 ]; then
>                          echo "$loadslot $result"
>                          exit 2
>                  fi
>          fi
> 
>          # Load the tape, finally!
>          echo "         -> loading tape from slot $loadslot" >> $DBGFILE
>          result=`$MTX load $loadslot 2>&1`
>          status=$?
>          echo "         -> status $status, result '$result'" >> $DBGFILE
> 
>          # If there is an error, abort unless the slot is simply empty
>          if [ $status -ne 0 ]; then
>                  empty=`echo $result | grep "is Empty"`
>                  if [ -z "$empty" ]; then
>                          echo "$loadslot $result"
>                          exit 2
>                  else
>                          loadslot next
>                  fi
>          else
>                  # Don't assume the drive is ready until we stop getting 
> tape offline
>                  readyError="offline"
>                  while [ -n "$readyError" ]; do
>                          readyStatus=`$MT $MTF $tape status 2>&1`
>                          echo "         -> readyStatus = $readyStatus" >> 
> $DBGFILE
>                          readyError=`echo $readyStatus | grep "offline"`
>                  done
> 
>                  # Now rewind and check
>                  echo "         -> rewind $loadslot" >> $DBGFILE
>                  echo "         -> sleeping TIMEOUT: $TIMEOUT 
> seconds..." >> $DBGFILE
>                  sleep $TIMEOUT
>                  echo "         -> rewind..." >> $DBGFILE
>                  $MT $MTF $tape rewind
>                  echo "$loadslot" > $slotfile
>                  echo "$loadslot $tape"
>                  exit 0
>          fi
> }
> 
> info() {
>          readstatus
>          echo "INFO -> current slot $usedslot, last slot $lastslot, can go 
> backwards 1" >> $DBGFILE
>          if [ $usedslot -lt 0 ]; then
>                  echo "0 $lastslot 1"
>          else
>                  echo "$usedslot $lastslot 1"
>          fi
>          exit 0
> }
> 
> # Program invocation begins here
> echo "\n`date` Invoked with args '$@'" >> $DBGFILE
> while [ $# -ge 1 ];do
>          case $1 in
>                  -slot)
>                          shift
>                          loadslot $*
>                          ;;
>                  -info)
>                          shift
>                          info
>                          ;;
>                  -reset)
>                          shift
>                          reset
>                          ;;
>                  -eject)
>                          shift
>                          eject
>                          ;;
>                  *)
>                          echo "Unknown option $1"
>                          exit 2
>                          ;;
>          esac
> done
> 
> 
> 
> 
> 
> 
> At 04:15 PM 2/1/2001 -0500, Jason Hollinden wrote:
> >After several days of searching, reading, and cussing, I am posting my woes
> >in the hopes someone has some insight to using barcodes.
> >
> >Just for background, I have a Dell Poweredge-2400 with RedHat 6.2, running
> >amanda-2.4.2p1.  My tape library is an ADIC Scalar 100 hanging off a 
> >dedicated
> >Adaptec 2944UW.  All my tapes have been labeled using amlabel.  I only have
> >8 tapes (and a cleaning tape resting in the last slot), as you will see in the
> >attached configs, as it takes way too long to index 30 tapes.
> >
> >That said, I'm having trouble with several different paths.  I have about 60%
> >sucess with chg-scsi, and 90% success with chg-zd-mtx (using mtx-1.2.10-1).
> >
> >chg-scsi problems:
> >
> >Using this glue script, I can do all of the "tape movement only" functions,
> >such as amtape's eject, reset, and slot <command or #>.  Where it fails is
> >any activity where it has to load tapes and 'quickly' read from them, such as
> >amtape's update, label, and show commands.  The problem is that amtape is not
> >giving my library enough time to load up the tape, despite whatever the sleep
> >setting in my chg-scsi.conf file is set to.  I've pretty much confirmed this
> >with the fact that I can run the same command again after the tape is
> >completely loaded, and the amlabel shows up fine.  Here's an example:
> >
> >### Ran with no tape in the drive
> >
> >bash-2.03$ /usr/sbin/amtape Reubens current
> >amtape: scanning current slot in tape-changer rack:
> >slot 0: rewinding tape: Input/output error
> >
> >### This loads a tape from slot 0, but doesn't wait for it to finish winding
> >### Next is the exact same command, after it's done winding
> >
> >bash-2.03$ /usr/sbin/amtape Reubens current
> >amtape: scanning current slot in tape-changer rack:
> >slot 0: date X        label Reubens01
> >
> >###
> >
> >Because of this, I can't get the bardcodes from the tapes to do much of
> >anything.  Chg-scsi will populate my barcode file with just the tape loaded,
> >but when I need to index all the tapes with 'amtape Reubens update' it has no
> >data, since it doesn't sleep until the tape is ready.  My sleep statement has
> >been everything from 120 - 1200 sec. but I don't believe that is what it is
> >supposed to do, anyways.
> >
> >chg-zd-mtx problems:
> >
> >Actually, I have very few problems with this, except that there is no barcode
> >work done with it.  I had to modify it to work with > 9 slots, and can post
> >that if someone wants.  The main problem is no barcode support.  The 
> >version of
> >mtx I have reports the barcodes, so modifying this glue script some more 
> >to use
> >them shouldn't be too much trouble.
> >
> >This is where I finally start getting to my point...
> >
> >How does Amanda utilize barcodes?  Are there any Amanda commands that directly
> >mess with barcodes, or is the only thing that has anything to do with them the
> >changer glue script, and it just so happens that only chg-scsi looks at them
> >right now?  If it's the second, I'm about a few days away from writing a
> >chg-zd-mtx variant with an "internal" barcode matching system.
> >
> >I'm attaching about everything I've seen on this group as a usable file for
> >cases like this, and if there is anything I've missed, please tell me.  If,
> >after looking through my stuff, it looks like a simple fix for chg-scsi on my
> >part for it to work correctly, that's great.
> >
> >A quick list of attachments:
> >
> >- amanda.conf
> >- ADIC.conf   (chg-scsi script)
> >- status-all.txt   (running chg-scsi -status all)
> >
> ># below 3 were done with no tape in the drive, and 8 in the slots
> >- chg-scsi.debug.update   (generated after running 'amtape Reubens update')
> >- amtape.debug.update   (generated after running 'amtape Reubens update')
> >- update.txt   (what 'amtape Reubens update' spat to the screen)
> >
> ># outputs from 'amtape Reubens slot current' with tape in drive
> >- chg-scsi.debug.current
> >- amtape.debug.current
> >- current.txt   (paste from the screen)
> >
> >--
> >    Jason Hollinden
> >
> >    SMG Systems Admin
> 
> 
> 
> 
> 
> Doug Munsinger
> 
> egenera, Inc.
> [EMAIL PROTECTED]
> 563 Main Street, Bolton, MA  01740
> Tel: 508-786-9444 ext. 2612
> OR 508-481-5493
> fax: 978 779-9730
--
   Jason Hollinden

   SMG Systems Admin

Reply via email to