最近发现在报警邮件中,有显示current http code是200,但是nagios的状态却是critical的情况。
报警邮件:
通过nagios的页面查看,确实看到了监控报错的情况:
nagios页面:
分析nagio的报判断的几种状态:
在pycurl中控制超时的设置是CONNECTTIMEOUT(默认300s),TIMEOUT(永不超时)
而nagios的模式设置service_check_timeout模式时60s.
具体的pycurl的代码:
def check_server_url(proxy,url,location): buf_header = cStringIO.StringIO() c = pycurl.Curl() c.setopt(c.URL,url) c.setopt(c.CONNECTTIMEOUT,20) c.setopt(c.TIMEOUT,40) if location == 0: c.setopt(c.FOLLOWLOCATION,0) else: c.setopt(c.FOLLOWLOCATION,1) c.setopt(c.PROXY,proxy) c.setopt(c.HEADERFUNCTION,buf_header.write) c.setopt(c.NOBODY,True) try: c.perform() http_code = c.getinfo(c.HTTP_CODE) print http_code http_hearder = buf_header.getvalue() except pycurl.error: http_code = "-1" c.close() buf_header.close() return http_code
其实最根本的rc还是业务响应慢导致(最终定位为db的响应慢)。
本文出自 “菜光光的博客” 博客,请务必保留此出处http://caiguangguang.blog.51cto.com/1652935/1357283
原文:http://caiguangguang.blog.51cto.com/1652935/1357283