Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose more hardware information #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

zachstence
Copy link

Hi @marianob85!

I have recently been building Grafana dashboards for my homelab, and was having trouble getting data from my Windows workstation. I came across your repo, and it worked great! However I was wanting some more information about the hardware, so I implemented it in my fork.

The changes include:

  • Expose more information from OpenHardwareMonitor, including
    • Hardware
      • HardwareType
      • Identifier
      • InstanceId
      • Name
    • Sensor
      • Identifier
      • Index
      • InstanceId
      • Name
      • Parent
      • SensorType
      • Value
  • Change measurement name to open_hardware_monitor to match the input plugin name and module name
  • Don't modify Identifiers ( -> _, / -> _)
  • Prefix tags with Hardware_ or Sensor_ to distinguish Name, Identifier, etc
  • Enable filtering by hardware identifier and hardware type
  • Improve README docs
  • Unit tests for new functionality
  • Bumped build-version.txt to 2.0.0 due to breaking changes

I'm not sure how invested you are in this project, as it hasn't seen much activity for a while. I know that this PR introduces quite a few breaking changes, so I understand if you don't want to merge it. In that case, I'll just maintain my fork separately.

Let me know if you have any questions or suggested changes! 🚀

@zachstence
Copy link
Author

Also, I plan on making a Grafana dashboard to go with this plugin very soon. When I finish that I'll also add it to the repo!

@marianob85
Copy link
Owner

Wow. Thanks. Looks great. I will merge it soon.

}

var sensors []Sensor
sensors, err = p.QuerySensors()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it does not work well.
Using configuration file:

 [[inputs.open_hardware_monitor]]
 	HardwareType = ["GpuNvidia"] # optional

You are building sensor query using attribute "HardwareType" which is not available in Sensor query class:

It result with query error:

PS D:\Temp\ohm> .\open_hardware_monitor-telegraf-plugin.exe --config .\open_hardware_monitor-telegraf-plugin.config
2022/09/05 12:24:12 E! Error in plugin: Exception occurred. (Invalid query )

Analysing the source code, the wmi query looks like this:

Get-WmiObject -Namespace root/OpenHardwareMonitor -Query "SELECT * FROM SENSOR WHERE (HardwareType='GpuNvidia')"

which lead to an query error:

Get-WmiObject : Invalid query "SELECT * FROM SENSOR WHERE (HardwareType='GpuNvidia')"
At line:1 char:1
+ Get-WmiObject -Namespace root/OpenHardwareMonitor -Query "SELECT * FR ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

Sensor response for command:
Get-WmiObject -Namespace root/OpenHardwareMonitor -Query "SELECT * FROM SENSOR"
returns:

__GENUS          : 2
__CLASS          : Sensor
__SUPERCLASS     :
__DYNASTY        : Sensor
__RELPATH        : Sensor.InstanceId="3911",ProcessId="67ccdffb-07e7-45fc-bdb6-f017483b0a9f"
__PROPERTY_COUNT : 10
__DERIVATION     : {}
__SERVER         : MARIANO-PC
__NAMESPACE      : root\OpenHardwareMonitor
__PATH           : \\MARIANO-PC\root\OpenHardwareMonitor:Sensor.InstanceId="3911",ProcessId="67ccdffb-07e7-45fc-bdb6-f017483b0a9f"
Identifier       : /lpc/nct6798d/fan/1
Index            : 1
InstanceId       : 3911
Max              : 1032.11
Min              : 601.0685
Name             : Fan #2
Parent           : /lpc/nct6798d
ProcessId        : 67ccdffb-07e7-45fc-bdb6-f017483b0a9f
SensorType       : Fan
Value            : 611.6901
PSComputerName   : MARIANO-PC

So there is no "HardwareType" field.

@@ -0,0 +1,18 @@
[[inputs.open_hardware_monitor]]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this sample configuration file in etc\open_hardware_monitor-telegraf-plugin.config
Makefile script automatically pack it into zip file while generating github release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants