PDH Performance Counters
Measure Process, CPU, Network, Process, Disk (etc) Usage
(note that the above dialog appears differently on Vista+)
New ObjectBase interface!!
*x64 and Localization Issues have been resolved!*
*Download and License agreement are at the bottom of this post!
About The Project:
Performance Counters gather all kind of performance data about the PC and the Network using the standard PDH.DLL module (standard since Windows 2000).
Among the performance data you can collect and monitor are:
- Processor Stats (including total usage)
- Process (programs) Stats (including CPU usage)
- Disk Stats (speed/access)
- TCP, UDP, IP Connection Counts, Speed/Error Stats
- Network Stats
- ..and so on
You can jump right in, download the two AutoIT files (below) and run one of the following to see what the PDH Performance Counters project can get you:
- TestPDH_PerformanceCounters - this is where you should start! It allows you to visually experiment with most all of the Counters available on your PC and Network.
- Currently the 'Refresh' rate is set to 1/2 second - this can be changed by altering the Adlib() function frequency
- New Counters that come into existence during monitoring will *not* be added to the list (this would be a function I've yet to add)
- Counters that become invalid are simply given a prefix of '[Dead Counter Handle]:'
- TestPDH_ProcessLoop - this basically repeatedly shows an extended Process-information list for all processes. NOTE: You must hit 'ESC' to exit the loop
- TestPDH_TaskManager - this gathers and displays most everything you'd see in the Process and Performance sections of Task Manager.
- The screen does NOT update, and the UDF is a MESS. This is due to a number of reasons - the biggest one being laziness on my behalf. Plus I need to figure out how best to manage ListView changes.
- TWO fields need Windows XP+ to display correctly (or a version of psapi.dll that supports 'GetPerformanceInfo'): Commit Charge (Peak) and System Cache
- TestPDH_ProcessGetRelatives - this shows how the PDH Performance Counters can be used to get 'parent' and 'children' process information. There are more practical means of getting this info of course (a few you'll see in my 'Process Functions' module, but hey - its just yet another example of what can be done.
- TestPDH_ObjectTests - this is more for reading/understanding the code than anything. It is there to show how the new 'ObjectBase' Interface works to make coding Performance Counters *much* easier.
- Multipile extra 'TestPDH*' examples
The brand new ObjectBase Interface removes some of the difficulty in interacting with Performance Counters, and works like this:
Examples of the new ObjectBase interface:
% CPU Usage of a Process
% CPU Usage of Multiple Instances of a Process (+monitoring and adjustment based on new/dead Instances)
Waiting for Hard Disk activity to Idle for 'x' ms
% System CPU Usage (by Processor)
Network Usage (bytes sent/received)
Physical Disk Read/Write Speed
I've put a LOT of work into this project, and all I ask is that you follow my License Agreement when using the code (very easy, see below). Any feedback is welcome. I apologize for the unpolished GUI interfaces (especially the unfinished one), but I will get to that TaskManager GUI one day, hah. Enough chatter -now go on and experience the awesome power of Performance Counters
NOTE: Bundled in the ZIP (and included in the License agreement) are other UDF's I wrote that are necessary to run some of the 'Test' programs:
_WinAPI_GetSystemInfo.au3, _WinAPI_GetPerformanceInfo.au3, _WinTimeFunctions.au3, and the unnecessary, but provided for those who are interested in the _WinTimeFunctions 'filetime' usage, program: TestWinTimeFunctions.au3.
Ascend4nt's AutoIT Code License agreement:
While I provide this source code freely, if you do use the code in your projects, all I ask is that:
- If you provide source, keep the header as I have put it, OR, if you expand it, then at least acknowledge me as the original author, and any other authors I credit
- If the program is released, acknowledge me in your credits (it doesn't have to state which functions came from me, though again if the source is provided - see #1)
- The source on it's own (as opposed to part of a project) can not be posted unless a link to the page(s) where the code were retrieved from is provided and a message stating that the latest updates will be available on the page(s) linked to.
- Pieces of the code can however be discussed on the threads where Ascend4nt has posted the code without worrying about further linking.
Edited by Ascend4nt, 18 October 2012 - 12:03 PM.