SHARE
TWEET

Untitled

a guest Jan 11th, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import graphitesend
  2. import redis
  3. import os
  4. import time
  5. import sys
  6.  
  7. pattern = '%Y-%m-%d %H:%M:%S'
  8.  
  9. g = graphitesend.init(prefix='devops.dotshipper',graphite_server='dograph2.docl.nic')
  10.  
  11. r = redis.StrictRedis(host='dotshipper2.docl.nic', port=6379, db=0)
  12.  
  13. counter = r.get('counter')
  14.  
  15. try:
  16.     keystring = sys.argv[1]
  17.     klist = keystring.split('-')
  18.     int(klist[1])
  19. except:
  20.     keystring = 'run-%07d' % int(counter)
  21.  
  22. print("Got current keystring of " + str(keystring))
  23.  
  24.  
  25. epochdate_from = None
  26. epochdate_to = None
  27. resultscount_counts = None
  28. resultscount_rows = None
  29. total_runtime = None
  30. timedelta_seconds = None
  31.  
  32. keys = r.hgetall(keystring)
  33. for key in keys:
  34.     if key == 'from':
  35.         epochdate_from = int(time.mktime(time.strptime(r.hget(keystring,key),pattern)))
  36.     if key == 'to':
  37.         epochdate_to = int(time.mktime(time.strptime(r.hget(keystring,key),pattern)))
  38.     if key == 'resultscount_counts':
  39.         resultscount_counts = r.hget(keystring,key)
  40.     if key == 'resultscount_rows':
  41.         resultscount_rows = r.hget(keystring,key)
  42.     if key == 'total_runtime':
  43.         total_runtime = r.hget(keystring,key)
  44.     if key == 'timedelta_seconds':
  45.         timedelta_seconds = r.hget(keystring,key)
  46.  
  47. # first push from/to with counts count
  48. g.send('total_offerserved_counts',resultscount_counts,timestamp=epochdate_from)
  49. g.send('total_offerserved_counts',resultscount_counts,timestamp=epochdate_to)
  50.  
  51. g.send('resultscount_rows', resultscount_rows, timestamp=epochdate_to)
  52. g.send('resultscount_counts', resultscount_counts, timestamp=epochdate_to)
  53. g.send('total_runtime', total_runtime, timestamp=epochdate_to)
  54. g.send('timedelta_seconds', timedelta_seconds, timestamp=epochdate_to)
RAW Paste Data
Top