Average CPU load on Windows?
Moderator: General Moderators
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Average CPU load on Windows?
Hi,
Does anyone have an idea how to get the average CPU load on Windows?
Does anyone have an idea how to get the average CPU load on Windows?
Re: Average CPU load on Windows?
I'm assuming you want a command-line tool that you can call from PHP? Tasklist provides some useful information on running processes and memory usage.
The ouput is too extensive to paste here.
For something shorter, this call filters the output for processes where the image name is "System Idle Process".
The output is something like
If the memory usage of the System Idle Process is low, the CPU load is low as well.
I'll keep looking for the proper command-line tool.
Edit: This post was recovered from search engine cache.
Code: Select all
<?php
header('Content-Type: text/plain');
echo system('tasklist /V');
?>For something shorter, this call filters the output for processes where the image name is "System Idle Process".
Code: Select all
tasklist /FI "IMAGENAME eq System Idle Process"Code: Select all
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
System Idle Process 0 Services 0 24 KI'll keep looking for the proper command-line tool.
Edit: This post was recovered from search engine cache.
Last edited by McInfo on Tue Jun 15, 2010 11:07 pm, edited 1 time in total.
Re: Average CPU load on Windows?
I posted a C app to someone earlier. Let me find it...
Re: Average CPU load on Windows?
Thanks, mikemike. Because of the code you posted, I was able to find information on the Performance Command Line Tools and discovered that the performance counters can be accessed using typeperf.
Command line:
Output:
Edit: This post was recovered from search engine cache.
Command line:
Code: Select all
C:>typeperf -?Code: Select all
Microsoft r TypePerf.exe (6.0.6000.16386)
Typeperf writes performance data to the command window or to a log file. To
stop Typeperf, press CTRL+C.
Usage:
typeperf { <counter [counter ...]>
| -cf <filename>
| -q [object]
| -qx [object]
} [options]
Parameters:
<counter [counter ...]> Performance counters to monitor.
Options:
-? Displays context sensitive help.
-f <CSV|TSV|BIN|SQL> Output file format. Default is CSV.
-cf <filename> File containing performance counters to
monitor, one per line.
-si <[[hh:]mm:]ss> Time between samples. Default is 1 second.
-o <filename> Path of output file or SQL database. Default
is STDOUT.
-q [object] List installed counters (no instances). To
list counters for one object, include the
object name, such as Processor.
-qx [object] List installed counters with instances. To
list counters for one object, include the
object name, such as Processor.
-sc <samples> Number of samples to collect. Default is to
sample until CTRL+C.
-config <filename> Settings file containing command options.
-s <computer_name> Server to monitor if no server is specified
in the counter path.
-y Answer yes to all questions without prompting.
Note:
Counter is the full name of a performance counter in
"\\<Computer>\<Object>(<Instance>)\<Counter>" format,
such as "\\Server1\Processor(0)\% User Time".
Examples:
typeperf "\Processor(_Total)\% Processor Time"
typeperf -cf counters.txt -si 5 -sc 50 -f TSV -o domain2.tsv
typeperf -qx PhysicalDisk -o counters.txt
Last edited by McInfo on Tue Jun 15, 2010 11:09 pm, edited 1 time in total.
Re: Average CPU load on Windows?
This script displays the % Processor Time for all processors in CSV format and appends an update every second until you hit the stop button in your browser.
Edit: This post was recovered from search engine cache.
Code: Select all
<?php
header('Content-Type: text/plain');
echo system('typeperf "\Processor(*)\% Processor Time"');
?>
Last edited by McInfo on Tue Jun 15, 2010 11:09 pm, edited 1 time in total.
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: Average CPU load on Windows?
Thank you. I knew this could be accomplished. 
Re: Average CPU load on Windows?
:)welcome
-
madhuj1260
- Forum Newbie
- Posts: 5
- Joined: Wed Jun 10, 2009 3:26 am
Re: Average CPU load on Windows?
Is there any command for web application?
Re: Average CPU load on Windows?
The system() function makes command-line programs accessible through Web applications. If you are looking for a different answer, you need to be more specific.
Edit: This post was recovered from search engine cache.
Edit: This post was recovered from search engine cache.