cpu usage code

hi i need a procedure that is once called could continuously calculate the CPU usage of the current machine in use and of a distant machine if possible or even just receiving it. My main objective is to use that numeric value as an entry to another function.

Both *Nix and Windows have very different ways of accomplishing this. So you would have to pick one.
am using a windows based configuration and my main object is to find cpu usage percentage as close as possible to real value and in continous why ( by using "while" for instance ), and so use it this integer value representing the cpu usage as a parameter for other uses
For Windows you would be using WMI, I'm not sure which object class specifically would be best for this application but here is a list of them: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394084(v=vs.85).aspx

If you're not familiar with COM then this is a bit advanced so, not to shoot down your idea, but would setting something to run at a different priority be a better solution for you? Is this something that perfmon would be better suited to do? I ask as a Sys Admin, we often over complicate problems when simpler solutions exist.

EDIT: The class to use might be Win32_PerfFormattedData_PerfOS_Processor found here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394271(v=vs.85).aspx
Last edited on
Topic archived. No new replies allowed.