#916 closed enhancement (duplicate)

Adding --json command line option

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

Description

I would like to prepare a patch to implement '--json' cmd option, as mentioned in ticket #766. I'm new to this project and would appreciate your help.

  1. Is it okay if I use C++11 features, even if it as little as "auto"?
  1. What's your opinion about using a JSON library? (specifically this one - JSON for Modern C++)
  1. I wish to create a data structure to hold the smart data, and print it when it's completely populated.

Do you have insights about how the data structure should look like, considering hierarchy, data order, and which containers to use?

When looking at the first chunks of output for SATA I was wondering how to represent the data, so it would be easy to traverse and print. The general idea is to have a container to represent each section, for example:

struct smart_data
{

map<string, string> info_section;
map<string, string> smart_data_section;
vector<map<string,string>> vendor_specific_attr;
more containers go here

};

Is there a certain format you prefer it to be represented?

  1. Is there a way to mock output from devices I don't have (such as SAS)? I wish to test this output but I don't have all of the supported disks out there...

Many thanks!

Change History (1)

comment:1 Changed 21 months ago by Alex Samorukov

Component: allsmartctl
Resolution: duplicate
Status: newclosed
Type: patchenhancement

Hi Yaarit,

I would recommend to move discussion to the smartmontools-devel mailing list, to deal with a wider audience. Below is my personal opinion on the few topics you mentioned:

  1. Now smartmontools can be built on any OS with C++ compiler, i think it is a big benefit, giving the fact that it is common to find it on the hardware appliances with a minimalistic environment, as well as on some not-so-up-to-date OS (see full list in the manual). So we should think twice about adding some external dependency, especially if we are talking about such a basic functionality like a program output. However, if license is compatible with a smartmontools we can [optionally] include it, like it is with regex and getopt.
  1. I think if it would replicate todays output (may be in a little more "strict" format) that would be fine. Goal here is to provide machine-readable output suitable for importing in any external software with json support, or just more convenient scripting, e.g. using jq tool.
  1. You can find outputs for the many devices in the our bug tracker on this site (just use search) and when patch will be ready - ask users in the smartmontools list to provide more testing. For NVME it is possible to use qemu trunk (see NVMe page) with a NVMe device emulation supporting SMART data.

P.S. if you want to use git and github to submit your patches for review - there is an official mirror for that. Feel free to fork & PR. For discussions please use maillist, this tracker is for the bugreports. I am closing now this ticket, because we already have tickets for the JSON and i do not see a lot of sense to have duplicates.

Thank you, and lets move to the maillist

Note: See TracTickets for help on using tickets.