nickbabcock / OhmGraphite

Expose hardware sensor data to Graphite / InfluxDB / Prometheus / Postgres / Timescaledb
Other
411 stars 37 forks source link

Crash in x86 Win7sp1 Ultimate When Strart the OhmGraphite.exe #7

Closed Tea-NT closed 6 years ago

Tea-NT commented 6 years ago

Here is exception info:

Topshelf.HostFactory Error: 0 : An exception occurred creating the host, System.TypeInitializationException: The type initializer for 'OhmGraphite.Program' threw an exception. ---> System.MissingMethodException: Method not found: 'Int32 System.Environment.get_CurrentManagedThreadId()'. at NLog.LogFactory.d84..ctor(Int32 <>1state) at NLog.LogFactory.GetCandidateConfigFilePaths() at NLog.LogFactory.TryLoadFromFilePaths() at NLog.LogFactory.get_Configuration() at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey) at NLog.LogFactory.GetLogger(String name) at NLog.LogManager.GetCurrentClassLogger() at OhmGraphite.Program..cctor() --- End of inner exception stack trace --- at OhmGraphite.Program.<>c.\<Main>b1_1(ServiceConfigurator1 s) at Topshelf.ServiceExtensions.CreateServiceBuilderFactory[TService](Action1 callback) at Topshelf.ServiceExtensions.Service[TService](HostConfigurator configurator, Action1 callback) at OhmGraphite.Program.<>c.<Main>b__1_0(HostConfigurator x) at Topshelf.HostFactory.New(Action1 configureCallback) Topshelf.HostFactory Error: 0 : The service terminated abnormally, System.TypeInitializationException: The type initializer for 'OhmGraphite.Program' threw an exception. ---> System.MissingMethodException: Method not found: 'Int32 System.Environment.get_CurrentManagedThreadId()'. at NLog.LogFactory.d84..ctor(Int32 <>1state) at NLog.LogFactory.GetCandidateConfigFilePaths() at NLog.LogFactory.TryLoadFromFilePaths() at NLog.LogFactory.get_Configuration() at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey) at NLog.LogFactory.GetLogger(String name) at NLog.LogManager.GetCurrentClassLogger() at OhmGraphite.Program..cctor() --- End of inner exception stack trace --- at OhmGraphite.Program.<>c.\<Main>b1_1(ServiceConfigurator1 s) at Topshelf.ServiceExtensions.CreateServiceBuilderFactory[TService](Action1 callback) at Topshelf.ServiceExtensions.Service[TService](HostConfigurator configurator, Action1 callback) at OhmGraphite.Program.<>c.<Main>b__1_0(HostConfigurator x) at Topshelf.HostFactory.New(Action1 configureCallback) at Topshelf.HostFactory.Run(Action`1 configureCallback)

I tryed OhmGraphite.exe start ,OhmGraphite.exe run and OhmGraphite.exe install,all of them was not work. The OhmGraphite.exe work well in x64 Win7

Tea-NT commented 6 years ago

I installed .NET Framework 4.7.2 to solved the question, I think add the .NET Framework minimum version request in README.md file is batter. and thanks for your opensource code.

I google this page: System.MissingMethodException Int32 System.Environment. get_CurrentManagedThreadId() so i download the newest .NET Framework to try.it works.

nickbabcock commented 6 years ago

You're right, .NET 4.6 is required to run. Hopefully most people won't require downloading a newer version as Windows 10 includes it by default.

I'll close this when I've added it to the readme, thank you very much for your report.

Tea-NT commented 6 years ago

Yeah,you’re right,so i spend some time to solve it.

I deployed the OhmGraphite in my Intel Celeron J1800 CPU Clients,OhmGraphite can not collect the CPU temperature,only SSD temperature,if running Open Hardware Monitor it was fine.

温度采集 I want to try remote debugging to find out the reason,but there is not Remote debug checkbox in OhmGraphite project's Properties --Debug page with VS2017 .I am confused.

远程调试

After a few time.... There is a strange things happend,When i try anylized the log file,it change "Sent 8 metrics " to "Sent 15 metrics ",and the CPU temperture showing.

2018-07-20 11:01:41.6495|INFO||Sent 8 metrics in 13.2015ms
2018-07-20 11:01:46.6588|INFO||Sent 8 metrics in 14.1494ms
2018-07-20 11:01:51.6601|INFO||Sent 8 metrics in 15.629ms
2018-07-20 11:01:56.6894|INFO||Sent 8 metrics in 35.8582ms
2018-07-20 11:02:01.6747|INFO||Sent 8 metrics in 13.1045ms
2018-07-20 11:02:05.5229|INFO|Topshelf.Runtime.Windows.WindowsServiceHost|[Topshelf] Stopping
2018-07-20 11:02:05.5469|INFO|Topshelf.Runtime.Windows.WindowsServiceHost|[Topshelf] Stopped
2018-07-20 11:02:07.9400|INFO||Influxdb address: http://192.168.1.116:8086/ db: telegraf
2018-07-20 11:02:08.2201|INFO|Topshelf.HostFactory|Configuration Result:
[Success] Name OhmGraphite 

after i start OpenHardwareMonitor.exe and then restart the OhmGraphite service

[Success] Description Extract hardware sensor data and exports it to a given host and port in a graphite compatible format
[Success] ServiceName OhmGraphite
2018-07-20 11:02:08.2341|INFO|Topshelf.HostConfigurators.HostConfiguratorImpl|Topshelf v0.4.0.0, .NET Framework v4.0.30319.42000
2018-07-20 11:02:08.2671|INFO|Topshelf.Runtime.Windows.WindowsServiceHost|Starting as a Windows service
2018-07-20 11:02:08.3011|INFO|Topshelf.Runtime.Windows.WindowsServiceHost|[Topshelf] Starting
2018-07-20 11:02:10.9552|INFO|Topshelf.Runtime.Windows.WindowsServiceHost|[Topshelf] Started
2018-07-20 11:02:16.2085|INFO||Sent 15 metrics in 248.1669ms
2018-07-20 11:02:20.9928|INFO||Sent 15 metrics in 17.459ms
2018-07-20 11:02:26.0021|INFO||Sent 15 metrics in 18.6801ms
2018-07-20 11:02:31.0114|INFO||Sent 15 metrics in 18.2229ms
2018-07-20 11:02:36.0176|INFO||Sent 15 metrics in 20.8326ms
2018-07-20 11:02:41.0169|INFO||Sent 15 metrics in 11.3402ms

CPU temperature showing

I am more confused now.

nickbabcock commented 6 years ago

This should be fixed now on the master branch. Are you able to try it out? You seem savvy! If not, I can cut a pre-release version.

I did notice that I occasionally would have 70 or 71 metrics reported, and I didn't think much of it. I took a deeper look into how open hardware monitor uses its library and I found some inconsistencies between how I use it and the gui. I wouldn't think these inconsistencies would cause only some metrics to be detected on startup.

Anyways, the latest code successfully detects when new sensors are available. I saw that 5 minutes after starting I went from 70 metrics to 71 (why there is a such a delay in detection, I don't know)

Tea-NT commented 6 years ago

Thanks for your speedy response! Yesterday after I configed Grafana and then try see the code,our office and near street region was out of power because of a transformer failure(weather is too hot,in outside temperature may over 40℃ about 104℉ ),electricity power need a few days to restore.

I will test fast as i can.

nickbabcock commented 6 years ago

No worries, no rush 😄

Tea-NT commented 6 years ago

Hey! I think i find the reason,today i find the way to remote debug the OhmGraphite by use the Attach to Process in VS2017. First,copy the Remote Debuger in VS2017 \Common7\IDE\ from install folder to Client PC,then start the msvsmon.exe. After that,in debuger PC use the Attach to Process,input the remote client ip and select OhmGraphite Process. remote debug

All sensors was added through HardwareAdded event function,but next step in ReportedValues function two CPU temperature sensor and two others sensor(clock) has no values. temperature sensor has no temperature sensor has no values

that is why my client PC only sent 8 metrics.

I am a novice in .NET,and not familiar with Nlog,if the log output DEBUG message that don't need remot debug to find out that.


After check the code,if run OhmGraphite.exe direct,it actually detect 12 sensors,and 4 sensors has no values, so only sent 8 metrics(i runned the newest master code at least 20 minutes), i can exclude Topshelf service and the _computer.open() function in SensorCollector Class, i also don‘t think ReportedValues function effect to this situation.

sensor diff Left pic is only start OhmGraphite,right is start OhmGraphite after ohm startup.

I have no idea why it happened...>﹏<

nickbabcock commented 6 years ago

Left pic is only start OhmGraphite,right is start OhmGraphite after ohm startup.

Thank you for the info and all the debugging. That is certainly weird that OhmGraphite would see more metrics when ohm is running 😖

And just to triple check, are you running OhmGraphite and ohm as administrator?

Tea-NT commented 6 years ago

Yes,ohm need administrator permission when startup,each time i also tested Right Click -- Run As Administrator option to run OhmGraphite.exe. Still the same result.

It look ohm activated the others sensors.After OhmGraphite startup whth ohm. Even close the ohm, OhmGraphite also work fine,it sent 15 metrics. If then restart OhmGraphite,change back to sent 8 metrics.

nickbabcock commented 6 years ago

Yes this is very puzzling. I just uncovered the opposite scenario: sensor values in OhmGraphite but absent in ohm report.


Not sure how much this would help, but you can set Nlog.config to have these lines (eg. set to "Debug" instead of "Info")

  <rules>
    <logger name="*" minlevel="Debug" writeTo="file" />
    <logger name="*" minlevel="Debug" writeTo="console" />
  </rules>

You'll get more output which could lead to more insights. I also pushed some more code to mirror ohm more closely, but it was minor and probably only a 5% chance that it would help 😄

Tea-NT commented 6 years ago

Ok,I give up,Thanks your response anyway.

I tried add a app.manifest file in OhmGraphite Project to request Administrator permission,it failed. the last way only start OhmGraphite in Windows Services set Automatict(Delayed Start),wait ohm startup.

nickbabcock commented 6 years ago

Ah shoot, yeah it's a bummer.

I'll close this issue, but if anyone wants to continue working on this issue (or has this issue), feel free to respond (or open a new issue).