Ad Widget

Collapse

OpenHardwareMonitor WMI - Sensor Discovery + Collection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Clontarf[X]
    Member
    • Jan 2017
    • 80

    #1

    OpenHardwareMonitor WMI - Sensor Discovery + Collection

    Hi All, rather than dig up an old thread, I wanted to share my re-work of captainmac40's OpenHardwareMonitor scripts and template.

    Download: zabbix-template-openhardwaremonitor

    I have not yet revised the collection component of his work because frankly I haven't had to, it works just fine. I do want to do something about the values collected though, as it collects Real32 values, meaning "1.324" could be anything... 1.325 kittens?

    My changes mostly involve making more information available via discovery macros, to allow for more meaningful item names.



    Enjoy
  • klarter
    Junior Member
    • Jul 2020
    • 27

    #2
    I have downloaded template and scripts and installed them, and attached them to a host, but I don't seem to be getting any data. Openhardwaremonitor is running on the target computer.
    Is there anything else I need to do.
    How can I tell if the powershell scripts are working?
    regards,
    kl

    Comment

    • klarter
      Junior Member
      • Jul 2020
      • 27

      #3
      From agent log:
      Failed to execute command "powershell.exe -Noprofile -ExecutionPolicy Bypass -File "c:\program files\zabbix\ohm_disco.ps1"": Timeout while executing a shell script.
      active check "ohm_disco" is not supported: Timeout while executing a shell script.
      Last edited by klarter; 23-09-2020, 19:19. Reason: Extra character in my script. It works fine.

      Comment

      • klarter
        Junior Member
        • Jul 2020
        • 27

        #4
        Increased timeout in server config.
        Seems to be fine now.

        Comment

        • jgalea
          Junior Member
          • Feb 2022
          • 10

          #5
          I've been working on a number of customizations to grab additional data from my hosts to pass back to Zabbix and track and alert on. I love how easily extensible it is. Now, be gentle, I'm not a proficient coder but more of a hacker ... With this I have been able to add Windows: CPU and System temperatures using Open Hardware monitor, hard Drive temperatures and SMART status, as well as UPS battery levels. On ESX I've added CPU and system temperatures, Drive temperatures and SMART status. On Pfsense CPU temperature. I've coarsely documented what I've done on my blog to save others time. I have NOT taken the time to create templates to support these, I chose to manually add items and triggers. Here's the link ... https://johngalea.wordpress.com/2022...ring/#userdata

          Comment

          • tinomms
            Junior Member
            • Mar 2022
            • 4

            #6
            Wanted to add something to the knowledge base because it took me ages to piece together the info from lots of sources and figure it out. Perhaps it will save people some time.

            So you want to know how to add CPU temperature from Windows machines into an item within a Zabbix template??

            Here is how I did it:

            Pre-req: Install the Zabbix_Agent2 client on your windows PC.

            1) Download LibreHardwareMonitor (It is a more modern fork of OpenHardwareMonitor) You'll have to google it
            2) Run it on your Windows PC that you want the CPU temp from. Then from the options menu make sure you Run At Startup. This creates a scheduled task in Task Scheduler. You can amend it as required.
            3) In LibreHardwareMonitor, check that you can see the CPU temp you want (this will be the field that will report to Zabbix)
            4) The next step is to add an item to a template that issues a WMI call to LibreHardwareMonitor. I added mine to the "Windows CPU by Zabbix Agent" template. I called my item "WMI CPU Temp Value"
            5) In the new item make sure the following fields are filled in:

            Type is "Zabbix Agent"
            Key is the WMI call. This for me is: wmi.get[root/OpenHardwareMonitor,"SELECT value FROM Sensor WHERE SensorType ='Temperature' AND name='CPU Package'"]
            Type of information is "Numeric Float"
            Units: I pasted in °C

            6) Update your item. You can test if you like.

            It is worth noting that you can find so many more fields to report on using WMI and LibreHardwareMonitor should you want to. Go grab WMIExplorer, install it on your PC. Connect to the local machine and look at what info there is under root/LibreHardwareMonitor. Here is an example of another WMI query I use which lets me know how many GB of data has been written to an NVMe drive/s

            wmi.get[root/LibreHardwareMonitor,"SELECT value FROM Sensor WHERE SensorType ='Data' AND name='Data Written'"]

            If you have multiple NVMe drives they are referred to by the parent field: For example

            wmi.get[root/LibreHardwareMonitor,"SELECT value FROM Sensor WHERE SensorType ='Data' AND parent='/nvme/0' AND name='Data Written'"]

            wmi.get[root/LibreHardwareMonitor,"SELECT value FROM Sensor WHERE SensorType ='Data' AND parent='/nvme/1' AND name='Data Written'"]

            So to summarise. I'm using the built in ability of LibreHardwareMonitor which writes information into WMI, and then using Zabbix items to call those values using a WQL query.

            I hope this helps someone !!

            Comment


            • Buozinis
              Buozinis commented
              Editing a comment
              Hello, I am tried to do this, but I am failing.
              I have downloaded the software LibreHardwareMonitor, downloaded WMI explorer to see queries.

              wmi.get[root/LibreHardwareMonitor,"SELECT * FROM Sensor WHERE InstanceId='3863' AND ProcessId='01956a11-ee16-47b6-bae1-27df18b15ff0'"]
              in powershell I get error:
              At line:1 char:34
              + wmi.get[root/LibreHardwareMonitor,"SELECT * FROM Sensor WHERE Instanc ...
              + ~
              Missing argument in parameter list.
              + CategoryInfo : ParserError: ( [], ParentContainsErrorRecordException
              + FullyQualifiedErrorId : MissingArgument
          • etcrush
            Junior Member
            • Feb 2024
            • 2

            #7
            Originally posted by tinomms

            I hope this helps someone !!
            actually it helped a lot thanks

            Comment

            • Denionzz
              Junior Member
              • Feb 2024
              • 1

              #8
              It is not clear where LibreHardwareMonitor needs to be placed for this bundle to work. Please tell me. When I run the command, I just get an error about getting incorrect results.

              Comment


              • ryazur
                ryazur commented
                Editing a comment
                LibreHardwareMonitor can be installed anywhere, it just needs to be running so that it is added to the /root WMI namespace. I suggest using WMI explorer to make sure you are connecting to correct namespaces querying correct classes. In my case I had to use the following key:
                wmi.get[Root\LibreHardwareMonitor,"SELECT Value FROM Sensor WHERE SensorType='Temperature' AND name='CPU Package'"]
                Having the WMI Explorer allows you to test queries and make sure you have it correct before you use as a key in Zabbix Item.

                Also, if you prefer things in F instead of C, you can add preprocessing javascript step with paramerters of `return parseFloat(value) * 1.8 + 32;`
                Last edited by ryazur; 08-05-2024, 08:47.
            Working...