Jon,
Thanks for pointing me to the mtx, and the mtx shell-script. Unfortunately,
mtx would not compile on my OS (TRU64 5.1A). The website claimed that it
could, but I suspect that it only holds true for earlier versions 4.0x and
below. 5.0x & above restructured the /dev directory into softlinks to
/devices, and such.
So I discovered a new util called mcutil. Once I configure /etc/mcicap, I
was able to use this binary to control the tape changer. So I took the mtx
script, and rewrote it so that it would work with the mcutil program.
I tested it against amtape, and tweaked the output, so that amtape now
functions correctly (oh boy was that fun!). So I'm including the script as
an attachment and as embedded for anyone who faces a similar situation in
the future.
-Rob
---- snip ----
#!/bin/sh
#
# Exit Status:
# 0 Alles Ok
# 1 Illegal Request
# 2 Fatal Error
#
#
# Set Path so that it includes Amanda binaries, and access to tapechanger &
drive programs
#
prefix=/usr/local/amanda
sbindir=${prefix}/sbin
PATH=$sbindir:${prefix}/libexec:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb:/usr/
local/bin
export PATH
#
# Check that the logging directory exists
#
if [ -d "/tmp/amanda" ]; then
logfile=/tmp/amanda/changer.debug
else
logfile=/dev/null
fi
# Several Variables that get defined for the script
tape=/dev/ntape/tape2 # Tape Drive device
MCUTIL=/sbin/mcutil # Tape Changer command
firstslot=0 # First changer slot #
lastslot=6 # Last changer slot #
cleanslot=7 # slot # for cleaning tape
myname=$0
currentslot=${prefix}/configs/changer/currentslot
if [ ! -f $currentslot ] || [ `cat $currentslot` -lt $firstslot ];then
readstatus
echo $used > $currentslot
fi
current=`cat $currentslot`
# Start logging to $logfile
echo "\n\n==== `date` ====" >> $logfile
echo "Command Line -> $myname $@" >> $logfile
use_cleaning=0
if [ $use_cleaning -eq 1 ]; then
cleanfile=${prefix}/configs/changer/times_cleaned
lastfile=${prefix}/configs/changer/last_cleaned
[ ! -f $cleanfile ] && echo 0 > $cleanfile
[ ! -f $lastfile ] && echo 0,0 > $lastfile
cleaned=`cat $cleanfile`
cleansleep=300
#
# Check to see when tape drive was last cleaned
# output warning message if it's been too long
# Currently, if it's been more than 45days, then
# an error message is displayed everytime the
# script is called, until the clean parameter
# is run
#
lastcleaned=`cut -d, -f1 $lastfile`
yearcleaned=`cut -d, -f2 $lastfile`
curday=`date +%j`
curyear=`date +%Y`
if [ `expr $curday - $lastcleaned` -lt 0 ];then
diffday=`expr $curday - $lastcleaned + 365`
diffyear=`expr $curyear - $yearcleaned - 1`
else
diffday=`expr $curday - $lastcleaned`
diffyear=`expr $curyear - $yearcleaned`
fi
if [ $diffday -gt 45 ] || [ $diffyear -ge 1 ];then
if [ $diffyear -ge 1 ];then
echo "Warning, it's been $diffyear year(s) & $diffday days since
you last cleaned the tape drive!"
else
echo "Warning, it's been $diffday days since you last cleaned the
tape drive!"
fi
fi
fi
#
# Read if there is a tape in the tape drive
# If so, determine what slot is the tape from
#
readstatus() {
# To determine what slot is currently used, I query the drive itself.
# $MCUTIL -e drive
# With a Tape : drive 0 [full,access,source=256] 16
# Without Tape: drive 0 [empty,access] 16
#
# each slot has a source number assigned to it. I subtract slot 0's source
num from the output.
# If the number is less than 0, no tape is in the drive, else it outputs the
current slot number.
#
# slot 0 [full,access,source=256] 256
# slot 1 [full,access,source=257] 257
# slot 2 [full,access,source=258] 258
# slot 3 [full,access,source=259] 259
#
echo -n "querying tape drive....." >> $logfile
used=`expr \`$MCUTIL -e drive | tr = \] | cut -d\] -f2\` - 256`
echo " Done" >> $logfile
# Give changer a chance to reset itself
sleep 3
}
#
# If tape is in the drive, eject it
#
eject() {
echo "tape drive eject was called" >> $logfile
readstatus
if [ $used -ge $firstslot ];then
$MCUTIL -m drive slot:$used
code=$?
else
code=1
fi
if [ $code -eq 0 ];then
answer="Cartridge $used successfully ejected from $tape"
echo "Exit($code): $answer" >> $logfile
echo $current $tape #For amtape output
return $code
elif [ $code -eq 1 ];then
answer="No Cartridge in Tape Drive"
echo "Exit($code): $answer" >> $logfile
echo $current $answer #For amtape output
exit $code
else
answer="Tape abnormally failed"
echo "Exit($code): $answer" >> $logfile
echo $current $answer #For amtape output
exit $code
fi
}
#
# reset tape drive to a current state.
# This involves ejecting the current tape (if occupied)
# and inserting the tape in $firstslot
#
reset() {
echo "tape drive reset was called" >> $logfile
readstatus
if [ $used -ge $firstslot ];then
eject
fi
res=`$MCUTIL -m slot:$firstslot drive`
code=$?
if [ $code -eq 0 ];then
echo $firstslot > $currentslot
answer="$firstslot - Tape drive was successfully reset"
elif [ $code -eq 1 ];then
answer="$firstslot - Tape drive reset failed\nCommand -> $res"
else
code=2
answer="$firstlot - Tape abnormally failed -> $res"
fi
echo "Exit($code): slot $answer" >> $logfile
echo $firstslot #For amtape output
exit $code
}
#
# Load a specific cartridge into the changer
#
loadslot() {
echo "loadslot was called" >> $logfile
readstatus
whichslot=$1
case $whichslot in
current)
if [ $current -ge $firstslot ];then
load=$current
else
load=$used
fi
movetape
;;
next|advance)
[ $used -lt $firstslot ] && used=$current
load=`expr $used + 1`
[ $load -gt $lastslot ] && load=$firstslot
if [ $whichslot = advance ];then
echo $load > $currentslot
code=0
answer="current slot has been updated"
echo "Exit($code): $answer" >> $logfile
echo $load $code
exit $code
else
movetape
fi
;;
prev)
[ $used -lt $firstslot ] && used=$current
load=`expr $used - 1`
[ $load -lt $firstslot ] && load=$lastslot
movetape
;;
first)
load=$firstslot
movetape
;;
last)
load=$lastslot
movetape
;;
[$firstslot-$lastslot])
load=$1
movetape
;;
clean)
if [ use_cleaning -eq 1 ];then
eject
$MCUTIL slot:$cleanslot drive
sleep $cleansleep
echo "$curday,$curyear" > $lastfile
echo `expr $cleaned + 1` > $cleanfile
eject
else
code=1
answer="Cleaning not enabled in config" >> $logfile
echo "Exit($code): $answer" >> $logfile
echo $cleanslot $answer
exit $code
fi
;;
*)
code=1
answer="\"$whichslot\" invalid menu option"
echo "Exit($code): slot $answer" >> $logfile
echo "$answer"
exit $code
;;
esac
}
#
# sub-function that slot calls to actually eject the tape
# & load in the correct slot cartridge
#
movetape() {
current=$load # For amtape output
# If the requested slot is already loaded in the tape drive
if [ $load -eq $used ]; then
code=1
answer="$load is already loaded"
echo "Exit($code): slot $answer" >> $logfile
echo "$answer"
exit $code
elif [ $used -ge $firstslot ];then
eject
else
echo $current $tape # For amtape output
fi
echo "Loading slot $load into Tape drive" >> $logfile
$MCUTIL -m slot:$load drive
code=$?
if [ $code -eq 0 ];then
echo $load > $currentslot
answer="Cartridge $load successfully loaded in Tape drive"
else
answer="Cartridge $load failed to load in Tape drive"
fi
echo "Exit($code): $answer" >> $logfile
exit $code
}
info() {
echo "tape drive info was called" >> $logfile
readstatus
if [ $used -lt 0 ];then
used=0
fi
code=0
answer="$used $lastslot 1"
echo "Exit($code): $answer" >> $logfile
echo "$answer"
exit $code
}
case $1 in
-slot)
shift
loadslot $*
;;
-device)
echo $tape
;;
-info)
shift
info
;;
-reset)
shift
reset
;;
-eject)
shift
eject
;;
--help|-help)
echo "-slot
{current|next|previous|first|last|$firstslot-$lastslot|clean}"
echo " current - show contents of current slot"
echo " next - load tape from next slot"
echo " previous - load tape from previous slot"
echo " first - load tape from first slot"
echo " last - load tape from last slot"
echo " $firstslot - $lastslot - load tape from slot <slot
#>"
echo " clean - Clean the drive"
echo "-device : Show current tape device"
echo "-reset : Reset changer to known state"
echo "-eject : Eject current tape from drive"
echo "-info : Output {current slot | # of slots | can
changer go backwards}"
echo "-help : Display this help"
;;
*)
echo "<usage> $myname -{slot|device|reset|eject|help}"
;;
esac
-- snip ---
-----Original Message-----
From: Jon LaBadie [mailto:jon AT jgcomp DOT com]
Sent: Saturday, April 05, 2003 2:51 PM
To: 'amanda-users AT amanda DOT org'
Subject: Re: Where oh where is chg-scsi?
On Sat, Apr 05, 2003 at 07:44:47AM -0800, Dege, Robert C wrote:
>
> I have a Quantum PowerStor L200 Disk Changer with a Quantum DLT8000 tape
> drive builtin. It is connected to an alpha running TRU64 5.1A.
>
> Now that I have my specs out of the way, lemme explain my problem. This
is
> my first time setting up an amanda server, so I made sure to read the docs
> to the best of my ability. As I built & configured amanda, I decided that
> chg-scsi would be the best choice to interact with the tape changer.
> However, after I finished configuring the device, chg-scsi.conf, and
> amanda.conf, I discover that the chg-scsi binary was never built or
> installed into libexec.
>
> Based on the TapeChanger doc, chg-scsi seemed to be best suited for my
> hardware configuration. But now that it's not there, my next best option
is
> to use the chg-multi.
>
> I was curious why chg-scsi was never built, or if I configured something
> incorrectly. I listed my configure paramters below:
>
This is a guess on my part, chg-scsi in the source dirs is a shell script.
But it needs OS specific C modules to be compiled. I see things like
scsi-solaris.c, scsi-hpux.c, ... but no scsi-tru64.c. Perhaps it has never
been ported to tru64 and thus does not build.
Any reason not to install mtx (sourceforge.net or freshmeat.net) and use
chg-??-mtx?
--
Jon H. LaBadie jon AT jgcomp DOT com
JG Computing
4455 Province Line Road (609) 252-0159
Princeton, NJ 08540-4322 (609) 683-7220 (fax)
chg-mcutil
Description: Binary data
|