Jump to content

Catching hangs / detecting dead processes


Recommended Posts

Hello again,

Right. I've written a rather complicated script which scans all the PCs listed in our Active Directory and scans them for various things. The problems begin, when using WMI connections. If a machine has issues with WMI - often the script will just hang. Now, out of 5000+ PCs on our network, only a handful have WMI issues.

I've adapted the script to automatically add the last failed machine to an exclude list - but currently have no way of killing the script if the process hangs. So... my question is...

Is there any way to either (1) automatically kill the scripts process if the process hangs or (2) kill the script with another external detection script, based on it hanging?

Ooh, good one for a tuesday morning! :)

Many thanks,

JT

Link to comment
Share on other sites

  • Moderators

Might try using 2 scripts.

1. Main script, on startup get a list of AutoIt windows, match their PIDs to your newly launched app.

2. Once you find the right Hwnd, send that in a command line to the "watcher" app.

3. In the watcher app, loop through using a dll call for IsHungAppWindow : http://msdn.microsoft.com/en-us/library/ms633526(VS.85).aspx

I could have sworn someone wrote something up for checking if a process is hung, but my search terms may be incorrect... I thought I remembered them using GetProcessIOCounters but that search didn't turn it up either.

Any, the quickest solution I can think of off the top of my head above.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

hi there, thanks for your responses.

Okay, i've only got one window which does everything - so getting the PID should be easy enough. I can call another autoit script and pass that ID - but how do I do the 'step 3' part within AutoIT?

Link to comment
Share on other sites

  • Moderators

Well, just pass your PID (I was talking about window handles, not process id's... but let's do it with process id's that way you only have to pass @AutoItPID in the main app to the watcher).

(None of this is tested, just pseudo mainly):

Main App:

Run('"' & $s_Watcher_Location_Name & '" ' & @AutoItPID)
; Somewhere in here before you actually exit your main app
; Be sure to close the watcher appoÝ÷ Ùf­r«ZºÚ"µÍÈØ]ÚYÝ    ÌÍØÛY[VÌH[SÙÐÞ
M   ][ÝÑÜ][ÝË  ][ÝÖ[ÝH]ÝÜÈHÛÛ[X[[HÈYK][ÝÊBQ^]B[YÛØ[   ÌÍÚWÔQH ÌÍØÛY[VÌWK ÌÍØWÒÒ[ÂÛØ[ ÌÍØWÕÙÌHÜ[   ][ÝÕÙÌ  ][ÝÊBY    ÌÍØWÕÙÌHLH[^]YØÙÜÑ^ÝÊ   ÌÍÚWÔQ
H[^]ÂÛØ[ ÌÍÚXØË ÌÍÚØÛ  ÌÍØWÕÚ[ÝHÚ[Ý
    ][ÝÖÐÓTÔÎ]]Ò]×I][ÝÊBÜ    ÌÍÚXØÈHHÈ ÌÍØWÕÚ[ÝÌVÌBRYÚ[Ù]ØÙÜÊ    ÌÍØWÕÚ[ÝÉÌÍÚXØ×VÌWJHH  ÌÍÚWÔQ[BIÌÍÚØÛHÛ
    ÌÍØWÕÚ[ÝÉÌÍÚXØ×VÌWJBBQ^]ÛÜQ[Y^Y  ÌÍÚØÛH ][ÝÉ][ÝÈ[^]
Ú[HØÙÜÑ^ÝÊ   ÌÍÚWÔQ
BIÌÍØWÒÒ[ÈHØ[
    ÌÍØWÕÙÌ   ][ÝÚ[ ][ÝË  ][ÝÒÒ[ÐÚ[ÝÉ][ÝË    ][ÝÚÛ    ][ÝË  ÌÍÚØÛ
BRYÐ^J ÌÍØWÒÒ[ÊH[    ÌÍØWÒÒ[ÖÌH[BNÈ]ØÈØ]Ú[È]Z]ÜÛ[ÂBNÈ]ÛÛY][ÈHÈÂBNÈØÙÜÐÛÜÙBBNÈÙÈ]ËQ[YTÛY
L
BÑ[[ÈÛ]]Ò]^]

BRYÑXÛY
    ][ÝØWÕÙÌ][ÝÊH[ÛÜÙJ    ÌÍØWÕÙÌBNÈX^[ÈÙÈÛÛY][ÈB[[

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thank you for your reply - thats really helpful. I'm going to have a play around with it and see if I can resolve the issue.

We noticed something else happening on the PC which is doing the scanning. It seems that after a couple of thousand PCs - the script starts bombing out all attempts to connect to anything with WMI (until after you reboot).

Hmmmm.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...