Gilles Ganault <[EMAIL PROTECTED]> 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?

This script has been pretty reliable for us for the past few years,
much more reliable than the expect script it replaced.

  #!/usr/bin/python
  import sys
  import pexpect 
  quiet = open("/dev/null", "rw")
  sys.stdin = quiet
  sys.stdout = quiet
  sys.stderr = quiet 
  smtp = pexpect.spawn("telnet " + sys.argv[1] + " 25")
  smtp.expect('220', timeout=120)
  smtp.sendline("quit\n^]q")

Pacman
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to