My system outputs some values in different units, which the script doesn’t fix up, leading to fake alarms like CRITICAL - Sensor value 45.52 mW, which is bigger than 15.0 for this output:
The fix, for my future self, is to add mW handling the same way as mV, in the file ./local/lib/python3/cmk/base/plugins/agent_based/lmsensors2.py.
I think the round() should probably be done on the mV as well, but I don’t have any mV values to test with.
if unit == "mV":
value = value/1000
if unit == "mW":
value = round(value/1000,4)
....
if unit == "mV":
unit = "V"
value = value/1000
if unit == "mW":
unit = "V"
value = round(value/1000,4)
Checkmk assumes canonical MKSI units everywhere, so either lmsensors might be patched for a strict MKSI mode, or a check written for Checkmk might detect non MKSI units in input and calculate the correct MKSI unit from there. But applying 15 to an input field named “power” and assuming it is anything other than Watts will not work.
I will have a look there and probably give better hints on canonical units in the articles on check plugin development. Thanks for the hint!
I think the agent itself should probably do this conversion, so its only done once, not on every display right ?
Sadly the agent in this case uses giant wodgies of perl one liners instead of readable code, probably because it’s trying to parse ‘sensors’ output without using the “machine readable” flag (-u)