showtools icon indicating copy to clipboard operation
showtools copied to clipboard

[Suggestion] smartctl now supports --json output

Open danieldjewell opened this issue 3 years ago • 3 comments

Not sure when it got added but smartctl now supports a --json option (and it's also surprisingly configurable).

This is as of v7.2-1 in debian/sid.

Could provide some additional reliability instead of having to parse the human readable output?

danieldjewell avatar Aug 07 '21 17:08 danieldjewell

Thank you for the tip!

Just to set expectations, I'll leave this open but I won't implement this on short notice. Older Linux platforms may ship older versions of smartmontools and those still need to work too. Hope you understand.

louwrentius avatar Aug 08 '21 00:08 louwrentius

Thank you for the tip!

Absolutely :)

Just to set expectations, I'll leave this open but I won't implement this on short notice. Older Linux platforms may ship older versions of smartmontools and those still need to work too. Hope you understand.

Of course, obviously the code that does the parsing is already there and still useful. (Could even be a fallback for older systems)

I did a little more digging -- it looks like JSON functionality was initially added in ~2017: https://www.smartmontools.org/log/trunk/smartmontools/json.cpp

Looking at the tags, the revision # would correspond to being in smartmontools >= 7.x

And I think your concern about older versions is warranted: https://repology.org/project/smartmontools/versions

Debian/stable(buster) is on 6.6 still! (Although buster-backports does have 7.2....) I wonder how that breaks out statistically based on what's actually installed out there hmmm....

danieldjewell avatar Aug 08 '21 17:08 danieldjewell

Thank you for digging a bit deeper in the actual age of this feature.

But you made the point that is in my head: it's already there. Not without some bugs due to platform differences I recall that would have totally been prevented by the json output - but here we are and the output parsing bugs have been ironed out as far as those bug reports go.

But when I do get new bug reports, I may switch over to json as the new default and keep the old stuff for fallback.

louwrentius avatar Aug 08 '21 21:08 louwrentius

I've started working on supporting JSON output in the development branch, it's still a work in progress

louwrentius avatar Nov 17 '23 00:11 louwrentius

With the latest commit to master, SMARTCTL JSON output is now used.

louwrentius avatar Nov 17 '23 14:11 louwrentius