prometheus-community/node-exporter-textfile-collector-scripts

smartmon.sh and parsing of LUN IDs

iustin opened this issue · 2 comments

Looking at the code in smartmon.sh, here:

  while read -r line; do
    info_type="$(echo "${line}" | cut -f1 -d: | tr ' ' '_')"
    case "${info_type}" in
    …
    Logical_Unit_id) lun_id="${info_value}" ;;

However, on all systems I have access to, the actual info contains LU WWN Device ID, and I suppose smartctl made an output change since this code was written.

The fix is rather trivial, but since I don't know if there are still old - or many just different - smartctl versions are there, needs to handle both.

This is a pretty strong argument for ditching both the smartmon.sh bash script and the smartmon.py Python script, both of which invoke smartctl in the usual way, and parse the human-readable output.

smartmontools has supported JSON output since 2017, and it would IMHO make a lot more sense to parse that. The smartmontools developers are aware that the JSON output is assumed to be machine-readable, and they avoid making backwards-incompatible changes to the format.

Right, let's not even bring up the duplication 😞 I was not aware of the JSON output, a quick look shows that it's much better indeed.