sno Posted June 13, 2005 Share Posted June 13, 2005 I would like to capture the cpu load of some processes. Depending on the average load (measured by a couple of samples) one action must take place. How do I take samples of the cpu load regarding a process? Grtx Sno. The Novice Newbie. Link to comment Share on other sites More sharing options...
sno Posted June 14, 2005 Author Share Posted June 14, 2005 No luck so far, i have found out that PDH.dll can give me some performance information. But as i posted b4 that goes beyond my understanding. Maybe some1 can point me a bit furder into the right direction? Thx.The PdhGetCounterInfo function retrieves information about a counter, such as data size, counter type, path, and user-supplied data values.PDH_STATUS PdhGetCounterInfo( IN HQUERY hCounter, // handle of the counter IN BOOLEAN bRetrieveExplainText, // TRUE to retrieve explain text IN LPDWORD pdwBufferSize, // pointer to size of lpBuffer IN PPDH_COUNTER_INFO lpBuffer // buffer for counter information ); ParametershCounterThe handle of the counter from which to retrieve the information.bRetrieveExplainTextDetermines whether explain text is retrieved. If you set this parameter to TRUE, then the explain text for the counter is retrieved. If you set this parameter to FALSE, the field in the returned buffer is NULL.pdwBufferSizeA pointer to the size, in bytes, of the buffer passed in lpBuffer. If the counter requires a buffer larger than is indicated by pdwBufferSize, then PdhGetCounterInfo will return the required buffer size in this field. If the function succeeds, then this field will contain the size of the data returned in lpBuffer. If the size is zero, then no data will be returned in the buffer (in fact, lpBuffer can be NULL); and the size, in bytes, will be returned in the DWORD.lpBufferA pointer to the data buffer to receive the counter information. The buffer returned is variable-length, because the string data is appended to the end of the fixed-format portion of the structure. This is done so that all data is returned in a single buffer allocated by the caller. Grtx Sno. The Novice Newbie. Link to comment Share on other sites More sharing options...
sno Posted June 15, 2005 Author Share Posted June 15, 2005 kick Grtx Sno. The Novice Newbie. Link to comment Share on other sites More sharing options...
w0uter Posted June 15, 2005 Share Posted June 15, 2005 look's like a nice project. but first i need to finish up SCHOOL work and my FTP.au3 if after that noone has already started it i would be happy to do it. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
sno Posted June 16, 2005 Author Share Posted June 16, 2005 I espected this to be a simple question for some guys around, gues not. And I will be glad to get some help on this one if u have some free time wouter. Grtx Sno. The Novice Newbie. Link to comment Share on other sites More sharing options...
ptrex Posted June 16, 2005 Share Posted June 16, 2005 @sno This will you help starting. The code brings you the performance info for all processes running at that time. So If you now the PID of that process (see via taksmanager) you can select only that process you want and querie for that process. You need to convert this script to an EXE and schedule it to run every X minutes, to update the data. If the condition is met you take action expandcollapse popup$wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfProc_Process", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Caption: " & $objItem.Caption & @CRLF $Output = $Output & "CreatingProcessID: " & $objItem.CreatingProcessID & @CRLF $Output = $Output & "Description: " & $objItem.Description & @CRLF $Output = $Output & "ElapsedTime: " & $objItem.ElapsedTime & @CRLF $Output = $Output & "Frequency_Object: " & $objItem.Frequency_Object & @CRLF $Output = $Output & "Frequency_PerfTime: " & $objItem.Frequency_PerfTime & @CRLF $Output = $Output & "Frequency_Sys100NS: " & $objItem.Frequency_Sys100NS & @CRLF $Output = $Output & "HandleCount: " & $objItem.HandleCount & @CRLF $Output = $Output & "IDProcess: " & $objItem.IDProcess & @CRLF $Output = $Output & "IODataBytesPersec: " & $objItem.IODataBytesPersec & @CRLF $Output = $Output & "IODataOperationsPersec: " & $objItem.IODataOperationsPersec & @CRLF $Output = $Output & "IOOtherBytesPersec: " & $objItem.IOOtherBytesPersec & @CRLF $Output = $Output & "IOOtherOperationsPersec: " & $objItem.IOOtherOperationsPersec & @CRLF $Output = $Output & "IOReadBytesPersec: " & $objItem.IOReadBytesPersec & @CRLF $Output = $Output & "IOReadOperationsPersec: " & $objItem.IOReadOperationsPersec & @CRLF $Output = $Output & "IOWriteBytesPersec: " & $objItem.IOWriteBytesPersec & @CRLF $Output = $Output & "IOWriteOperationsPersec: " & $objItem.IOWriteOperationsPersec & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "PageFaultsPersec: " & $objItem.PageFaultsPersec & @CRLF $Output = $Output & "PageFileBytes: " & $objItem.PageFileBytes & @CRLF $Output = $Output & "PageFileBytesPeak: " & $objItem.PageFileBytesPeak & @CRLF $Output = $Output & "PercentPrivilegedTime: " & $objItem.PercentPrivilegedTime & @CRLF $Output = $Output & "PercentProcessorTime: " & $objItem.PercentProcessorTime & @CRLF $Output = $Output & "PercentUserTime: " & $objItem.PercentUserTime & @CRLF $Output = $Output & "PoolNonpagedBytes: " & $objItem.PoolNonpagedBytes & @CRLF $Output = $Output & "PoolPagedBytes: " & $objItem.PoolPagedBytes & @CRLF $Output = $Output & "PriorityBase: " & $objItem.PriorityBase & @CRLF $Output = $Output & "PrivateBytes: " & $objItem.PrivateBytes & @CRLF $Output = $Output & "ThreadCount: " & $objItem.ThreadCount & @CRLF $Output = $Output & "Timestamp_Object: " & $objItem.Timestamp_Object & @CRLF $Output = $Output & "Timestamp_PerfTime: " & $objItem.Timestamp_PerfTime & @CRLF $Output = $Output & "Timestamp_Sys100NS: " & $objItem.Timestamp_Sys100NS & @CRLF $Output = $Output & "VirtualBytes: " & $objItem.VirtualBytes & @CRLF $Output = $Output & "VirtualBytesPeak: " & $objItem.VirtualBytesPeak & @CRLF $Output = $Output & "WorkingSet: " & $objItem.WorkingSet & @CRLF $Output = $Output & "WorkingSetPeak: " & $objItem.WorkingSetPeak & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_PerfFormattedData_PerfProc_Process" ) Endif More parameters are available, too many to list here. See WMI for more info (AutoIT scriptomatic Tool). Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
sno Posted June 20, 2005 Author Share Posted June 20, 2005 Thx for the idea. One question tho, does compiling the wmi code into a AU exe require the pc to be wmi enabled? Grtx Sno. The Novice Newbie. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now