You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for sharing the idea of a LLD script. I am not a huge fan of JSON hacks though so I modified the script that it uses jq to do all the parsing. This way it is guaranteed that the output is always a valid and nicely formatted json. Feel free to reuse or perhaps provide as an alternative where jq is installed.
sensors -j | \
jq '{"data": [to_entries[]|.key as $chip | .value |
to_entries[]|.key as $group | .value |
select(type == "object") | # discard scalars
to_entries[]|.key as $sensor|
select($sensor|test(".*input"))|
if ($sensor|test("temp.*")) then .units="°C"
elif ($sensor|test("power.*")) then .units="W"
elif ($sensor|test("fan.*")) then .units="RPM"
elif ($sensor|test("in.*")) then .units="V"
else .units=""
end |
{"{#CHIP}":$chip, "{#SENSOR}":($sensor|sub("_input";"")), "{#UNITS}":.units}]}'
The text was updated successfully, but these errors were encountered:
Thank you for sharing the idea of a LLD script. I am not a huge fan of JSON hacks though so I modified the script that it uses
jq
to do all the parsing. This way it is guaranteed that the output is always a valid and nicely formatted json. Feel free to reuse or perhaps provide as an alternative wherejq
is installed.The text was updated successfully, but these errors were encountered: