Esempio n. 1
0
    def _get_data(self, query):
        global _QUERY_CACHE
        if not query in _QUERY_CACHE:
            connection = Connection()
            _QUERY_CACHE[query] = connection.nodes.read(query=query)

        return _QUERY_CACHE[query]
Esempio n. 2
0
  ts = []
  for p in  data['metrics'][0]['data']:
    d.append(float(p['avg']))
    ts.append(p['ts'])

  # Chart size of 200x125 pixels and specifying the range for the Y axis
  max_y = int(max(d))
  chart = SimpleLineChart(450, 250, y_range=[0,max_y])
  chart.add_data(d)
  left_axis = range(0, max_y + 1, max_y/5)
  left_axis[0] = ''
  chart.set_axis_labels(Axis.LEFT, left_axis)
  min_dt = datetime.fromtimestamp(min(ts))
  max_dt = datetime.fromtimestamp(max(ts))
  chart.set_axis_labels(Axis.BOTTOM, [ str(min_dt), str(max_dt) ])
  title = '%s.%s.%s' % (node['name'], check['type'], metric)
  chart.set_title(title)
  return chart.get_url()

if __name__ == "__main__":
  c = Connection()
  nodes = c.nodes()
  node = nodes[20]
  print node
  checks = c.checks(node['id'])
  print checks
  check = checks[0][node['id']][0]
  print check
  metric = check['metrics'][1]
  print gchart(c, node=node, check=check, metric=metric)
Esempio n. 3
0
def _get_data():
    global _CACHED_NODES
    if _CACHED_NODES is None:
        c = Connection()
        _CACHED_NODES = c.nodes()
    return _CACHED_NODES
Esempio n. 4
0
  # Chart size of 200x125 pixels and specifying the range for the Y axis
  max_y = int(max(d))
  chart = SimpleLineChart(450, 250, y_range=[0,max_y])
  chart.add_data(d)
  left_axis = range(0, max_y + 1, max_y/5)
  left_axis[0] = ''
  chart.set_axis_labels(Axis.LEFT, left_axis)
  min_dt = datetime.fromtimestamp(min(ts))
  max_dt = datetime.fromtimestamp(max(ts))
  chart.set_axis_labels(Axis.BOTTOM, [ str(min_dt), str(max_dt) ])
  title = '%s.%s.%s' % (node['name'], check['type'], metric)
  chart.set_title(title)
  return chart.get_url()

if __name__ == "__main__":
  c = Connection()
  nodes = c.nodes.read()["items"]
  node = nodes[-1]
  print
  print "NODE", node
  checks = c.checks.read(node_ids=node['id'])
  print
  print "CHECKS: found", len(checks["items"])
  check = checks["items"][0]
  print "CHECK", check
  #metric = check["metrics"] # this isn't implemented
  metric = "duraction"
  #data = conn.data(check['id'], name=metric, start=start, end=end) # this isn't implemented either
  #print gchart(c, node=node, check=check, metric=metric)