louwrentius / showtools

Shows detailed disk or network device information
BSD 3-Clause "New" or "Revised" License
122 stars 17 forks source link

[Suggestion] smartctl now supports --json output #14

Closed danieldjewell closed 11 months ago

danieldjewell commented 3 years ago

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?

louwrentius commented 3 years ago

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.

danieldjewell commented 3 years ago

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....

louwrentius commented 3 years ago

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 commented 11 months ago

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

louwrentius commented 11 months ago

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