Jonathan Gardner
3/14/2008 4:25:00 PM
On Mar 13, 11:32 pm, Gilles Ganault <nos...@nospam.com> wrote:
> I'd like to monitor connections to a remote SSH and web server. Does
> someone have some code handy that would try to connect every 5mn, and
> print an error if the script can't connect?
from time import sleep
while True:
# Try to connect. May want to spawn a subprocess running a simple
shell script
# Handle success / failure appropriately
sleep 5*60 # Sleep for 5 minutes
What you monitor is up to you. At a basic level, you can see if the
server is accepting connections. At a higher level, see if you can get
a page or see if you can login as a specific person. At a higher
level, you may want to check what is on the page or what happens when
you log in. It's all up to you.