1SG_SENDDIAG(8) SG3_UTILS SG_SENDDIAG(8)
2
3
4
6 sg_senddiag - performs a SCSI SEND DIAGNOSTIC command
7
9 sg_senddiag [--doff] [--extdur] [--help] [--hex] [--list] [--pf]
10 [--raw=H,H...] [--raw=-] [--selftest=ST] [--test] [--uoff] [--verbose]
11 [--version] DEVICE
12
13 sg_senddiag [-doff] [-e] [-h] [-H] [-l] [-pf] [-raw=H,H...] [-raw=-]
14 [-s=ST] [-t] [-uoff] [-v] [-V] [-?] DEVICE
15
17 This utility sends a SCSI SEND DIAGNOSTIC command to the DEVICE. It can
18 issue self-tests, find supported diagnostic pages or send arbitrary
19 diagnostic pages.
20
21 When the --list option and a DEVICE are given then the utility sends a
22 SCSI RECEIVE DIAGNOSTIC RESULTS command to fetch the response (i.e.
23 the page numbers of supported diagnostic pages).
24
25 When the --list option is given without a DEVICE then a list of diag‐
26 nostic page names and their numbers, known by this utility, are listed.
27
28 This utility supports two command line syntax-es, the preferred one is
29 shown first in the synopsis and explained in this section. A later sec‐
30 tion on the old command line syntax outlines the second group of
31 options.
32
34 Arguments to long options are mandatory for short options as well.
35
36 -d, --doff
37 set the Device Offline (DevOffL) bit (default is clear). Only
38 significant when --test option is set for the default self-test.
39 When set other operations on any logical units controlled by the
40 this device server (target) may be affected (delayed) while a
41 default self-test is underway.
42
43 -e, --extdur
44 outputs the expected extended self-test duration. The duration
45 is given in seconds (and minutes in parentheses). This figure is
46 obtained from mode page 0xa (i.e. the control mode page).
47
48 -h, --help
49 print usage message then exit.
50
51 -H, --hex
52 outputs response from RECEIVE DIAGNOSTIC RESULTS in hex rather
53 than decode it.
54
55 -l, --list
56 when a DEVICE is also given lists the names of all diagnostic
57 pages supported by this device. The request is sent via a SEND
58 DIAGNOSTIC command (with the "pF" bit set) and the response is
59 fetched by a RECEIVE DIAGNOSTIC RESULTS command. When used in
60 the absence of a --list argument then a list of diagnostic page
61 names and their numbers, known by this utility, are listed.
62
63 -O, --old
64 Switch to older style options. Please use as first option.
65
66 -p, --pf
67 set Page Format (PF) bit. By default it is clear (i.e. 0) unless
68 the list --list option is given in which case the Page Format
69 bit is set (as required by SPC-3).
70
71 -r, --raw=H,H...
72 string of comma separated hex numbers each of which should
73 resolve to a byte value (i.e. 0 to ff inclusive). A (single)
74 space separated string of hex bytes is also allowed but the list
75 needs to be in quotes. This sequence forms a diagnostic page to
76 be sent with the SCSI SEND DIAGNOSTIC command. Mostly likely the
77 --pf option should also be given.
78
79 -r, --raw=-
80 reads sequence of bytes from stdin. The sequence may be comma,
81 space, tab or linefeed (newline) separated. If a line contains
82 "#" then the remaining characters on that line are ignored. Oth‐
83 erwise each non separator character should resolve to a byte
84 value (i.e. 0 to ff inclusive). This sequence forms a diagnostic
85 page to be sent with the SCSI SEND DIAGNOSTIC command. Mostly
86 likely the --pf option should also be given.
87
88 -s, --selftest=ST
89 where ST is the self-test code. The default value is 0 which is
90 inactive. Some other values:
91 1 : background short self-test
92 2 : background extended self-test
93 4 : aborts a (background) self-test that is in progress
94 5 : foreground short self-test
95 6 : foreground extended self-test
96 This option is mutually exclusive with default self-test (i.e.
97 can't have (ST > 0) and --test).
98
99 -t, --test
100 sets the _default_ Self Test (SelfTest) bit. By default this is
101 clear (0). The --selftest=ST option should not be active
102 together with this option. Both the --doff and/or --uoff options
103 can be used with this option.
104
105 -u, --uoff
106 set the Unit Offline (UnitOffL) bit (default is clear). Only
107 significant when --test option is set for the default self-test.
108 When set other operations on this logical unit may be affected
109 (delayed) while a default self-test is underway. Some devices
110 (e.g. Fujitsu disks) do more tests when this bit is set.
111
112 -v, --verbose
113 increase level of verbosity. Can be used multiple times.
114
115 -V, --version
116 print out version string then exit.
117
119 All devices should support the default self-test. The 'short' self-test
120 codes should complete in 2 minutes or less. The 'extended' self-test
121 codes' maximum duration is vendor specific (e.g. a little over 10 min‐
122 utes with the author's disks). The foreground self-test codes wait
123 until they are completed while the background self-test codes return
124 immediately. The results of both foreground and background self-test
125 codes are placed in the 'self-test results' log page (see sg_logs(8)).
126 The SCSI command timeout for this utility is set to 60 minutes to allow
127 for slow foreground extended self-tests.
128
129 If the DEVICE is a disk then no file systems residing on that disk
130 should be mounted during a foreground self-test. The reason is that
131 other SCSI commands may become queued behind the foreground self-test
132 and timeout.
133
134 When the --raw=H,H... option is given then self-tests should not be
135 selected. However the --pf (i.e. "page format") option should be given.
136 The length of the diagnostic page to be sent is derived from the number
137 of bytes given to the --raw=H,H... option. The diagnostic page code
138 (number) should be the first byte of the sequence (i.e. as dictated by
139 SPC-3 diagnostic page format). See the EXAMPLES section below.
140
141 Arbitrary diagnostic pages can be read (in hex) with the sg_ses(8)
142 utility (not only those defined in SES-2).
143
144 If the utility is used with no options (e.g. "sg_senddiag /dev/sg1")
145 Then a degenerate SCSI SEND DIAGNOSTIC command is sent with zero in all
146 its fields apart from the opcode. Some devices report this as an error
147 while others ignore it. It is not entirely clear from SPC-3 if it is
148 invalid to send such a command.
149
150 In the 2.4 series of Linux kernels the DEVICE must be a SCSI generic
151 (sg) device. In the 2.6 series block devices (e.g. SCSI disks and DVD
152 drives) can also be specified.
153
154 To access SCSI enclosures see the sg_ses(8) utility. sg_ses uses the
155 SCSI SEND DIAGNOSTIC and RECEIVE DIAGNOSTIC RESULTS commands as out‐
156 lined in the SES-2 (draft) standard.
157
159 The exit status of sg_senddiag is 0 when it is successful. Otherwise
160 see the sg3_utils(8) man page.
161
163 The options in this section were the only ones available prior to
164 sg3_utils version 1.23 . In sg3_utils version 1.23 and later these
165 older options can be selected by either setting the SG3_UTILS_OLD_OPTS
166 environment variable or using '--old' (or '-O) as the first option.
167
168 -doff set the Device Offline (DevOffL) bit (default is clear). Only
169 significant when -t option is set for the default self-test.
170 Equivalent to --doff in the main description.
171
172 -e outputs the expected extended self-test duration. Equivalent to
173 --extdur in the main description.
174
175 -h outputs response from RECEIVE DIAGNOSTIC RESULTS in hex rather
176 than decode it.
177
178 -H outputs response from RECEIVE DIAGNOSTIC RESULTS in hex rather
179 than decode it.
180
181 -l when a DEVICE is also given lists the names of all diagnostic
182 pages supported by this device. The request is sent via a SEND
183 DIAGNOSTIC command (with the "pf" bit set) and the response is
184 fetched by a RECEIVE DIAGNOSTIC RESULTS command. When used in
185 the absence of a DEVICE argument then a list of diagnostic page
186 names and their numbers, known by this utility, are listed.
187
188 -N, --new
189 Switch to the newer style options.
190
191 -pf set Page Format (PF) bit. By default it is clear (i.e. 0) unless
192 the -l option is given in which case the Page Format bit is set
193 (as required by SPC-3).
194
195 -raw=H,H...
196 string of comma separated hex numbers each of which should
197 resolve to a byte value (i.e. 0 to ff inclusive). This sequence
198 forms a diagnostic page to be sent with the SCSI SEND DIAGNOSTIC
199 command. Mostly likely the -pf option should also be given.
200
201 -raw=- reads sequence of bytes from stdin. The sequence may be comma,
202 space, tab or linefeed (newline) separated. If a line contains
203 "#" then the remaining characters on that line are ignored. Oth‐
204 erwise each non separator character should resolve to a byte
205 value (i.e. 0 to ff inclusive). This sequence forms a diagnostic
206 page to be sent with the SCSI SEND DIAGNOSTIC command. Mostly
207 likely the -pf option should also be given.
208
209 -s=ST where ST is the self-test code. The default value is 0 which is
210 inactive. A value of 1 selects a background short self-test; 2
211 selects a background extended self-test; 5 selects a foreground
212 short self-test; 6 selects a foreground extended test. A value
213 of 4 will abort a (background) self-test that is in progress.
214 This option is mutually exclusive with default self-test (i.e.
215 -t).
216
217 -t sets the _default_ Self Test (SelfTest) bit. By default this is
218 clear (0). The -s=ST option should not be active together with
219 this option. Both the -doff and/or -uoff options can be used
220 with this option.
221
222 -uoff set the Unit Offline (UnitOffL) bit (default is clear). Equiva‐
223 lent to --uoff in the main description.
224
225 -v increase level of verbosity. Can be used multiple times.
226
227 -V print out version string then exit.
228
229 -? output usage message. Ignore all other parameters.
230
232 The examples sub-directory in the sg3_utils packages contains two exam‐
233 ple scripts that turn on the CJTPAT (jitter pattern) on some SAS disks
234 (one script for each phy). One possible invocation for phy 1 is:
235
236 sg_senddiag --pf --raw=- /dev/sg2 < sdiag_sas_p1_cjtpat.txt
237
238 There is also an example script that turns on the IDLE pattern. Once a
239 test pattern has been started it can be turned off by resetting the phy
240 or with the STOP phy pattern function:
241
242 sg_senddiag --pf --raw=- /dev/sg2 < sdiag_sas_p1_stop.txt
243
245 Written by Douglas Gilbert
246
248 Report bugs to <dgilbert at interlog dot com>.
249
251 Copyright © 2003-2011 Douglas Gilbert
252 This software is distributed under the GPL version 2. There is NO war‐
253 ranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
254 POSE.
255
257 sg_ses(8), sg_logs(8), smartmontools(see net)
258
259
260
261sg3_utils-1.33 December 2011 SG_SENDDIAG(8)