Skip to content

Instantly share code, notes, and snippets.

@rodrickbrown
Created October 20, 2016 04:50
Show Gist options
  • Save rodrickbrown/6b0103eb03d8ae75a690427a1e82fa47 to your computer and use it in GitHub Desktop.
Save rodrickbrown/6b0103eb03d8ae75a690427a1e82fa47 to your computer and use it in GitHub Desktop.
import os
import urllib
import json
from checks import AgentCheck
from hashlib import md5
class AccumuloCheck(AgentCheck):
def check(self, instance):
if 'host' not in instance:
self.log.info("Skipping instance, host not configured")
return
url = instance['host']
default_timeout = self.init_config.get('default_timeout', 5)
timeout = float(instance.get('timeout', default_timeout))
response = urllib.urlopen(url)
data = json.loads(response.read())
for node in data['servers']:
scans = int(node['scans'])
holdtime = float(node['holdtime'])
ingestMB = float(node['ingestMB'])
ingest = float(node['ingest'])
query = float(node['query'])
queryMB = float(node['queryMB'])
osload = float(node['osload'])
hostname = node['hostname']
scanssessions = float(node['scanssessions'])
ip = node['ip']
self.gauge('accumulo.ingestMB', ingestMB, tags=[hostname, url])
self.gauge('accumulo.ingest', ingest, tags=[hostname, url])
self.gauge('accumulo.query', query, tags=[hostname, url])
self.gauge('accumulo.queryMB', queryMB, tags=[hostname, url])
self.gauge('accumulo.osload', osload, tags=[hostname, url])
if __name__ == '__main__':
check, instances = AccumuloCheck('/etc/dd-agent/conf.d/accumulo.yaml')
for instance in instances:
print "\nRunning check against host: %s" % (instance['host'])
check.check(instance)
if check.has_events():
print 'Events: %s' % (check.get_events())
print 'Metrics: %s' % (check.get_metrics())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment