开发者

Check status of process and restart process if unresponsive/stopped - Python

开发者 https://www.devze.com 2023-03-27 02:01 出处:网络
I\'m trying to build a small process monitoring script on Windows Server 2008. The script开发者_StackOverflow中文版 would:

I'm trying to build a small process monitoring script on Windows Server 2008.

The script开发者_StackOverflow中文版 would:

  • find target process
  • check status (running/unresponsive/stopped)
  • kill and restart process if unresponsive/stopped

Any suggestion on the best way to implement this?


Naming a process 'unresponsive' is quite subjective. It might be waiting for data and seem unresponsive, or it might be in a (endless) loop and seem unresponsive.

Usually, what people do is implement hartbeat. That is - have a very tiny socket server in the process where other processes can connect and send ping messages, to which it replies pong. What monitoring tools usually do is ping the process periodically, and if it doesn't respond within a timeout - it's considered unresponsive (and usually gets killed).

0

精彩评论

暂无评论...
验证码 换一张
取 消