Update from 2.0.0P22 to 2.1 | Missing monitoring data for plugins: wmi_cpuload

Today i had some systems with this problem and only the section [system_perf] was empty. Computer system was working as expected.
In search for a solution i also had a look at the check - wmi_cpuload.py and found some strang things.
Why is there no real error handling inside the parsing function? It returns empty output but the section is not empty.

For all who want a small workaround.
It only give the error if the computer_system table is empty.

Original

    try:
        load = wmi_tables["system_perf"].get(0, "ProcessorQueueLength")
        timestamp = get_wmi_time(wmi_tables["system_perf"], 0)
        computer_system = wmi_tables["computer_system"]
    except (KeyError, WMIQueryTimeoutError):
        return None
    assert load

changed version

    try:
        load = wmi_tables["system_perf"].get(0, "ProcessorQueueLength")
    except (KeyError, WMIQueryTimeoutError):
        load = 0.0

    try:
        timestamp = get_wmi_time(wmi_tables["system_perf"], 0)
    except (KeyError, WMIQueryTimeoutError):
        timestamp = 0.0

    try:
        computer_system = wmi_tables["computer_system"]
    except (KeyError, WMIQueryTimeoutError):
        return None
1 Like