1#!/bin/sh 2# 3# Copyright (C) 2000-2016 Kern Sibbald 4# License: BSD 2-Clause; see file LICENSE-FOSS 5# 6# Bacula interface to tapeinfo to get tape alerts 7# 8# tapealert %l (control device name) 9# 10# Note: you must have in your SD Device resource: 11# Alert Command = /full-path/tapealert %l 12# Control Device = /dev/sg0n (where this is the scsi control 13# device for the device you are using). 14# 15 16# Note: to test 17# 1. uncomment out the DEBUG=1 line below 18# 2. Possibly remove or add TapeAlert[nn]: that you want to test. 19# Note, the message following the : is not used. 20# 3. Run Bacula 21# 22#DEBUG=1 23 24tapeinfo=`which tapeinfo` 25 26if [ x${tapeinfo} = x ] ; then 27 echo "tapeinfo program not found, but is required." 28 exit 1 29fi 30if [ x$1 = x ] ; then 31 echo "First argument missing. Must be device control name." 32 exit 1 33fi 34 35 36if [ x$DEBUG = x ] ; then 37$tapeinfo -f $1 |grep "^TapeAlert" - |cut -b1-13 38exit $? 39 40else 41 42# For testing only 43cat <<EOF |grep "^TapeAlert" - |cut -b1-13 44Product Type: Tape Drive 45Vendor ID: 'IBM ' 46Product ID: 'ULTRIUM-TD6 ' 47Revision: 'G350' 48Attached Changer API: No 49SerialNumber: 'F3A2930090' 50TapeAlert[3]: Hard Error: Uncorrectable read/write error. 51TapeAlert[5]: Read Failure: Tape faulty or tape drive broken. 52TapeAlert[39]: Undefined. 53MinBlock: 1 54MaxBlock: 8388608 55SCSI ID: 9 56SCSI LUN: 0 57Ready: yes 58BufferedMode: yes 59Medium Type: 0x58 60Density Code: 0x58 61BlockSize: 0 62DataCompEnabled: yes 63DataCompCapable: yes 64DataDeCompEnabled: yes 65CompType: 0xff 66DeCompType: 0xff 67EOF 68fi 69