Opened 8 years ago

Closed 7 years ago

#774 closed enhancement (wontfix)

Add machine-readable output formating

Reported by: lynxchaus Owned by:
Priority: minor Milestone:
Component: smartctl Version: 6.5
Keywords: Cc:

Description

Patch adds machine simple comma-delimited output format.

example output:
# smartctl -A -f machine /dev/sda
1,Raw_Read_Error_Rate,0x000f,117,97,6,Pre-fail,Always,-,133234088
3,Spin_Up_Time,0x0003,96,95,0,Pre-fail,Always,-,0
4,Start_Stop_Count,0x0032,99,99,20,Old_age,Always,-,1386
5,Reallocated_Sector_Ct,0x0033,100,100,36,Pre-fail,Always,-,0
7,Seek_Error_Rate,0x000f,78,60,30,Pre-fail,Always,-,81588632
9,Power_On_Hours,0x0032,86,86,0,Old_age,Always,-,12439
10,Spin_Retry_Count,0x0013,100,100,97,Pre-fail,Always,-,0
12,Power_Cycle_Count,0x0032,99,99,20,Old_age,Always,-,1391
187,Reported_Uncorrect,0x0032,97,97,0,Old_age,Always,-,3
189,High_Fly_Writes,0x003a,100,100,0,Old_age,Always,-,0
190,Airflow_Temperature_Cel,0x0022,48,43,45,Old_age,Always,In_the_past,52 (Min/Max 25/52 #152)
194,Temperature_Celsius,0x0022,52,57,0,Old_age,Always,-,52 (0 17 0 0 0)
195,Hardware_ECC_Recovered,0x001a,45,42,0,Old_age,Always,-,19427128
197,Current_Pending_Sector,0x0012,100,100,0,Old_age,Always,-,1
198,Offline_Uncorrectable,0x0010,100,100,0,Old_age,Offline,-,1
199,UDMA_CRC_Error_Count,0x003e,200,200,0,Old_age,Always,-,0
200,Multi_Zone_Error_Rate,0x0000,100,253,0,Old_age,Offline,-,0
202,Data_Address_Mark_Errs,0x0032,100,253,0,Old_age,Always,-,0

Attachments (1)

add-machine-format.patch (5.9 KB ) - added by lynxchaus 8 years ago.

Download all attachments as: .zip

Change History (5)

by lynxchaus, 8 years ago

Attachment: add-machine-format.patch added

comment:1 by Christian Franke, 8 years ago

Milestone: undecided
Priority: majorminor

Thanks for this patch. Sorry, not applied for now for various reasons:

  • The attribute table is IMO already "machine readable": Fixed size columns separated by spaces, no spaces within columns (except last column).
  • A wrapper script would have the same effect, for example:
    #!/bin/sh
    test $# = 1 || { echo "Usage: $0 DEVICE"; exit 1; }
    
    out=$(/usr/sbin/smartctl -A "$1")
    rc=$?
    
    a='\([^ ][^ ]*\)  *' n='0*\([^ ][^ ]*\)  *'
    echo "$out" | sed -e '1,/^ID#/d' \
      -e "s|^ *$a$a$a$n$n$n$a$a$a|"'\1,\2,\3,\4,\5,\6,\7,\8,\9,|'
    
    exit $rc
    
  • Advanced machine readability will eventually be addressed by JSON output, see ticket #766.

comment:2 by lynxchaus, 8 years ago

Ahha, search google around "parse smartctl output" - every time people reinvent wheel on $LANG with all sorts of regex parsers.
Generate JSON is easy but shut-up all other noise from smartctl - is not. There is banner, "start reading of ..." and other.
Maybe create -Q switch to make tool really silent?

in reply to:  2 comment:3 by Christian Franke, 7 years ago

Of course the JSON output will not contain the current banner as is - but likely the smartmontools version/platform/build info as JSON.

comment:4 by Christian Franke, 7 years ago

Milestone: undecided
Resolution: wontfix
Status: newclosed

Topic will be addressed by JSON, see ticket #766.

Note: See TracTickets for help on using tickets.