Monitoring SSHd and web servers?

Pacman nomailplease at
Fri Mar 14 19:13:57 CET 2008

Gilles Ganault <nospam at> 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.

  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)


More information about the Python-list mailing list