Jump to content

Need help for an autorestart script


thegeek
 Share

Recommended Posts

Hello all,

We have a few critical processes that need to be up 24/7.

Sometimes these processes hang and I get a call in the middle of the night to connect to the server and restart the process (which is stupid).

I need a monitoring script to check the health of these processes and once it detects a process to be hung or not responding to kill and restart the process.

Is this doable with Autoit?

Any help is appreciated.

Thanks...

Link to comment
Share on other sites

It's quite possible i could be done but it depends on a number of factors.

First, do the monitored processes provide a reliable way to determine if they're hung? Something innocuous, like the equivalent of a ping.

EDIT:

Sorry I didn't notice: welcome to the AutoIt forum!

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

If there is some reliable way to "ping" the process as mentioned by jchd, you can use "ProcessClose" to terminate it and "ShellExecute" or "Run" to start it back up (Check documentation to see how to call these functions). If these processes need administrative rights, then add "#RequireAdmin" to the top of your script, and use "ShellExecute" not "Run" because "ShellExecute" preserves application rights and "Run" does not.

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Link to comment
Share on other sites

If you use ProcessGetStats() on the process when its running fine (test a few times) then try again when its hung then you will most likely see some noticable differends in 1 or more od the array elements.

Hopefully from that you will be able to have your script check it intermittently and restart it if conditions are met.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I guess I need to first understand what "hung" means in OS terms.

When the process is hung it is still running according to task manager, but it is not processing what it should.

Then this is this buggy process that needs attention, not a doubtful way to possibly catch an undefined internal state, which this "critical 24/7" process should _never_ be allowed to reach.

I'd like my grandfather to wear a heart monitor, calling for rescue in case he gets a heart attack.

Geez, take him to a heart specialist in the first place!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Thanks to all of you guys.

This is the script that I have so far:

$title = "process_name"
$text = ""
$hWnd = WinGetHandle($title, $text)
If $hWnd == "" Then Exit
$retArr = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $hWnd)
If $retArr[0] Then ProcessClose(WinGetProcess($title, $text))
Exit

Now all I have to do is to create a time loop to check the process every 10 minutes.

What do you guys think?

Link to comment
Share on other sites

It's cool that this works for you but nonetheless the mere need to routinely check such abnormal condition reflects a deeper problem which isn't going to fade away if noone cares. Sounds pretty fragile for a mission critical application. I don't mean to blame you since I guess this isn't your responsability.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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...