Topper Posted July 12, 2010 Posted July 12, 2010 (edited) Is it possible with AutoIT3 (I'm sure it is) to be made monitor, which to monitor specific process with known name ( or unknown name for unification) and this process overload CPU above some limit for specific time. For ex. if process.exe runs above 90% CPU more than 1 min - kill it or restart it. Will be thankful for any help. I'm asking because made only simple scripts, nothing with WMI. Some additional goals - this watched process may be run from different users and must be killed/restarted only specific. I mean that snippets like "Finding if an Application is Hung" from URL http://quadryders.com/phpcc/snippet.php?sid=28 !! WILL NOT ABLE TO DO THE JOB !! Edited July 12, 2010 by Topper
Ascend4nt Posted July 12, 2010 Posted July 12, 2010 It can be done using Performance Counters (see the link in my signature). I give an example on how to track CPU usage on the local PC, but it is also possible to monitor processes on other PC's with filtered wildcard counter results. The filtering isn't built-in but can be done simply enough on a returned array. There's also WMI, but that can be really slow and unreliable My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
Topper Posted July 13, 2010 Author Posted July 13, 2010 Yeah, looks easy according this postBut what about when process's are many from different user on same machine.I'm talking about Win2k3 server and remote logged users.Please advice ?
Ascend4nt Posted July 13, 2010 Posted July 13, 2010 I'm not sure I follow - all the processes are on one machine? Or are the processes being run on other people's machines? If all the processes are locally run, then I'm not sure why you can't use that function? As long as you are an administrator and can see all sessions, I'm fairly sure you would be able to see all processes under all sessions. But if that's the case, I'm wondering how does a person run a process on a server, unless its spawned by the server itself when it receives some sort of request? (Sorry, I've never run a server). Well, whatever the case - if its all on a local machine, you should be able to see it as an administrator. You can read Session ID information if that helps (that'd be another function to determine that info). My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
Topper Posted July 14, 2010 Author Posted July 14, 2010 (edited) You are on right way. It's not necessary to be a server, could be a personal computer with 2 or 3 co-workers logged in with Remote Desktop Protokol. But one of them started long and heavy operation with program process.exe - by mistake or purposely. So I want to kill this process when it takes a lot of processor time for a long period because I don't need to suffer rest of users. Actually I'v got 15 remote users on Win2k3 running same program trough its login script. Some time one or two of them start to over load and I need to close this processes. That's the way I think. PS:This picture means, that we have on ONE machine few processes with different sessions and different CPU Usage: 123 server/user1 process.exe 1% 345 server/user2 process.exe 2% 567 server/user3 process.exe 90% 789 server/user4 process.exe 50% The script must kill process PID 567 from user 3 if it takes 15 minute to run above watermark level 85% for examp. Edited July 14, 2010 by Topper
Ascend4nt Posted July 14, 2010 Posted July 14, 2010 Check out the 'TestPDH_ObjectTests' module. There's an example of using the '_PDH_ProcessAll' module. You'd basically set it up like in the link you put, but you'd be getting an array back each time. You'd need to monitor different processes in that array and check the CPU usages. However - if there's a lot of changes in processes, the CPU Usage info will need two calls with an interval between them each time there's a change, so if its pretty busy on your machine, it might be you'll just have to get a _PDH_ProcessObject for each process and monitor them all as they come and go. And use sesion ID and Owner information to find out what process belongs to who. Well.. I hope maybe that helps. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
Topper Posted July 14, 2010 Author Posted July 14, 2010 I need to monitor only one process from different users but not so important which user own that overloading process simple must to close/kill it when that overload continue 30 min for example. Sorry that I disturb you, but I used AutoIt long time ago and I'm afraid that not have enough knowledge to make the script
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