Hi,

I just started learning Python and would like to try writing a monitoring script.

What I would like to do is use Telnet to send a GET via port 80 to a status page in a directory to verify my site is up.

Psuedo code:

Connect = telnet website.com 80

Send = GET /folder/folder/test.asp HTTP/1.1
      Host: website.com

Pipe the Response to a file (overwriting it each time):

HTTP/1.1 400 Bad Request
Server: Server: Microsoft-IIS/5.0
Date: Wed, 16 Nov 2005 20:15:20 GMT
X-Powered-By: ASP.NET
Connection: close
Server: website.com
Content-Length: 102
Content-Type: text/html

GREP "HTTP/1.1 400 Bad Request" from the file and | append >> it into a log. This tells me the connection was valid. Timestamping the line would be nice.

The other error code could be "HTTP/1.1 404 Not Found" if the directory went missing or possibly "Cound not open connection" if the connection could not be made.

If the above GREP is found in the file do nothing.

If not send an email stating the error.

End

Anyway, Can someone point me in the right direction on getting the Telnet working? Or if you have a better way to get what I am trying to do accomplished. Is there a Python Telnet module?

Thanks in advance

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to