HWiNFO Sensors in CheckMK

I use HWiNFO64 on my Windows PCs to monitor the various temperature and fan sensors.  I wanted to get this data into CheckMK for monitoring purposes.  Here’s how I did it.

First, in HWiNFO, tag any sensors you want to monitor for the Vista gadget.  This causes HWiNFO to populate registry keys with the relevant data.  You’ll then need to make a custom plugin for CheckMK in C:\Program Files (x86)\checkmk\plugins named “hwinfo64.cmd”, containing the following;

Now, do a test on your CheckMK server, you should see the <<<hwinfo64>>> fields in your agent output for the host.  Great.  Now we need to write a check in CheckMK to interpret that data.  Make a new check ‘hwinfo64’ in /omd/sites/SITENAME/local/share/check_mk/checks, replacing SITENAME with your OMD site name;

Apologies for the terrible Python, my Python is very weak.  Also note that this assumes that all temperature-type sensors are in Celsius units, and all fan-type sensors are in RPM units.

Once that’s done, you should be able to add services to your host and the HWiNFO sensors will be automatically inventoried and show up.  They will use some default thresholds.  In order to customize those thresholds, edit etc/check_mk/main.mk in your OMD site and do something like this;

That will set the warning/crit threshold for CPU temp checks at 70/80 C, and the threshold for GPU checks at 90/100 C, on the machines ‘desktop1’ and ‘desktop2’.  Set as appropriate for your environment.

7 thoughts on “HWiNFO Sensors in CheckMK”

  1. Hey there 🙂

    Thanks for writing this guide – content concerning temperature monitoring on Windows systems (with Nagios/Check_MK) seems to be pretty rare.

    Unfortunately, I’m not able to get any data from the hwinfo64 plugin to my Check_MK server and I can’t figure out how to add this as a new service to my Windows hosts via WATO.

    Basically, I’m stuck at “Now, do a test on your CheckMK server, you should see the <<>> fields in your agent output for the host”. I can see this field, but it is always empty. Like the check script does not output data or it fails to parse information coming from the plugin.

    Can you help me?

    1. First thing is to make sure that the plugin script is installed in the right place and it works. You should have the batch script installed in C:\Program Files (x86)\check_mk\plugins. Name it hwinfo64.cmd (NOT hwinfo64.cmd.txt !)

      Next up is to fire up a command prompt, CD to that directory, and run the script by hand. You should see the script dump a bunch of text output, which should look something like this;

      (replace the tildes with angle brackets, WordPress mangles them!)

      ~~~hwinfo64~~~

      HKEY_USERS\SOMESIDHERE\SOFTWARE\HWiNFO64\VSB
      Label0 REG_SZ CPU Package Temperature
      Value0 REG_SZ 23 °C
      Color0 REG_SZ 800000
      Label1 REG_SZ CPU Fan
      Value1 REG_SZ 721 RPM
      Color1 REG_SZ ff0000

      Your output will obviously be somewhat different. If you see that, then great, the plugin should work. Next thing is to try and telnet to your machine from the CheckMK server, port 6556. You should see the dumped output from the plugin in amongst all that.

      I believe your problem may be that the plugin script isn’t executable (it is likely to be a txt file instead of a .cmd batch script).

      1. Thanks for your reply!

        I’m sorry, should have mentioned that: The plugin script works fine locally…

        PS C:\Program Files (x86)\check_mk\plugins> C:\Program Files (x86)\check_mk\plugins\hwinfo64.ps1
        <<>>

        HKEY_CURRENT_USER\SOFTWARE\HWiNFO64\VSB
        Label0 REG_SZ CPU Temp (CPU)
        Value0 REG_SZ 36.0 øC
        Color0 REG_SZ ff0000

        I can telnet to the machine (Hyper-V-Server) but the output won’t show HWiNFO64 data (same result with “cmk -d Hyper-V-Server”) :

        (…)
        <<>>
        <<>>
        <<>>
        <<>>
        “Name” “State” “Uptime” “Status”
        (…)

  2. Thanks for your reply!

    I’m sorry, should have mentioned that: The plugin script works fine locally…

    C:\Users\AT\Desktop\hwinfo64.ps1
    <<>>

    HKEY_CURRENT_USER\SOFTWARE\HWiNFO64\VSB
    Label0 REG_SZ CPU Temp (CPU)
    Value0 REG_SZ 36.0 øC
    Color0 REG_SZ ff0000

    I can telnet to the machine (Hyper-V-Server) but output won’t show any HWiNFO64 data (same as “cmk -d Hyper-V-Server” executed as omd siteuser):

    (…)
    <<>>
    <<>>
    <<>>
    <<>>
    “Name” “State” “Uptime” “Status”
    (…)

    1. Ok. If you’re getting the same results when telnetting, we know it’s not CheckMK specifically. I note that the script you named above is a PS1, which means it’ll be executed with Powershell. The script will work with Powershell, but it’s a Windows Batch Script. I just did some testing, and it looks like Powershell doesn’t execute correctly in the context of the CheckMK agent. Don’t know why yet.

      At any rate, rename the script from hwinfo64.ps1 to hwinfo64.cmd so it executes with the command shell, and it should work fine.

      1. Hey, it works!

        Thanks for the hint “If you’re getting the same results when telnetting, we know it’s not CheckMK specifically.” 🙂

        Here is what I did to get it working with my hyper-v server (server 2012 R2) and my workstation (windows 8.1):

        ##############

        In your check-script I changed all occurences of

        regex = re.compile(“Label(\d)+”)

        to

        regex = re.compile(“Label(\d{1,2})”)

        to prevent the script omitting values/labels with consecutive numbers > 9.

        ##############

        [hwinfo64.ps1]

        # respective user instead of HKEY_CURRENT_USER
        HKEY_USERS\S-1-2-34-5678910111-2131415161-7181920212-223\SOFTWARE\HWiNFO64\VSB

        # replace degree char because it is broken in all output (powershell, check-script and webinterface)
        $mylist = $mylist.replace(‘°’,’D’)

        # replace blanks, otherwise the check-script will throw an error at line 19
        # error msg was something like “NoneType object has no attribute ‘.endswith'”
        # so the get_hwinfo64 function could not determine fieldUnits from line-array
        $mylist = $mylist.replace(‘ ‘,’ ‘)
        $mylist = $mylist.Trim()

        # remove comma for fan-RPM-values (thousands seperator)
        # otherwise the check_mk webinterface will throw an error during services-scan
        $mylist = $mylist.replace(‘,’,”)

        # get rid of registry lines containing hwinfo64-color (of tray-icons?)
        for ($i=0; $i -lt $mylist.Count; $i++)
        {
        if ($mylist[$i] -notlike “*Color*”)
        {
        [string[]] $mylist2 += $mylist[$i]
        }
        }

        # output without leading registry path and without blank lines at the end
        $mylist2[2..($mylist2.Count-2)]

        ##############

        Additional info based on my configuration:

        The check-script seems to ignore sensors with identical label. E.g. temperature sensors of two ssds were both labeled “Drive Temperature” in HWiNFO64. So I had to customize the labeltext in HWiNFO64: “Drive-1 Temperature” “Drive-2 Temperature”.

        I have four RAM temp-sensors labeled DIMM[0], DIMM[1], DIMM[4], DIMM[5] for which I defined thresholds in main.mk – check_mk ignored these thresholds until I altered the labeltext to DIMM-0 and so on in HWiNFO64 (and main.mk of course). The square brackets destroy check_mks syntax in the main.mk file.

        ##############

        Unresolved problems with my configuration:

        – degree character in webinterface looks like “39.0 °C” (I tried to hardcode in your check-script like fieldUnits = “°C” in respective lines)
        – for my workstation, I defined 3 temp sensors and 2 fan sensors, but somehow the script and the webinterface will only show 2 temp-values and 1 rpm-value (still working on this)

        Thanks for your help and your unique guide!

        Greetings, Andy

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.