WMI, negative CPU usage value and Timestamp_Sys100NS in past

后端 未结 3 938
伪装坚强ぢ
伪装坚强ぢ 2021-02-05 09:10

I am monitoring some machines using WMI, using .NET\'s System.Management stuff. The query I am using is this:

SELECT Timestamp_Sys100NS, PercentProc         


        
3条回答
  •  既然无缘
    2021-02-05 09:38

    it sounds like a standard "time synchronization" issue to me.

    your system's clock is... a clock. in your case, your clock may be running fast (perhaps it completes a minute in 99% of the actual time) so when your computer syncs with an external clock (such as through the Windows Time service) your system time will jump backwards.

    alternatively, the user may manually adjust the system time (eg: Date and Time control panel), so it's something you should design for (your users would be very unhappy if setting their system's time crashes your app!)

    the way I solve this is by clamping. always require at least 0.0 seconds of "real time" to pass, but also clamp to a maximum of 0.5 seconds, as time adjustment may leap forwards, not only backwards.

    i hope that helps.

提交回复
热议问题