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