basic.py 1.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Copyright 2014 Budapest University of Technology and Economics (BME IK)
#
# This file is part of CIRCLE Cloud.
#
# CIRCLE is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# CIRCLE is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with CIRCLE.  If not, see <http://www.gnu.org/licenses/>.

Őry Máté committed
18
from calvin import *  # noqa
Nagy Gergő committed
19 20 21 22 23 24 25

server_name = "0.0.0.0"
server_port = "8080"

query = Query()
query.setTarget("1889.foo.fook.fookie.com.DOMAIN")
query.setMetric("cpu.usage")
Őry Máté committed
26 27
query.setFormat("json")  # Not neccesary, default is json
query.setRelativeStart(1, "minutes")  # Current cpu usage
Nagy Gergő committed
28 29

query.generate()
Őry Máté committed
30
# print(query.getGenerated())
Nagy Gergő committed
31 32

print(query.getStart())
Őry Máté committed
33 34 35
# query.setAbsoluteStart("1889", "04", "20", "00", "00")
# query.setRelativeEnd(...)
# query.setAbsoluteEnd(...)
Nagy Gergő committed
36 37 38 39 40 41 42 43 44

handler = GraphiteHandler(server_name, server_port)

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

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