How to Monitor an application which required kill and regenerate if hang
-
Hi all, Do need a favour here. I would like to monitor an application and kill it if it is hang and regenerate it. However, not able to find relevant code. I'm able to get the kernel and user time by "getprocesstime". But not able to monitor the CPU usage (not able to get idle time) to kill the hang program.Understand that some programmer use "GetSystemTimes" function. But it does not work in my PC. Any suggestion or free code to share? Thanks a lot! -- modified at 23:29 Wednesday 19th September, 2007
-
Hi all, Do need a favour here. I would like to monitor an application and kill it if it is hang and regenerate it. However, not able to find relevant code. I'm able to get the kernel and user time by "getprocesstime". But not able to monitor the CPU usage (not able to get idle time) to kill the hang program.Understand that some programmer use "GetSystemTimes" function. But it does not work in my PC. Any suggestion or free code to share? Thanks a lot! -- modified at 23:29 Wednesday 19th September, 2007
littlecheer wrote:
Do need a favour here. I would like to monitor an application and kill it if it is hang and regenerate it. However, not able to find relevant code. I'm able to get the kernel and user time by "getprocesstime". But not able to monitor the CPU usage (not able to get idle time) to kill the hang program.Understand that some programmer use "GetSystemTimes" function. But it does not work in my PC. Any suggestion or free code to share? Thanks a lot!
There are lots of ways for a program to hang. For instance, I've had just the user interface fail and the program keep running in the background. If you control the code for this program, you could have it periodically signal your monitor program that it's still working. If not, your problem is a lot more dificult. Nathan
-
littlecheer wrote:
Do need a favour here. I would like to monitor an application and kill it if it is hang and regenerate it. However, not able to find relevant code. I'm able to get the kernel and user time by "getprocesstime". But not able to monitor the CPU usage (not able to get idle time) to kill the hang program.Understand that some programmer use "GetSystemTimes" function. But it does not work in my PC. Any suggestion or free code to share? Thanks a lot!
There are lots of ways for a program to hang. For instance, I've had just the user interface fail and the program keep running in the background. If you control the code for this program, you could have it periodically signal your monitor program that it's still working. If not, your problem is a lot more dificult. Nathan
I see. Based on my understanding, the hang program will reflect very high CPU usage (program in a loop) or usertime and kerneltime unchange (deadlock). Is it possible to trace the particular application's CPU usage? Thanks a lot!
-
I see. Based on my understanding, the hang program will reflect very high CPU usage (program in a loop) or usertime and kerneltime unchange (deadlock). Is it possible to trace the particular application's CPU usage? Thanks a lot!
-
one idea: use Sysinternals' pslist -
(1) have another periodically run pslist (2) pipe the output the a flat file, (3) then your *other* application to parse the file for CPU usage (4) If ProcessA.CPU>30 Then killtask
devvvy wrote:
- If ProcessA.CPU>30 Then killtask
many of myserver application are so cpu savvy , it runs on 30-40% i.e. when acquring data from hardware at 20hz( i.e. 20 record per second). that will help ful atleast in my case!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
devvvy wrote:
- If ProcessA.CPU>30 Then killtask
many of myserver application are so cpu savvy , it runs on 30-40% i.e. when acquring data from hardware at 20hz( i.e. 20 record per second). that will help ful atleast in my case!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
My current monitoring application is written in C++ console. Is it possible to use C++ coding to solve this problem? Thanks a million.