basic.py 636 Bytes
Newer Older
Nagy Gergő committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
from calvin import *

server_name = "0.0.0.0"
server_port = "8080"

query = Query()
query.setTarget("1889.foo.fook.fookie.com.DOMAIN")
query.setMetric("cpu.usage")
query.setFormat("json") # Not neccesary, default is json
query.setRelativeStart(1, "minutes") # Current cpu usage

query.generate()
# print(query.getGenerated())

print(query.getStart())
# query.setAbsoluteStart("1889", "04", "20", "00", "00")
# query.setRelativeEnd(...)
# query.setAbsoluteEnd(...)

handler = GraphiteHandler(server_name, server_port)

handler.put(query)
handler.send()
response = handler.pop()

print(response["target"])
print(response["datapoints"])