JAH-211 forwarder bug fix, JAH-222 metric rename

This commit is contained in:
David Schroeder 2014-05-22 14:37:40 -06:00
parent 73a484f233
commit d9f785a11a
3 changed files with 17 additions and 14 deletions

View File

@ -47,31 +47,31 @@ class HTTPCheck(AgentCheck):
except socket.timeout, e:
length = int((time.time() - start) * 1000)
self.log.info("%s is DOWN, error: %s. Connection failed after %s ms" % (addr, str(e), length))
self.gauge('mon_http_status', 1, dimensions=new_dimensions)
self.gauge('http_status', 1, dimensions=new_dimensions)
return
except HttpLib2Error, e:
length = int((time.time() - start) * 1000)
self.log.info("%s is DOWN, error: %s. Connection failed after %s ms" % (addr, str(e), length))
self.gauge('mon_http_status', 1, dimensions=new_dimensions)
self.gauge('http_status', 1, dimensions=new_dimensions)
return
except socket.error, e:
length = int((time.time() - start) * 1000)
self.log.info("%s is DOWN, error: %s. Connection failed after %s ms" % (addr, repr(e), length))
self.gauge('mon_http_status', 1, dimensions=new_dimensions)
self.gauge('http_status', 1, dimensions=new_dimensions)
return
except Exception, e:
length = int((time.time() - start) * 1000)
self.log.error("Unhandled exception %s. Connection failed after %s ms" % (str(e), length))
self.gauge('mon_http_status', 1, dimensions=new_dimensions)
self.gauge('http_status', 1, dimensions=new_dimensions)
raise
if response_time:
# Stop the timer as early as possible
running_time = time.time() - start
self.gauge('mon_http_response_time', running_time, dimensions=new_dimensions)
self.gauge('http_response_time', running_time, dimensions=new_dimensions)
# Add a 'detail' tag if requested
if include_content:
@ -79,16 +79,16 @@ class HTTPCheck(AgentCheck):
if int(resp.status) >= 400:
self.log.info("%s is DOWN, error code: %s" % (addr, str(resp.status)))
self.gauge('mon_http_status', 1, dimensions=new_dimensions)
self.gauge('http_status', 1, dimensions=new_dimensions)
if pattern is not None:
if re.search(pattern, content, re.DOTALL):
self.log.debug("Pattern match successful")
else:
self.log.info("Pattern match failed! '%s' not in '%s'" % (pattern, content))
self.gauge('mon_http_status', 1, dimensions=new_dimensions)
self.gauge('http_status', 1, dimensions=new_dimensions)
return
self.log.debug("%s is UP" % addr)
self.gauge('mon_http_status', 0, dimensions=new_dimensions)
self.gauge('http_status', 0, dimensions=new_dimensions)

View File

@ -56,7 +56,7 @@ def get_parsed_args():
def get_version():
return "1.0.2"
return "1.0.3"
def skip_leading_wsp(f):
@ -831,12 +831,15 @@ def get_mon_api_config(config):
if config.has_option("Main", "dimensions"):
# parse comma separated dimensions into a dimension list
dim_list = [dim.split(':') for dim in config.get('Main', 'dimensions').split(',')]
mon_api_config['dimensions'] = {key.strip(): value.strip() for key, value in dim_list}
try:
dim_list = [dim.split(':') for dim in config.get('Main', 'dimensions').split(',')]
mon_api_config['dimensions'] = {key.strip(): value.strip() for key, value in dim_list}
except ValueError:
mon_api_config['dimensions'] = { }
if config.has_section("Api"):
options = {"use_mon_api": config.getboolean,
"url": config.get,
options = {"url": config.get,
"project_id": config.get,
"username": config.get,
"password": config.get,

View File

@ -112,7 +112,7 @@ setup(
name='mon-agent',
maintainer="Tim Kuhlman",
maintainer_email="tim.kuhlman@hp.com",
version='1.0.2',
version='1.0.3',
description="Collects metrics from the host it is installed on and sends to the monitroing api",
classifiers=[
"Development Status :: 5 - Production/Stable",