views:

204

answers:

2

I don't want the list of all process, just a total percentage like you would see in windows taskmanager.

I will be using this information via coldfusion, but i am having all kinds of problems just trying to find a total number of current cpu usage.

I don't care if it comes from wmi or t-sql, i just want a total number for which i will be using to populate a gauge chart that via ajax will be showing my current cpu usage percentage...

Thank You...

+1  A: 

If it were me I would setup a perfmon counter on the machine in question to measure total CPU. This can be configured to write to a CSV file every couple of seconds.

You can then either have a task that writes that file to the database every minute and get CF to read that data so you can see a graph over time. Or, if you need the most recent value then just get CF to read the CSV file's last value and use that for your gauge.

Personally I store all the data in the database for all our web servers so I can see performance over time and run reports on busy or problem periods. Works great for us.

Hope that helps!

Ciaran Archer
+1  A: 

You can use the Win32_PerfRawData_PerfOS_Processor WMI class to get this information. In your query you would use Win32_PerfFormattedData_PerfOS_Processor.Name='_Total'. See the article ColdFusion and WMI for more information on using WMI as well as the sample vbscirpt code in this article.

Garett
Which counter should I use to get the total cpu usage, similar to the taskmanager? PercentUserTime, or PercentPrivaledgedTime etc.
crosenblum
If you want total cpu usage then you will need PercentProcessorTime and TimeStamp_Sys100NS. There is sample code in the second article that shows how to use these values to calculate the percentage, albiet in VBscript.
Garett
The values i get back grom TimeSpan_Sys100NS is always blank or empty. So that formula does not work. Would I need to adjust this at all for use on Vista?
crosenblum
What does your query look like? Can you update your post with the query you are using?
Garett
I just updated my post, to show the code, it kind of looks ugly. you can see the function i use at http://crosenblum.pastebin.com/sTjwsmck which is how any wmi query get's executed, and then returns it's results. Which in simpler terms, i hand it the name of a wmi object, then i have to loop thru all results to get the 1 result i need lol.
crosenblum
I'm not very familiar with cold fusion, but can you change the query to `obj_wmi.execQuery( "Win32_PerfFormattedData_PerfOS_Processor.Name='_Total'" )` or`select * from Win32_PerfFormattedData_PerfOS_Processor where name = '_Total'`. You can also try running the vbscript sample on Vista to see if it works.
Garett
No i can not, unless i change the cfc, to accept parameter's. So far it only accept's names of objects. Then i have to loop around results to just the result I want.
crosenblum
Where i try it with .name = or where name = i get no data returning back. I am open to suggestions..
crosenblum