jackdeth999
May 25th, 2009, 12:13 AM
I am trying to get the Performance Monitor library to return CPU usage, but I keep getting the error "CPUUSAGE PdhAddCounter failed c0000bb8" when I run the command:
obj, err = win.CreatePerformanceMonitor(1000, 33, 1, "Laptop", "_Total", 2, nil);
print (obj)
print (err)
Result of print statements:
CPUUSAGE PdhAddCounter failed c0000bb8
nil
"Laptop" is the hostname of the system I'm on. To arrive at the parameters in the win.CreatePerformanceMonitor command, I used the following code:
objects,e = win.PerformanceMonitorListObjects( "Laptop", "100" )
table.print(objects)
-Snipped result of "objects" table:
[33] = "Processor"
counters, instances = win.PerformanceMonitorListObjectItems("Laptop", "Processor", "100")
table.print(counters)
table.print(instances)
-Snipped result of "counters" table:
[1] = "% Processor Time"
-Snipped result of "instances" table:
[2] = "_Total"
Can you tell me what I'm doing wrong here? It seems this should create a counter I can poll with obj.Read() that would give me the total CPU usage.
Thanks,
Ken
obj, err = win.CreatePerformanceMonitor(1000, 33, 1, "Laptop", "_Total", 2, nil);
print (obj)
print (err)
Result of print statements:
CPUUSAGE PdhAddCounter failed c0000bb8
nil
"Laptop" is the hostname of the system I'm on. To arrive at the parameters in the win.CreatePerformanceMonitor command, I used the following code:
objects,e = win.PerformanceMonitorListObjects( "Laptop", "100" )
table.print(objects)
-Snipped result of "objects" table:
[33] = "Processor"
counters, instances = win.PerformanceMonitorListObjectItems("Laptop", "Processor", "100")
table.print(counters)
table.print(instances)
-Snipped result of "counters" table:
[1] = "% Processor Time"
-Snipped result of "instances" table:
[2] = "_Total"
Can you tell me what I'm doing wrong here? It seems this should create a counter I can poll with obj.Read() that would give me the total CPU usage.
Thanks,
Ken