ITA translation
This commit is contained in:
parent
726f00104b
commit
c0e6c15da4
22
optimizer.sh
22
optimizer.sh
|
@ -2,7 +2,7 @@
|
|||
###
|
||||
### Usage: ./optimizer.sh </dev/sgX> <parallelism>
|
||||
###
|
||||
### -h | --help Shows this message
|
||||
### -h | --help Shows this message
|
||||
###
|
||||
### optimizer.sh
|
||||
### Necessary parameters:
|
||||
|
@ -10,10 +10,12 @@
|
|||
### - parallelism
|
||||
###
|
||||
### The script checks the parallelism with the available drives of the library/partition, then
|
||||
### proceeds with loading *all* the tapes in the slots. Mailboxes are ignored.
|
||||
### proceeds with loading *all* the tapes found in the slots. Mailboxes are ignored.
|
||||
### It launches several child processes. The `timeout` command tries to unload the drives,
|
||||
### it succeeds when the the tape optimization is done.
|
||||
###
|
||||
### Kill switch to stop the running processes: `killall optimizer.sh`
|
||||
###
|
||||
|
||||
|
||||
help() {
|
||||
|
@ -36,12 +38,12 @@ alive() {
|
|||
echo "${4}" > "${TMP}/.drive${3}.lock"
|
||||
local PID_ALIVE='1'
|
||||
local WAIT=$((3600 + $RANDOM % 7200)) # from 1 to 2 hours
|
||||
local TIMEOUT="600" #10 minuti wait before dismounting the tape
|
||||
local TIMEOUT="600" # 10 minutes wait before dismounting the tape
|
||||
while [ $PID_ALIVE -eq 1 ]; do
|
||||
log "ALIVE [$$] - Waiting ${WAIT} secondi..."
|
||||
sleep "${WAIT}"
|
||||
log "ALIVE [$$] - Trying to unload drive ${3} into slot ${2} (Timeout: ${TIMEOUT} seconds)..."
|
||||
timeout "${TIMEOUT}" mtx -f "${1}" unload "${2}" "${3}" #kill after ${TIMEOUT} seconds
|
||||
timeout "${TIMEOUT}" mtx -f "${1}" unload "${2}" "${3}" # Kill after ${TIMEOUT} seconds
|
||||
if [[ $(echo $?) == '0' ]]; then
|
||||
log "ALIVE [$$] - OK. Drive ${3} unloaded."
|
||||
grep -q "$4;drive$3;WIP" "${PROCESSED_BARCODES}" # Check if barcode is WIP
|
||||
|
@ -52,11 +54,11 @@ alive() {
|
|||
touch "${TMP}/.drive${3}.ready"
|
||||
log "ALIVE [$$] - Drive ${3} newly available. Exit."
|
||||
local PID_ALIVE='0'
|
||||
return 0 # Fine Alive
|
||||
return 0 # End Alive
|
||||
else
|
||||
log "ALIVE [$$] - ERROR. Can't find the barcode among the WIP. Exit."
|
||||
return 1
|
||||
fi # Barcode processato --> OK
|
||||
fi # Barcode processed --> OK
|
||||
elif [ -f "${TMP}/.drive${3}.lock" ]; then # Drive in use
|
||||
log "ALIVE [$$] - Unmount drive ${3} failed, still in use (file .lock). Checking the content."
|
||||
grep -q "${4}" "${TMP}/.drive${3}.lock"
|
||||
|
@ -134,13 +136,13 @@ while [ $COUNT -le $(cat ${SLOTS_FULL} | wc -l) ]; do
|
|||
if [[ "${RUNNING}" -lt "${PARALLELISM}" ]]; then
|
||||
SLOT=$(sed "${COUNT}q;d" ${SLOTS_FULL} | awk '{print $3;}' | cut -d ':' -f 1)
|
||||
BARCODE=$(sed "${COUNT}q;d" ${SLOTS_FULL} | awk '{print $4;}' | cut -d '=' -f 2)
|
||||
grep -q "${SLOT}" "${PROCESSED_SLOTS}" #Controllo che lo slot non sia stato già processato
|
||||
grep -q "${SLOT}" "${PROCESSED_SLOTS}" # Check if slot is aready processed
|
||||
if [[ $(echo $?) == '0' ]]; then
|
||||
echo "Slot ${SLOT} already processed."
|
||||
((COUNT++))
|
||||
continue
|
||||
fi
|
||||
grep -q "${BARCODE};OK" "${PROCESSED_BARCODES}" #Controllo che il barcode non sia già stato processato
|
||||
grep -q "${BARCODE};OK" "${PROCESSED_BARCODES}" # Check if barcode is already processed
|
||||
if [[ $(echo $?) == '0' ]]; then
|
||||
echo "Barcode ${BARCODE} already processed. Skip."
|
||||
((COUNT++))
|
||||
|
@ -148,13 +150,13 @@ while [ $COUNT -le $(cat ${SLOTS_FULL} | wc -l) ]; do
|
|||
fi
|
||||
log "### SLOT ${SLOT} - BARCODE ${BARCODE}"
|
||||
for (( i = 0 ; i < ${PARALLELISM} ; i++ )); do # Look for an available drive
|
||||
if [ -f "${TMP}/.drive${i}.ready" ]; then # Look for "ready" file
|
||||
if [ -f "${TMP}/.drive${i}.ready" ]; then # Look for ".ready" file
|
||||
DRIVE=${i}
|
||||
mv "${TMP}/.drive${DRIVE}.ready" "${TMP}/.drive${DRIVE}.lock"
|
||||
break
|
||||
fi
|
||||
done
|
||||
log "Load slot ${SLOT} into drive ${DRIVE}."
|
||||
log "Loading slot ${SLOT} into drive ${DRIVE}."
|
||||
mtx -f "${LIB_SG}" load "${SLOT}" "${DRIVE}"
|
||||
echo "${BARCODE};drive${DRIVE};WIP" >> "${PROCESSED_BARCODES}" # Barcode WIP
|
||||
echo ${SLOT} >> "${PROCESSED_SLOTS}"
|
||||
|
|
Loading…
Reference in New Issue