Prometheus Adapter for HWiNFO (+ Grafana Dashboard)

Hope this is ok to ask, I'm still struggling setting up a dashboard.. is anyone willing to help me set one up? I'll happily pay.. please PM to discuss.

I have a basic dashboard working fine, it's just some some data querying I am having trouble with.. so I can see the realtime stats of 3 servers, but I want to show total power use over a certain time period etc.

Thanks!
 
Hope this is ok to ask, I'm still struggling setting up a dashboard.. is anyone willing to help me set one up? I'll happily pay.. please PM to discuss.

I have a basic dashboard working fine, it's just some some data querying I am having trouble with.. so I can see the realtime stats of 3 servers, but I want to show total power use over a certain time period etc.

Thanks!

I don't have experience of that kind of aggregating yet, but I think I'm looking to get something similar with WMI cpu and memory loads. I'll report back if I get experienced enough to have some/any idea about such calculations.
 
Hi guys! Can't find any solution to my problem related to setting up promAdapter on my laptop. The problem is that http://localhost:10445/metrics page display error text (log below). I already tried to change config in ProgramData, restarting all related services, resetting config through metrics/reset, reloading hwi and reloading machine. metrics/debugerror returns absolutely same error. Also .NET packages and c++ redis of all versions are installed. Hope someone can help me:)
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'MaxDegreeOfParallelism') at System.Threading.Tasks.ParallelOptions.set_MaxDegreeOfParallelism(Int32 value) at PrometheusProcessor.ServiceProcessor.<>c__DisplayClass23_0.<<InitializeProcessors>b__2>d.MoveNext() --- End of stack trace from previous location --- at PromDapterSvc.Controllers.MetricsController.getPrometheusContent(String filter, Dictionary`2 paramDictionary) at PromDapterSvc.Controllers.MetricsController.Get(String filter, String option)
 
I can help you :) . It seems there's a bug in the calculation of parallelism. I get to check this after the weekend, sorry that you have to wait.

It seems your installation and setup is all good, the degree of parallelism is based on the cores and/or total amount of metrics and there apparently seems to be some corner cases, that crash it out.
 
I can help you :) . It seems there's a bug in the calculation of parallelism. I get to check this after the weekend, sorry that you have to wait.

It seems your installation and setup is all good, the degree of parallelism is based on the cores and/or total amount of metrics and there apparently seems to be some corner cases, that crash it out.
Ok, thanks a lot!
 
I released quick attempt for the fix. Can you test the newest release and report back, if the error is still there.

Yep, it works! But the port changed to 10446 instead of 10445.
Thanks for the fast response :^)

Code:
 TCP    0.0.0.0:10446          Win-Laptop:0           LISTENING
 [PromDapterSvc.exe]
 
@Kallex very cool adapter. Just got a new AMD laptop and I'm like, how the hell am I going to tune this thing without an on-screen display.

I can see how the setup process is complicated for people not used to Grafana, etc. Having developed adapters for industrial equipment, my suggestion would be to change the adapter to output MQTT. Grafana and InfluxDb both support MQTT ingress now. Grafana+MQTT for real-time only, and InfluxDb+MQTT for historical. With some client side deadband settings, this could scale to a lot of users.
 
@Kallex very cool adapter. Just got a new AMD laptop and I'm like, how the hell am I going to tune this thing without an on-screen display.

I can see how the setup process is complicated for people not used to Grafana, etc. Having developed adapters for industrial equipment, my suggestion would be to change the adapter to output MQTT. Grafana and InfluxDb both support MQTT ingress now. Grafana+MQTT for real-time only, and InfluxDb+MQTT for historical. With some client side deadband settings, this could scale to a lot of users.
Hey, what a cool suggestion!

I checked the MQTT specs and available .NET libraries and I think it is small effort to add support for MQTT. I can try to add it in the near-ish future, but of course if someone wants to submit a pull request for that, it's also OK :-).
 
Hey, what a cool suggestion!

I checked the MQTT specs and available .NET libraries and I think it is small effort to add support for MQTT. I can try to add it in the near-ish future, but of course if someone wants to submit a pull request for that, it's also OK :).

I hear you. I wish I had time to help with the code.

https://github.com/dotnet/MQTTnet is a solid .NET library for client and broker. Moqsuitto is a great standalone broker.

I'm not sure MQTT support for Grafana has been released yet. Last time I had to build it myself. https://github.com/grafana/mqtt-datasource

I saw an announcement for InfluxDb native MQTT: https://www.businesswire.com/news/h...ata-Brings-Native-Data-Collection-to-InfluxDB

But I can't find more details. The way I get MQTT data into InfluxDb is https://github.com/influxdata/telegraf/blob/master/plugins/inputs/mqtt_consumer/README.md

And actually, if you're already spitting out Prometheus format, then Telegraf should be a pretty good drop in https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md

Screenshot 2022-09-11 142757.png
 
Last edited:
Here is a Powershell script around your provider code.

Bash:
# prep
#   install powershell 7
#       winget install --id Microsoft.Powershell --source winget
#   allow script execution
#       Set-ExecutionPolicy -ExecutionPolicy Unrestricted
#   VSCode should show version 7
#       $PSVersionTable
Clear-Host 
New-Item -Path $HOME\hwinfo_adapter -ItemType Directory -ErrorAction SilentlyContinue;
Set-Location -Path $HOME\hwinfo_adapter;
$sources = [ordered]@{
    source = @{
        uri = "https://raw.githubusercontent.com/kallex/PromDapterHWiNFO/master/PromDapterDeclarations/Source.cs";
        output = "PromDapterDeclarations.Source.dll";
    };
    data_value = @{
        uri = "https://raw.githubusercontent.com/kallex/PromDapterHWiNFO/master/PromDapterDeclarations/DataValue.cs";
        output = "PromDapterDeclarations.DataValue.dll";
    };
    data_item = @{
        uri = "https://raw.githubusercontent.com/kallex/PromDapterHWiNFO/master/PromDapterDeclarations/DataItem.cs";
        output = "PromDapterDeclarations.DataItem.dll";
    };
    service_iface = @{
        uri = "https://raw.githubusercontent.com/kallex/PromDapterHWiNFO/master/PromDapterDeclarations/IPromDapterService.cs";
        output = "PromDapterDeclarations.IPromDapterService.dll";
    };
    service_impl = @{
        uri = "https://raw.githubusercontent.com/kallex/PromDapterHWiNFO/master/HWiNFODataProvider/HWiNFOProvider.cs";
        output = "SensorMonHTTP.HWiNFOProvider.dll";
    };
};
$references = [System.Collections.ArrayList]@(
    "System.Core", 
    "System.Collections", 
    "System.IO.MemoryMappedFiles", 
    "System.Linq");
foreach ($key in $sources.Keys) 
{
    $item = $sources[$key];
    Write-Host "`t$($key)"
    Write-Host "`t`tDownload source.";
    $response = Invoke-WebRequest -Uri $item["uri"];
    $source = $response.Content;
    
    Write-Host "`t`tCreate .NET type.";
    $path = Join-Path -Path $(Get-Location) -ChildPath $item["output"];
    Remove-Item -Path $path -ErrorAction SilentlyContinue;
    Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly $path -OutputType Library -ReferencedAssemblies $references -IgnoreWarnings -PassThru;
    $references.Add($path) | Out-Null;
}
Write-Host "`n`tCreate wrapper instance.";
$wrapper = New-Object -TypeName SensorMonHTTP.HWiNFOProvider;
$wrapper.Open.Invoke();
$data = $wrapper.GetDataItems.Invoke().GetAwaiter().GetResult();
$psdata = $data | Select-Object `
    @{Name='Source';Expression={$_.Source.SourceName};}, `
    Name, `
    @{Name='Value';Expression={$_.Value.Object};}, `
    Unit, `
    @{Name='Category';Expression={$_.Category};}
$psdata | Format-Table
$psdata | Out-GridView
$wrapper.Close.Invoke();

Code:
Source                                               Name                                                     Value Unit
------                                               ----                                                     ----- ----
System: ASUS ROG Zephyrus G14 GA402RJ_GA402RJ        Virtual Memory Committed                                 12469 MB
System: ASUS ROG Zephyrus G14 GA402RJ_GA402RJ        Virtual Memory Available                                 11846 MB
System: ASUS ROG Zephyrus G14 GA402RJ_GA402RJ        Virtual Memory Load                                       51.2 %
System: ASUS ROG Zephyrus G14 GA402RJ_GA402RJ        Physical Memory Used                                      6759 MB
System: ASUS ROG Zephyrus G14 GA402RJ_GA402RJ        Physical Memory Available                                 8852 MB
System: ASUS ROG Zephyrus G14 GA402RJ_GA402RJ        Physical Memory Load                                      43.2 %
System: ASUS ROG Zephyrus G14 GA402RJ_GA402RJ        Page File Usage                               3.12715418198529 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 0 VID                                               1.465 V
CPU [#0]: AMD Ryzen 9 6900HS                         Core 1 VID                                                1.45 V
CPU [#0]: AMD Ryzen 9 6900HS                         Core 2 VID                                                1.45 V
CPU [#0]: AMD Ryzen 9 6900HS                         Core 3 VID                                                1.45 V
CPU [#0]: AMD Ryzen 9 6900HS                         Core 4 VID                                                1.45 V
CPU [#0]: AMD Ryzen 9 6900HS                         Core 5 VID                                                1.45 V
CPU [#0]: AMD Ryzen 9 6900HS                         Core 6 VID                                                1.45 V
CPU [#0]: AMD Ryzen 9 6900HS                         Core 7 VID                                                1.45 V
CPU [#0]: AMD Ryzen 9 6900HS                         Core 0 Clock (perf #2/)                       4810.37429073951 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 1 Clock (perf #1/)                       3282.07829211914 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 2 Clock (perf #3/)                       3282.07829211914 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 3 Clock (perf #6/)                       3282.07829211914 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 4 Clock (perf #4/)                       3282.07829211914 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 5 Clock (perf #7/)                       3282.07829211914 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 6 Clock (perf #5/)                       3282.07829211914 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 7 Clock (perf #8/)                       3282.07829211914 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Bus Clock                                     100.216131057073 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 0 T0 Effective Clock                     967.892883300781 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 0 T1 Effective Clock                     476.545337924948 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 1 T0 Effective Clock                     752.127294428884 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 1 T1 Effective Clock                      272.45550737156 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 2 T0 Effective Clock                     352.247171944307 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 2 T1 Effective Clock                     251.596558952757 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 3 T0 Effective Clock                      44.596532433681 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 3 T1 Effective Clock                     41.2388756322904 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 4 T0 Effective Clock                     221.875366433011 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 4 T1 Effective Clock                     191.846927878884 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 5 T0 Effective Clock                     27.4648685451495 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 5 T1 Effective Clock                     26.4218597473796 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 6 T0 Effective Clock                     73.7891520557069 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 6 T1 Effective Clock                     119.974528268864 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 7 T0 Effective Clock                     20.5766423033784 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 7 T1 Effective Clock                     18.0619329061826 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Average Effective Clock                       241.169465007985 MHz
CPU [#0]: AMD Ryzen 9 6900HS                         Core 0 T0 Usage                                           13.8 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 0 T1 Usage                                            6.1 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 1 T0 Usage                                             20 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 1 T1 Usage                                            6.9 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 2 T0 Usage                                             10 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 2 T1 Usage                                            4.6 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 3 T0 Usage                                            1.5 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 3 T1 Usage                                              0 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 4 T0 Usage                                              3 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 4 T1 Usage                                            6.1 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 5 T0 Usage                                            1.5 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 5 T1 Usage                                              0 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 6 T0 Usage                                            1.5 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 6 T1 Usage                                            2.3 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 7 T0 Usage                                              0 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 7 T1 Usage                                              0 %
CPU [#0]: AMD Ryzen 9 6900HS                         Max CPU/Thread Usage                                        20 %
CPU [#0]: AMD Ryzen 9 6900HS                         Total CPU Usage                                        4.83125 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 0 T0 Utility                              15.514744546967 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 0 T1 Utility                              14.162183311522 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 1 T0 Utility                             22.4346484035122 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 1 T1 Utility                             8.00978076693708 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 2 T0 Utility                             10.4575773017779 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 2 T1 Utility                             7.39056178250797 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 3 T0 Utility                             1.23150114380374 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 3 T1 Utility                              1.1199448765046 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 4 T0 Utility                             6.23845588316497 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 4 T1 Utility                             5.63133507506484 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 5 T0 Utility                            0.755732603405366 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 5 T1 Utility                            0.705972372099481 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 6 T0 Utility                              2.0543123631384 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 6 T1 Utility                             3.47949363573831 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 7 T0 Utility                            0.562148922659451 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 7 T1 Utility                             0.45272993322579 %
CPU [#0]: AMD Ryzen 9 6900HS                         *Total CPU Utility                            6.26213273634007 %
CPU [#0]: AMD Ryzen 9 6900HS                         Core 0 Ratio                                                48 x
CPU [#0]: AMD Ryzen 9 6900HS                         Core 1 Ratio                                             32.75 x
CPU [#0]: AMD Ryzen 9 6900HS                         Core 2 Ratio                                             32.75 x
CPU [#0]: AMD Ryzen 9 6900HS                         Core 3 Ratio                                             32.75 x
CPU [#0]: AMD Ryzen 9 6900HS                         Core 4 Ratio                                             32.75 x
CPU [#0]: AMD Ryzen 9 6900HS                         Core 5 Ratio                                             32.75 x
CPU [#0]: AMD Ryzen 9 6900HS                         Core 6 Ratio                                             32.75 x
CPU [#0]: AMD Ryzen 9 6900HS                         Core 7 Ratio                                             32.75 x
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Package C6 Residency                                         0 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 0 C0 Residency                           22.7541255950928 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 1 C0 Residency                           23.0968112945557 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 2 C0 Residency                           14.3191156387329 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 3 C0 Residency                           1.57580482959747 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 4 C0 Residency                           9.23273658752441 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 5 C0 Residency                          0.951142489910126 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 6 C0 Residency                           4.22052717208862 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 7 C0 Residency                          0.643017888069153 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 0 C1 Residency                           77.2458343505859 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 1 C1 Residency                           76.9032211303711 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 2 C1 Residency                           71.5608825683594 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 3 C1 Residency                           10.0295429229736 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 4 C1 Residency                           90.7672653198242 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 5 C1 Residency                           3.82043194770813 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 6 C1 Residency                           61.3139495849609 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 7 C1 Residency                           1.95260310173035 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 0 C6 Residency                                          0 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 1 C6 Residency                                          0 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 2 C6 Residency                           14.3730278015137 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 3 C6 Residency                           88.8222732543945 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 4 C6 Residency                                          0 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 5 C6 Residency                           95.5749893188477 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 6 C6 Residency                            34.753475189209 %
CPU [#0]: AMD Ryzen 9 6900HS: C-State Residency      Core 7 C6 Residency                           97.8610534667969 %
Memory Timings                                       *Memory Clock                                             2400 MHz
Memory Timings                                       Memory Clock Ratio                                          24 x
Memory Timings                                       Tcas                                                        40 T
Memory Timings                                       Trcd                                                        39 T
Memory Timings                                       Trp                                                         39 T
Memory Timings                                       Tras                                                        77 T
Memory Timings                                       Trc                                                        116 T
Memory Timings                                       Trfc                                                       710 T
Memory Timings                                       Command Rate                                                 1 T
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               *CPU (Tctl/Tdie)                                         48.25 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU Core                                      48.1524620056152 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU SOC                                       45.4793434143066 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               APU GFX                                       41.3664436340332 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU Skin Temperature                          31.4835453033447 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core0                                         47.5742607116699 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core1                                         42.7298812866211 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core2                                         46.9044380187988 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core3                                         40.5208587646484 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core4                                          46.179141998291 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core5                                         40.1584320068359 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core6                                         44.9378700256348 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core7                                         39.9599113464355 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               L3 Cache                                      46.4319534301758 °C
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               *CPU VDDCR_VDD Voltage (SVI3 TFN)             1.19591045379639 V
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU VDDCR_SOC Voltage (SVI3 TFN)              1.02410435676575 V
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU VDDCR_SR Voltage (SVI3 TFN)               1.03425192832947 V
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU Core Current (SVI2 TFN)                   10.4872779846191 A
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               SoC Current (SVI2 TFN)                        3.38117599487305 A
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU TDC                                       10.1237325668335 A
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU EDC                                       106.022003173828 A
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               *CPU Package Power                            20.3225399754972 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core 0 Power                                  1.91760754585266 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core 1 Power                                  1.92519950480102 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core 2 Power                                  1.33820961513791 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core 3 Power                                 0.213301508805273 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core 4 Power                                  1.13941842213073 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core 5 Power                                  0.11631754263766 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core 6 Power                                 0.705476532189879 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core 7 Power                                0.0780721633356791 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU Core Power (SVI2 TFN)                     14.0565614700317 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU SoC Power (SVI2 TFN)                      3.46167731285095 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Core+SoC+SR Power (SVI3 TFN)                  18.0358123779297 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               *CPU PPT                                      14.0312404632568 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               APU STAPM                                      17.393518447876 W
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Infinity Fabric Clock (FCLK)                              1800 MHz
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Memory Controller Clock (UCLK)                            1200 MHz
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               L3 Cache                                      4086.68565750122 MHz
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Frequency Limit - Global                      4825.87766647339 MHz
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU PPT Limit                                 38.9756679534912 %
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU TDC Limit                                 15.5749731797438 %
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU EDC Limit                                 75.7300022670201 %
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU PPT FAST Limit                              20.23899269104 %
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               CPU PPT SLOW Limit                            16.7038555145264 %
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               APU STAPM Limit                               17.3935165405273 %
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Thermal Limit                                 58.7225151062012 %
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Thermal Throttling (HTC)                                     0 Yes/No
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Thermal Throttling (PROCHOT CPU)                             0 Yes/No
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Thermal Throttling (PROCHOT EXT)                             0 Yes/No
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               DRAM Read Bandwidth                           3.60738110542297 Gbps
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               DRAM Write Bandwidth                          1.00867581367493 Gbps
CPU [#0]: AMD Ryzen 9 6900HS: Enhanced               Average Active Core Count                      0.7679323554039
S.M.A.R.T.: Micron_2450_MTFDKBA1T0TFK (2147334516DB) Drive Temperature                                           40 °C
S.M.A.R.T.: Micron_2450_MTFDKBA1T0TFK (2147334516DB) Drive Remaining Life                                       100 %
S.M.A.R.T.: Micron_2450_MTFDKBA1T0TFK (2147334516DB) Drive Failure                                                0 Yes/No
S.M.A.R.T.: Micron_2450_MTFDKBA1T0TFK (2147334516DB) Drive Warning                                                0 Yes/No
S.M.A.R.T.: Micron_2450_MTFDKBA1T0TFK (2147334516DB) Total Host Writes                                         1454 GB
S.M.A.R.T.: Micron_2450_MTFDKBA1T0TFK (2147334516DB) Total Host Reads                                          1210 GB
Drive: Micron_2450_MTFDKBA1T0TFK (2147334516DB)      Read Activity                                            0.031 %
Drive: Micron_2450_MTFDKBA1T0TFK (2147334516DB)      Write Activity                                           0.053 %
Drive: Micron_2450_MTFDKBA1T0TFK (2147334516DB)      Total Activity                                           0.085 %
Drive: Micron_2450_MTFDKBA1T0TFK (2147334516DB)      Read Rate                                                0.096 MB/s
Drive: Micron_2450_MTFDKBA1T0TFK (2147334516DB)      Write Rate                                               0.111 MB/s
Drive: Micron_2450_MTFDKBA1T0TFK (2147334516DB)      Read Total                                              241055 MB
Drive: Micron_2450_MTFDKBA1T0TFK (2147334516DB)      Write Total                                             236883 MB
GPU [#0]: AMD Radeon 600M series:                    GPU Temperature                               41.3664436340332 °C
GPU [#0]: AMD Radeon 600M series:                    GPU Core Voltage (VDDCR_GFX)                 0.759027183055878 V
GPU [#0]: AMD Radeon 600M series:                    GPU SoC Power (VDDCR_SOC)                                    3 W
GPU [#0]: AMD Radeon 600M series:                    GPU ASIC Power                                              18 W
GPU [#0]: AMD Radeon 600M series:                    GPU Clock                                                  400 MHz
GPU [#0]: AMD Radeon 600M series:                    GPU Clock (Effective)                         433.176025390625 MHz
GPU [#0]: AMD Radeon 600M series:                    GPU Memory Clock                                          2400 MHz
GPU [#0]: AMD Radeon 600M series:                    GPU SoC Clock                                              400 MHz
GPU [#0]: AMD Radeon 600M series:                    GPU VCN Clock                                               12 MHz
GPU [#0]: AMD Radeon 600M series:                    GPU Utilization                                              0 %
GPU [#0]: AMD Radeon 600M series:                    GPU D3D Usage                                 23.7666586552254 %
GPU [#0]: AMD Radeon 600M series:                    GPU Video Decode 0 Usage                                     0 %
GPU [#0]: AMD Radeon 600M series:                    GPU Video Decode 1 Usage                                     0 %
GPU [#0]: AMD Radeon 600M series:                    GPU Video Encode 0 Usage                                     0 %
GPU [#0]: AMD Radeon 600M series:                    GPU Computing (High Priority Compute) Usage                  0 %
GPU [#0]: AMD Radeon 600M series:                    GPU Computing (Compute 3) Usage                              0 %
GPU [#0]: AMD Radeon 600M series:                    GPU Computing (Compute 0) Usage                              0 %
GPU [#0]: AMD Radeon 600M series:                    GPU Computing (Compute 1) Usage                              0 %
GPU [#0]: AMD Radeon 600M series:                    GPU D3D Memory Dedicated                              431.6875 MB
GPU [#0]: AMD Radeon 600M series:                    GPU D3D Memory Dynamic                             400.5859375 MB
GPU [#0]: AMD Radeon 600M series:                    PCIe Link Speed                                             16 GT/s
GPU [#0]: AMD Radeon 600M series:                    GPU Memory Usage                                           880 MB
GPU [#0]: AMD Radeon 600M series:                    Throttle Reason - Power                                      0 Yes/No
GPU [#0]: AMD Radeon 600M series:                    Throttle Reason - Thermal                                    0 Yes/No
GPU [#0]: AMD Radeon 600M series:                    Throttle Reason - Current                                    0 Yes/No
GPU [#0]: AMD Radeon 600M series:                    Framerate                                                    0 FPS
Battery: ASUSTeK ASUS Battery                        Battery Voltage                                         15.933 V
Battery: ASUSTeK ASUS Battery                        Remaining Capacity                                      62.218 Wh
Battery: ASUSTeK ASUS Battery                        Charge Level                                  80.2667905152618 %
Battery: ASUSTeK ASUS Battery                        Wear Level                                                   0 %
RTSS                                                 Framerate                                     56.4000015258789 FPS
RTSS                                                 Frame Time                                             112.583 ms
Network: MediaTek, Device ID: 7922                   Total DL                                      16661.1272783279 MB
Network: MediaTek, Device ID: 7922                   Total UP                                      855.209715843201 MB
Network: MediaTek, Device ID: 7922                   Current DL rate                               1.50068979414683 KB/s
Network: MediaTek, Device ID: 7922                   Current UP rate                               1.27011253720238 KB/s
Windows Hardware Errors (WHEA)                       Total Errors                                                 0
 
Last edited:
And here it is with MQTT output. I think the topic structure needs more work to adhere to a model that is consumable regardless of what PC you're running.

Screenshot 2022-09-18 182450.png

Bash:
#
# prep
#   install powershell 7
#       winget install --id Microsoft.Powershell --source winget
#   allow script execution
#       Set-ExecutionPolicy -ExecutionPolicy Unrestricted
#   VSCode should show version 7
#       $PSVersionTable
Clear-Host
$myid = get-wmiobject Win32_ComputerSystemProduct  | Select-Object -ExpandProperty UUID;
$verbose = $true;
$sleep_ms = 1000;
$mqtt_broker = "test.mosquitto.org";
$mqtt_clientid = New-Guid;
Write-Warning "My ID = '$($myid)'.";
# Create working folder
$working_path = "$($HOME)\hwinfo_adapter";
Write-Host "Creating working folder '$($working_path)'.";
New-Item -Path $working_path -ItemType Directory -ErrorAction SilentlyContinue;
Set-Location -Path $working_path;
# Download Nuget
$nuget_bin = "$($working_path)\nuget.exe";
$nuget_uri = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe";
if((Test-Path -Path $nuget_bin -PathType Leaf) -eq $false) {
    Write-Host "Downloading Nuget binary.";
    $progressPreference = 'silentlyContinue';
    Invoke-WebRequest -Uri $nuget_uri -OutFile $nuget_bin;
    $progressPreference = 'continue';
}
# Install MQTT library
$mqtt_bin = "$($working_path)\MQTTnet.4.1.0.247\lib\net6.0\MQTTnet.dll";
$mqtt_install = "$($working_path)\nuget.exe install MQTTnet -Version 4.1.0.247 -o $working_path";
if((Test-Path -Path $mqtt_bin -PathType Leaf) -eq $false) {
    Write-Host "Installing MQTT library.";
    Invoke-Expression $mqtt_install | Out-Null;
}
Add-Type -Path $mqtt_bin;
# Define sources for hwinfo adapter build
$source_base = "https://raw.githubusercontent.com/kallex/PromDapterHWiNFO/master";
$sources = [ordered]@{
    source = @{
        uri = "$($source_base)/PromDapterDeclarations/Source.cs";
        output = "PromDapterDeclarations.Source.dll";
    };
    data_value = @{
        uri = "$($source_base)/PromDapterDeclarations/DataValue.cs";
        output = "PromDapterDeclarations.DataValue.dll";
    };
    data_item = @{
        uri = "$($source_base)/PromDapterDeclarations/DataItem.cs";
        output = "PromDapterDeclarations.DataItem.dll";
    };
    service_iface = @{
        uri = "$($source_base)/PromDapterDeclarations/IPromDapterService.cs";
        output = "PromDapterDeclarations.IPromDapterService.dll";
    };
    service_impl = @{
        uri = "$($source_base)/HWiNFODataProvider/HWiNFOProvider.cs";
        output = "SensorMonHTTP.HWiNFOProvider.dll";
    };
};
# .NET references to include when building
$references = [System.Collections.ArrayList]@(
    "System.Core",
    "System.Collections",
    "System.IO.MemoryMappedFiles",
    "System.Linq");
# Download and compile each source
Write-Host "Compiling sources.";
foreach ($key in $sources.Keys)
{
    $item = $sources[$key];
    Write-Host "`t'$($key)': Downloading.";
    $response = Invoke-WebRequest -Uri $item.uri -SkipHttpErrorCheck;
    if ($response.StatusCode -ne 200) {
        Write-Error "Unable to download '$($item.uri)'."
        exit;
    }
    $source = $response.Content;
    Write-Host "`t'$($key)': Compiling.";
    $path = Join-Path -Path $(Get-Location) -ChildPath $item.output;
    Remove-Item -Path $path -ErrorAction SilentlyContinue;
    try {
        Add-Type -TypeDefinition $source `
            -Language CSharp `
            -OutputAssembly $path `
            -OutputType Library `
            -ReferencedAssemblies $references `
            -IgnoreWarnings -PassThru -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null;
    } catch {
        Write-Error $_.Exception.Message;
        exit;
    }
    # Add compiled source as a reference for the next source
    $references.Add($path) | Out-Null;
}
# Create hwinfo adapter instance
Write-Host "Creating instance.";
$wrapper = New-Object -TypeName SensorMonHTTP.HWiNFOProvider;
# Open hwinfo shared memory
Write-Host "Opening HWINFO shared memory.";
if($wrapper.Open.Invoke().IsFaulted -eq $true) {
    Write-Error "Unable to access HWINFO shared memory.";
    exit;
}
# Create and connect MQTT client
Write-Host "Creating MQTT client.";
$mqtt_factory = [MQTTnet.MqttFactory]::new();
$mqtt_client = $mqtt_factory.CreateMqttClient();
$mqtt_options = [MQTTnet.Client.MqttClientOptionsBuilder]::new(). `
    WithTcpServer($mqtt_broker). `
    WithCleanSession($true). `
    WithClientId($mqtt_clientid). `
    Build();
try {
    $mqtt_client.ConnectAsync($mqtt_options).GetAwaiter().GetResult() | Out-Null ;
} catch {
    Write-Error "MQTT connection failed.";
    exit;
}
# Define function to combine data item source and name into a MQTT-able topic
function build_metric {
    param( $data_item )
    # remove leading and trailing spaces
    # remove forward slashes
    # remove dollar signs
    # join array with forward slash
    # remove trailing slash
    $src = $data_item.Source `
            -split ':' `
            -replace '^\s+|\s+$' `
            -replace '/' `
            -replace '$' `
            -join '/' `
            -replace '/$';
    # remove forward slashes
    $name = $data_item.Name `
            -replace '/';
    # remove pound signs
    # remove periods
    # remove asterisk
    # replace plus with underscore
    $metric = "hwinfo/$($myid)/$($src)/$($name)" `
        -replace '#' `
        -replace '\.' `
        -replace '\*' `
        -replace '\+','_';
    return $metric
};
# Run data collection loop
$last_known_mqdata = @{};
Write-Host "Terminate with 'x'.";
while($true)
{
    if($verbose -eq $true) {
        Write-Host "Retrieving HWINFO shared memory.";
    }
    $data = $wrapper.GetDataItems.Invoke().GetAwaiter().GetResult();
    # Create flat data item view that can be displayed by powershell
    $psdata = $data | Select-Object `
        @{Name='Source';Expression={$_.Source.SourceName};}, `
        Name,
        @{Name='Value';Expression={$_.Value.Object};}, `
        Unit, `
        @{Name='Category';Expression={$_.Category};}, `
        Timestamp;
   
    #$psdata | Format-Table
    #$psdata | Out-GridView
    # TODO: publish changed metrics only
    # Transform data items for MQTT
    $current_mqdata = $psdata | Select-Object `
        @{Name='Topic';Expression={ build_metric($_) }}, `
        @{Name='Payload';Expression={
            @{
                category=$_.Category;
                value=[math]::Round($_.Value, 3);
                unit=$_.Unit;
                ts=Get-Date -UFormat %s
            }
        }};
    # Publish to MQTT broker
    if($verbose -eq $true) {
        Write-Host "Publishing metrics.";
    }
    $pub_count = 0;
    foreach ($metric in $current_mqdata) {
        $publish = $false;
        $publish_reason = "";
        $find = $last_known_mqdata | Where-Object { $_.Topic -eq $metric.Topic };
        if ($find.Count -eq 0) {
            $publish = $true;
            $publish_reason = "new metric";
        }
        elseif ($find[0].Payload.value -ne $metric.Payload.value) {
            $publish = $true;
            $publish_reason = "value changed, old value = '$($find[0].Payload.value)'";
        }
        if($publish -eq $true) {
            $pub_count += 1;
            if($verbose -eq $true) {
                Write-Host "Publishing '$($metric.Topic)' = '$($metric.Payload.value)' reason: $($publish_reason).";
            }
            $message = [MQTTnet.MqttApplicationMessageBuilder]::new(). `
                WithTopic($metric.Topic). `
                WithPayload(($metric.Payload | ConvertTo-Json -Depth 4)). `
                WithRetainFlag(). `
                Build();
            $mqtt_client.PublishAsync($message).GetAwaiter().GetResult() | Out-Null;
        }
    }
    # TODO: verify this works correctly
    $last_known_mqdata = $current_mqdata.Clone();
    Write-Host "Published '$($pub_count)' metrics.";
    # Check if we should terminate loop
    if ([console]::KeyAvailable)
    {
        $key = [system.console]::readkey($true)
        if ($key.key -eq "x")
        {
            Write-Host "Terminated by user."
            break;
        }
    }
    Start-Sleep -Milliseconds $sleep_ms;
}
# Cleanup
Start-Sleep 1;
Write-Host "Closing HWINFO shared memory.";
$wrapper.Close.Invoke().GetAwaiter().GetResult() | Out-Null;
Write-Host "Disconnecting MQTT client.";
$mqtt_disc_options = [MQTTnet.Client.MqttClientDisconnectOptionsBuilder]::new().Build();
$mqtt_client.DisconnectAsync($mqtt_disc_options).GetAwaiter().GetResult() | Out-Null;
 
Last edited:
Thanks, I guess I'm running out of excuses here :) . I'll implement those parts into the adapter directly, with some configurable repeatable push for MQTT endpoint. I try to do it in near future/this week (weekend included).
 
Hey so I might be dumb but I'm trying to get this setup, I have promdapter installed localhost:10445/metrics shows me information I can curl that information on my prometheus/grafana docker host but when I try and start the container with the line targets: ["http://192.168.1.16:10445/metrics"] I get the error log:


Code:
2022-12-12 10:23:06 p.m.
ts=2022-12-13T05:23:06.578Z caller=main.go:468 level=error msg="Error loading config (--config.file=/etc/prometheus/prometheus.yml)" file=/etc/prometheus/prometheus.yml err="parsing YAML file /etc/prometheus/prometheus.yml: \"http://192.168.1.16:10445/metrics\" is not a valid hostname"

my prometheus.yml looks like

YAML:
global:
  scrape_interval: 15s

scrape_configs:
  -  job_name: "HWinfo Desk"
     scrape_interval: 10s
     static_configs:
     -  targets: ["http://192.168.1.16:10445/metrics"]

what am I doing wrong?

*EDIT* I have fixed it:

YAML:
 -  targets: ["192.168.1.16:10445"]
 
Last edited:
Just for some status report of not releasing anything. I've been busy elsewhere, but I'm still on the MQTT implementation. It requires bit of refactoring of the existing codebase, so it wasn't as trivial to add as I initially thought.

I hope to finish it soon-ish.
 
Back
Top