try: conn = httplib.HTTPConnection(urlparts.netloc) except Exception, e: print "ERROR: Unable to connect to %s. Exepction: %s" % (urlparts.netloc, e) conn_stop = time.time() t_start = time.time() try: conn.request("GET", urlparts.path, {}, headers) r1 = conn.getresponse() r1.read() except Exception, e: print "ERROR: unable to request. error: %s" % e t_stop = time.time() t_connect = conn_stop - conn_start t_fetch = t_stop - t_start t_totals = t_connect + t_fetch print "%.3f %.3f %.3f" % (t_connect, t_fetch, t_totals) sample = MonitorSample() sample.url = url sample.responsetime = t_totals sample.put() if __name__ == "__main__": print "Content-Type: text/plain\n" monitor_url = "http://" + os.environ['PATH_INFO'].replace("/mon/http/", "") run(monitor_url)