Skip to content

Instantly share code, notes, and snippets.

@sacreman
Created September 29, 2016 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sacreman/a03a8dfc16b5f18a16b9b0bb04164afc to your computer and use it in GitHub Desktop.
Save sacreman/a03a8dfc16b5f18a16b9b0bb04164afc to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
from dlcli import api
'''
Returns a sum of the number of agents that have returned the base.count metric in the last minute.
You will need to update the TAG, org, account and key variables in the settings below.
'''
# Settings
TAG = 'mytag'
settings = {
'url': 'https://app.dataloop.io/api/v1',
'org': 'myorg',
'account': 'myaccount',
'key': 'myapikey',
}
try:
count = 0
for series in api.series.get_tag_series(tag=TAG, metric='base.count', resolution='30', period='60', **settings):
count += int(series['points'][0]['avg'])
print "OK | count=%d;;;;" % count
sys.exit(0)
except Exception, e:
print "FAIL! %s" % e
sys.exit(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment