Lmsensors2 - is the author here?

Does anyone know how to contact the author of Checkmk Exchange?

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:

# sensors -A
fam15h_power-pci-00c4
power1:       67.44 mW (avg =   6.26 mW, interval =   0.01 s)
                       (crit =  15.00 W)

I’m fairly sure of what to change in the code, but would rather it was easy to contribute back…

This looks like the github repo for this check.

But it also looks a little bit dead :wink:

The implementation of the agent plugin there, lmsensors2/agent/lmsensors2 at master · modusoft/lmsensors2 · GitHub, is different, so not the right repo.

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!

1 Like

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) :slight_smile: