KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am monitoring some machines using WMI, using .NET's System.Management stuff. The query I am using is this: SELECT Timestamp_Sys100NS, PercentProcessorTime FROM Win32_PerfRawData_PerfOS_Processor WHERE Name='_Total' From that I compute the CPU usage % using the well known formula: double cpu_usage = (1 - (double)delta_cpu / delta_time) * 100; It works very well every machine but one (so far). The problem is that for one machine, which is Windows 2003 server (with hyper-threading enabled, if it matters), I am sometimes getting negative CPU usage values. In other words, the (double)delta_cpu / delta_time expression yields number > 1 . I did search the web for hints as to why this could be happening but I found nothing. Is this Windows 2003 server specific? Or is it hyper-threading related problem? Or is it just expected and I should just clamp the CPU usage value or the cpu_delta value into some range? EDIT: The second weird thing I am observing with this one machine is that the Timestamp_Sys100NS value does not indicate FILETIME like date (ticks since epoch January 1, 1600) but instead it looks like ticks since boot time. EDIT 2 : I have now verified that this problem is across a lot of Windows 2003 servers. And I am apparently not the only one with the same problem . EDIT 3 : I have solved the time stamp issue by querying LastBootUpTime from Win32_OperatingSystem and adding that to the Timestamp_Sys100NS when the value of Timestamp_Sys100NS is too far in the past. That seems to give correct date and time. The code manipulating the date after it is retrieved from Win32_OperatingSystem looks like this: Wbe
Tags (comma-separated)
Save Edits
Cancel