def is_alive(self):
url = urlparse.urlparse(self.conf.monasca_url)
if url.scheme == 'https':
http_connector = httplib.HTTPSConnection
else:
http_connector = httplib.HTTPConnection
try:
connection = http_connector(host=url.netloc)
connection.request('HEAD', url=url.path)
response = connection.getresponse()
except httplib.socket.error:
return False
try:
if getattr(response, 'status') in [200, 401]:
return True
except AttributeError:
pass
return False
评论列表
文章目录