]> git.sur5r.net Git - bacula/bacula/blob - bacula/scripts/tapealert
Big backport from Enterprise
[bacula/bacula] / bacula / scripts / tapealert
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
24 tapeinfo=`which tapeinfo`
25
26 if [ x${tapeinfo} = x ] ; then
27    echo "tapeinfo program not found, but is required."
28    exit 1
29 fi
30 if [ x$1 = x ] ; then
31    echo "First argument missing. Must be device control name."
32    exit 1
33 fi
34
35
36 if [ x$DEBUG = x ] ; then
37 $tapeinfo -f $1 |grep "^TapeAlert" - |cut -b1-13
38 exit $?
39
40 else
41
42 # For testing only
43 cat <<EOF |grep "^TapeAlert" - |cut -b1-13
44 Product Type: Tape Drive
45 Vendor ID: 'IBM     '
46 Product ID: 'ULTRIUM-TD6     '
47 Revision: 'G350'
48 Attached Changer API: No
49 SerialNumber: 'F3A2930090'
50 TapeAlert[3]:    Hard Error: Uncorrectable read/write error.
51 TapeAlert[5]:  Read Failure: Tape faulty or tape drive broken.
52 TapeAlert[39]: Undefined.
53 MinBlock: 1
54 MaxBlock: 8388608
55 SCSI ID: 9
56 SCSI LUN: 0
57 Ready: yes
58 BufferedMode: yes
59 Medium Type: 0x58
60 Density Code: 0x58
61 BlockSize: 0
62 DataCompEnabled: yes
63 DataCompCapable: yes
64 DataDeCompEnabled: yes
65 CompType: 0xff
66 DeCompType: 0xff 
67 EOF
68 fi