Skip to content

Commit

Permalink
Merge pull request #1202 from DataDog/conor/kyototycoon-service-check
Browse files Browse the repository at this point in the history
Add service check for Kyototycoon.
  • Loading branch information
LeoCavaille committed Dec 10, 2014
2 parents 9bc9f1e + f00ddc5 commit 28d3119
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion checks.d/kyototycoon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class KyotoTycoonCheck(AgentCheck):
database server (http://fallabs.com/kyototycoon/)
"""
SOURCE_TYPE_NAME = 'kyoto tycoon'
SERVICE_CHECK_NAME = 'kyototycoon.can_connect'

GAUGES = {
'repl_delay': 'replication.delay',
Expand Down Expand Up @@ -56,7 +57,23 @@ def check(self, instance):
if name is not None:
tags.append('instance:%s' % name)

response = urllib2.urlopen(url)
service_check_tags = []
if name is not None:
service_check_tags.append('instance:%s' % name)

try:
response = urllib2.urlopen(url)
except urllib2.URLError as e:
self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL,
tags=service_check_tags, message=e.reason)
raise
except Exception as e:
self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL,
tags=service_check_tags, message=str(e))
raise
else:
self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.OK)

body = response.read()

totals = defaultdict(lambda: 0)
Expand Down

0 comments on commit 28d3119

Please sign in to comment.