Advertisement
Guest User

Untitled

a guest
Jun 15th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. from influxdb import InfluxDBClient
  4. import datetime
  5.  
  6. def annotate():
  7.  
  8. _host = 'localhost'
  9. _port = 8086
  10. _user = "root"
  11. _pass = "root"
  12. _dbname = 'telegraf'
  13.  
  14. annotation_body = [
  15. {
  16. "measurement": "events",
  17. "tags": {
  18. "type": "start"
  19. "text": "This is the start"
  20. },
  21. "time": datetime.datetime.utcnow().isoformat(),
  22. }
  23. ]
  24.  
  25. client = InfluxDBClient(_host, _port, _user, _pass, _dbname)
  26.  
  27. try:
  28. client.create_database(_dbname)
  29. except:
  30. pass
  31.  
  32. client.switch_database(_dbname)
  33. client.switch_user(_user, _pass)
  34.  
  35. print annotation_body
  36.  
  37. if __name__ == '__main__':
  38. annotate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement