1SG_LOGS(8)                         SG3_UTILS                        SG_LOGS(8)
2
3
4

NAME

6       sg_logs - access log pages with SCSI LOG SENSE command
7

SYNOPSIS

9       sg_logs  [--all]  [--brief]  [--control=PC]  [--help]  [--hex] [--list]
10       [--maxlen=LEN] [--name] [--page=PG[,SPG]] [--paramp=PP] [--pcb] [--ppc]
11       [--raw]   [--reset]  [--select]  [--sp]  [--temperature]  [--transport]
12       [--verbose] [--version] DEVICE
13
14       sg_logs [-a] [-A] [-b]  [-c=PC]  [-h]  [-H]  [-l]  [-L]  [-m=LEN]  [-n]
15       [-p=PG[,SPG]] [-paramp=PP] [-pcb] [-ppc] [-r] [-select] [-sp] [-t] [-T]
16       [-v] [-V] [-?]  DEVICE
17

DESCRIPTION

19       This utility sends a SCSI LOG SENSE command to the DEVICE and then out‐
20       puts  the  response.  The LOG SENSE command is used to fetch log pages.
21       Known log pages  are  decoded  by  default.  When  the  --reset  and/or
22       --select  option  is  given then a SCSI LOG SELECT command is issued to
23       reset parameters.
24
25       In SPC-4 revision 5 a subpage code was introduced to both the LOG SENSE
26       and  LOG  SELECT command. At the same time a page code field was intro‐
27       duced to the to the LOG SELECT command. The log subpage code can  range
28       from  0  to  255  (0xff)  inclusive.  The subpage code value 255 can be
29       thought of as a wildcard.
30
31       This utility supports two command line syntaxes, the preferred  one  is
32       shown first in the synopsis and explained in this section. A later sec‐
33       tion on the old command  line  syntax  outlines  the  second  group  of
34       options.
35

OPTIONS

37       Arguments to long options are mandatory for short options as well.
38
39       -a, --all
40              outputs all the log pages supported by the device. This requires
41              a two stage process: first the "supported log pages" log page is
42              fetched,  then for each entry in the response, the corresponding
43              log page is fetched and displayed.  When used twice (e.g. '-aa')
44              all log pages and subpages are fetched.
45
46       -b, --brief
47              shorten the amount of output for some log pages. For example the
48              Tape Alert log page only outputs parameters whose flags are  set
49              when --brief is given.
50
51       -c, --control=PC
52              accepts 0, 1, 2 or 3 for the PC argument:
53                0 : current threshold values
54                1 : current cumulative values
55                2 : default threshold values
56                3 : default cumulative values
57              The default value is 1 (i.e. current cumulative values).
58
59       -h, --help
60              print out the usage message then exit.
61
62       -H, --hex
63              The  default  action  is  to decode known mode page numbers (and
64              subpage numbers) into text. When this option is used  once,  the
65              response is output in hexadecimal.
66
67       -l, --list
68              lists  the  names  of  all  logs  sense  pages supported by this
69              device. This is done by reading the "supported  log  pages"  log
70              page.  When  used twice (e.g. '-ll') lists the names of all logs
71              sense pages and subpages supported by this device.  There  is  a
72              list of common log page codes below.
73
74       -m, --maxlen=LEN
75              sets  the "allocation length" field in the LOG SENSE cdb. The is
76              the maximum length in bytes that the response will  be.  Without
77              this option (or LEN equal to 0) this utility first fetches the 4
78              byte response then does a second access with  the  length  indi‐
79              cated  in the first (4 byte) response. Negative values and 1 for
80              LEN are not accepted. Responses can be  quite  large  (e.g.  the
81              background scan results log page) and this option can be used to
82              limit the amount of information returned.
83
84       -n, --name
85              decode some log pages into 'name=value' entries, one  per  line.
86              The  name contains no space and may be abbreviated and the value
87              is decimal unless prefixed by  '0x'.  Nesting  is  indicated  by
88              leading  spaces.  This  form  is  meant to be relatively easy to
89              parse.
90
91       -O, --old
92              switch to older style options.
93
94       -p, --page=PG[,SPG]
95              log page code to access. PG is expected to be a  decimal  number
96              between  0  and 63 inclusive. A hexadecimal number can be speci‐
97              fied by a leading "0x" or a trailing "h". Common log page  codes
98              are  listed below. Optionally SPG, a subpage code, can be given.
99              SPG is expected to be a decimal number between 0 and 255  inclu‐
100              sive.
101
102       -P, --paramp=PP
103              PP  is  the  parameter pointer value to place in a field of that
104              name in the LOG SENSE cdb. A decimal number in the  range  0  to
105              65535 (0xffff) is expected. When a value greater than 0 is given
106              the --ppc option should be selected. The default value is 0.
107
108       -q, --pcb
109              show Parameter Control Byte settings  (only  relevant  when  log
110              parameters being output in ASCII).
111
112       -Q, --ppc
113              sets  the  Parameter  Pointer Control (PPC) bit in the LOG SENSE
114              cdb. Default is 0 (i.e. cleared).
115
116       -r, --raw
117              output the response in binary  to  stdout.  Error  messages  and
118              warnings are output to stderr.
119
120       -R, --reset
121              use  SCSI  LOG SELECT command (PCR bit set) to reset the all log
122              pages (or the given page). [SPC-4 (rev 6)  doesn't  say  that  a
123              given  log  (sub)page  can  be reset yet.] Exactly what is reset
124              depends on the accompanying  SP  bit  (i.e.  --sp  option  which
125              defaults to 0) and the PC ("page control") value (which defaults
126              to 1). Supplying this option  implies  the  --select  option  as
127              well.  This  option  seems  to clear error counter log pages but
128              leaves pages like self-test results,  start-stop  cycle  counter
129              and  temperature  log  pages  unaffected.  This  option  may  be
130              required to clear log pages if a  counter  reaches  its  maximum
131              value  since  the  log  page  in which the counter is found will
132              remain "stuck" until something is done.
133
134       -S, --select
135              use a LOG SELECT command. The default action (i.e. when  neither
136              this  option nor --reset is given) is to do a LOG SENSE command.
137              When this option is given, the SP bit (i.e.  --sp  option  which
138              defaults to 0), the PC ("page control") value (which defaults to
139              1) and the PCR bit (i.e.  --reset option which  defaults  to  0)
140              are placed in the LOG SELECT cdb. At some stage the log page and
141              subpage options may also be active [but SPC-4  (rev  6)  doesn't
142              say that].
143
144       -s, --sp
145              sets  the  Saving  Parameters  (SP)  bit.  Default  is  0  (i.e.
146              cleared). When set this instructs the device to store  the  cur‐
147              rent log page parameters (as indicated by the DS and TSD parame‐
148              ter codes) in some non-volatile location.  Hence the log parame‐
149              ters will be preserved across power cycles. This option is typi‐
150              cally not needed, especially if the GLTSD flag is clear  in  the
151              control  mode  page as this instructs the device to periodically
152              save all saveable log parameters to non-volatile locations.
153
154       -t, --temperature
155              outputs the temperature. First looks in the temperature log page
156              and  if that is not available tries the Informational Exceptions
157              log page which may also have the current temperature (especially
158              on older disks).
159
160       -T, --transport
161              outputs  the  transport  ('Protocol  specific  port')  log page.
162              Equivalent to setting '--page=18h'.
163
164       -v, --verbose
165              increase level of verbosity.
166
167       -V, --version
168              print out version string then exit.
169

NOTES

171       This utility will usually do a double fetch of log pages with the  SCSI
172       LOG  SENSE  command.  The  first fetch requests a 4 byte response (i.e.
173       place 4 in the  "allocation  length"  field  in  the  cdb).  From  that
174       response  it  can  calculate the actual length of the response which is
175       what it asks for on the second fetch. This is typical practice in  SCSI
176       and  guaranteed  to  work  in the standards. However some older devices
177       don't comply. For those devices using the --maxlen=LEN option will do a
178       single fetch.  A value of 252 should be a safe starting point.
179
180       Various  log  pages  hold  information error rates, device temperature,
181       start stop cycles since device produced and the results of the last  20
182       self  tests. Self tests can be initiated by the sg_senddiag(8) utility.
183       The smartmontools package provides much of the information  found  with
184       sg_logs  in a form suitable for monitoring the health of SCSI disks and
185       tape drives.
186
187       Here is a list of log pages that are decoded by this utility. [The code
188       values  can be given to '--page=' as is, with a trailing "h" instead of
189       the leading "0x", or as their decimal equivalents.]:
190
191       0x0       Supported log pages
192       0x0,0xff  Supported log pages and subpages
193       0x1       Buffer overrun/underrun
194       0x2       Write error counter
195       0x3       Read error counter
196       0x4       Read reverse error counter
197       0x5       Verify error counter
198       0x6       Non-medium error
199       0x7       Last n error events
200       0x8       Format status (sbc-2)
201       0xb       Last n deferred errors or asynchronous events
202       0xc       Sequential access device (ssc-2)
203       0xd       Temperature
204       0xe       Start-stop cycle counter
205       0x10      Self-test results
206       0x15      Background scan results (sbc-3)
207       0x17      Non-volatile cache (sbc-3)
208       0x18      Protocol specific port (SAS transport)
209       0x19      General statistics and performance
210       0x2f      Informational exceptions
211       0x37      Seagate cache (vendor, disk)
212       0x3e      Seagate factory (vendor, disk)
213
214       In the 2.4 series of Linux kernels the DEVICE must be  a  SCSI  generic
215       (sg)  device.  In the 2.6 series block devices (e.g. SCSI disks and DVD
216       drives) can also be specified. For example "sg_logs -a  /dev/sda"  will
217       work in the 2.6 series kernels.
218

EXIT STATUS

220       The  exit  status  of sg_logs is 0 when it is successful. Otherwise see
221       the sg3_utils(8) man page.
222

OLDER COMMAND LINE OPTIONS

224       The options in this section were  the  only  ones  available  prior  to
225       sg3_utils  version  1.23  .  In  sg3_utils version 1.23 and later these
226       older options can be selected by either setting the  SG3_UTILS_OLD_OPTS
227       environment variable or using '--old' (or '-O) as the first option.
228
229       Options  with  arguments  or with two or more letters can have an extra
230       '-' prepended. For example: both '-pcb' and '--pcb' are acceptable.
231
232       -a     outputs all the log pages supported by the  device.   Equivalent
233              to --all in the main description.
234
235       -A     outputs  all the log pages and subpages supported by the device.
236              Equivalent to '--all --all' in the main description.
237
238       -c=PC  Equivalent to --control=PC in the main description.
239
240       -h     suppresses decoding of known log sense pages and prints out  the
241              response in hex instead.
242
243       -H     same  action  as '-h' in this section and equivalent to --hex in
244              the main description.
245
246       -l     lists the names of  all  logs  sense  pages  supported  by  this
247              device.  Equivalent to --list in the main description.
248
249       -L     lists  the  names of all logs sense pages and subpages supported
250              by this device.  Equivalent  to  '--list  --list'  in  the  main
251              description.
252
253       -m=LEN request  only  LEN bytes of response data. Default is 0 which is
254              interpreted as all that is available. LEN is decimal  unless  it
255              has  a leading '0x' or trailing 'h'.  Equivalent to --maxlen=LEN
256              in the main description.
257
258       -n     Equivalent to --name in the main description.
259
260       -N     switch to the newer style options.
261
262       -p=PG[,SPG]
263              PG is the log page code to access. Should be a hexadecimal  num‐
264              ber  between 0 and 3f inclusive. If given SPG is the log subpage
265              code.  SPG should be a  hexadecimal  number  between  0  and  ff
266              inclusive. The subpage code of 'ff' can be thought of as a wild‐
267              card.
268
269       -paramp=PP
270              PP is the parameter pointer value (in hex) to place in  command.
271              Should be a number between 0 and ffff inclusive.
272
273       -pcb   show  Parameter  Control  Byte  settings (only relevant when log
274              parameters being output in ASCII).
275
276       -ppc   sets the Parameter Pointer Control (PPC) bit. Default is 0 (i.e.
277              cleared).
278
279       -r     use  SCSI  LOG SELECT command (PCR bit set) to reset the all log
280              pages (or the given page). Equivalent to  --reset  in  the  main
281              description.
282
283       -select
284              use  a  LOG  SELECT  command. Equivalent to --select in the main
285              description.
286
287       -sp    sets  the  Saving  Parameters  (SP)  bit.  Default  is  0  (i.e.
288              cleared).  Equivalent to --sp in the main description.
289
290       -t     outputs the temperature. Equivalent to --temperature in the main
291              description.
292
293       -T     outputs the  transport  ('Protocol  specific  port')  log  page.
294              Equivalent to --transport in the main description.
295
296       -v     increase level of verbosity.
297
298       -V     print out version string then exit.
299
300       -?     output usage message then exit.
301

AUTHOR

303       Written by Doug Gilbert
304

REPORTING BUGS

306       Report bugs to <dgilbert at interlog dot com>.
307
309       Copyright © 2002-2007 Douglas Gilbert
310       This  software is distributed under the GPL version 2. There is NO war‐
311       ranty; not even for MERCHANTABILITY or FITNESS FOR  A  PARTICULAR  PUR‐
312       POSE.
313

SEE ALSO

315       smartctl(smartmontools), sg_senddiag(8)
316
317
318
319sg3_utils-1.24                    April 2007                        SG_LOGS(8)
Impressum