本文整理匯總了Python中rrd.model.graph.TmpGraph.add方法的典型用法代碼示例。如果您正苦於以下問題:Python TmpGraph.add方法的具體用法?Python TmpGraph.add怎麽用?Python TmpGraph.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rrd.model.graph.TmpGraph
的用法示例。
在下文中一共展示了TmpGraph.add方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: chart
# 需要導入模塊: from rrd.model.graph import TmpGraph [as 別名]
# 或者: from rrd.model.graph.TmpGraph import add [as 別名]
def chart():
endpoints = request.form.getlist("endpoints[]") or []
counters = request.form.getlist("counters[]") or []
graph_type = request.form.get("graph_type") or GRAPH_TYPE_HOST
endpoints = sorted(set(endpoints))
group_objs = Group.gets_by_group(endpoints)
if len(group_objs) > 0:
group_ids = [x.id for x in group_objs]
grouphost_objs = GroupHost.search(group_ids)
host_ids = [x.hostId for x in grouphost_objs]
host_objs = Host.search(host_ids)
endpoint_names = [x.name for x in host_objs]
id_ = TmpGraph.add(endpoint_names, counters)
else:
id_ = TmpGraph.add(endpoints, counters)
ret = {
"ok": False,
"id": id_,
"params": {
"graph_type": graph_type,
},
}
if id_:
ret['ok'] = True
return json.dumps(ret)
示例2: charts
# 需要導入模塊: from rrd.model.graph import TmpGraph [as 別名]
# 或者: from rrd.model.graph.TmpGraph import add [as 別名]
def charts():
if not g.id:
abort(400, "no graph id given")
tmp_graph = TmpGraph.get(g.id)
if not tmp_graph:
abort(404, "no graph which id is %s" %g.id)
counters = tmp_graph.counters
if not counters:
abort(400, "no counters of %s" %g.id)
counters = sorted(set(counters))
endpoints = tmp_graph.endpoints
if not endpoints:
abort(400, "no endpoints of %s" %g.id)
endpoints = sorted(set(endpoints))
chart_urls = []
chart_ids = []
p = {
"id": "",
"legend": g.legend,
"cf": g.cf,
"sum": g.sum,
"graph_type": g.graph_type,
"nav_header": g.nav_header,
"start": g.start,
"end": g.end,
}
if g.graph_type == GRAPH_TYPE_KEY:
for x in endpoints:
id_ = TmpGraph.add([x], counters)
if not id_:
continue
p["id"] = id_
chart_ids.append(int(id_))
src = "/chart/h?" + urllib.urlencode(p)
chart_urls.append(src)
elif g.graph_type == GRAPH_TYPE_HOST:
for x in counters:
id_ = TmpGraph.add(endpoints, [x])
if not id_:
continue
p["id"] = id_
chart_ids.append(int(id_))
src = "/chart/h?" + urllib.urlencode(p)
chart_urls.append(src)
else:
id_ = TmpGraph.add(endpoints, counters)
if id_:
p["id"] = id_
chart_ids.append(int(id_))
src = "/chart/a?" + urllib.urlencode(p)
chart_urls.append(src)
return render_template("chart/multi_ng.html", **locals())
示例3: chart
# 需要導入模塊: from rrd.model.graph import TmpGraph [as 別名]
# 或者: from rrd.model.graph.TmpGraph import add [as 別名]
def chart():
endpoints = request.form.getlist("endpoints[]") or []
counters = request.form.getlist("counters[]") or []
graph_type = request.form.get("graph_type") or GRAPH_TYPE_HOST
id_ = TmpGraph.add(endpoints, counters)
ret = {"ok": False, "id": id_, "params": {"graph_type": graph_type}}
if id_:
ret["ok"] = True
return json.dumps(ret)
示例4: api_create_tmpgraph
# 需要導入模塊: from rrd.model.graph import TmpGraph [as 別名]
# 或者: from rrd.model.graph.TmpGraph import add [as 別名]
def api_create_tmpgraph():
d = request.data
jdata = json.loads(d)
endpoints = jdata.get("endpoints") or []
counters = jdata.get("counters") or []
id_ = TmpGraph.add(endpoints, counters)
ret = {"ok": False, "id": id_}
if id_:
ret["ok"] = True
return json.dumps(ret)
else:
return json.dumps(ret)
示例5: get_endpoint_detail_charts
# 需要導入模塊: from rrd.model.graph import TmpGraph [as 別名]
# 或者: from rrd.model.graph.TmpGraph import add [as 別名]
def get_endpoint_detail_charts():
counters = []
endpoints = []
counters0 = request.form.getlist("counters[]") or []
graph_type = request.form.get("graph_type") or GRAPH_TYPE_HOST
endpoint0 = request.form.get("endpoint") or ""
qtype = request.form.get("type") or ""
endpointlist = Endpoint.search_agent_and_httpapi_by_endpoint(endpoint0)
for endpoint in endpointlist:
endpoints.append(endpoint.endpoint)
for counter in counters0:
if counter == "port":
counters.append("net.port.listen/port=" + endpoint.id)
elif counter == "memory":
counters.append("mem.memfree.percent")
elif counter == "df":
counters.append("df.statistics.used.percent")
else:
if (qtype == "mysql" or qtype == "redis"):
counters.append(counter + endpoint.id)
else:
counters.append(counter)
endpoints.append(endpoint0)
print endpoints
print counters
id_ = TmpGraph.add(endpoints, counters)
ret = {
"ok": False,
"id": id_,
"params": {
"graph_type": graph_type,
},
}
if id_:
ret['ok'] = True
return json.dumps(ret)
示例6: create_tmp_graph
# 需要導入模塊: from rrd.model.graph import TmpGraph [as 別名]
# 或者: from rrd.model.graph.TmpGraph import add [as 別名]
def create_tmp_graph(endpoints, counters):
id_ = TmpGraph.add(endpoints, counters)
return id_
示例7: api_charts
# 需要導入模塊: from rrd.model.graph import TmpGraph [as 別名]
# 或者: from rrd.model.graph.TmpGraph import add [as 別名]
def api_charts():
ret = {
"ok":True,
"msg":"",
"chart_ids":[],
"chart_urls":[]
}
p = {
"id": "",
"legend": g.legend,
"cf": g.cf,
"sum": g.sum,
"graph_type": g.graph_type,
"nav_header": g.nav_header,
"start": g.start,
"end": g.end,
}
if not g.id:
abort(400, "no graph id given")
tmp_graph = TmpGraph.get(g.id)
if not tmp_graph:
abort(400,"no graph which id is %s" % g.id)
counters = tmp_graph.counters
if not counters:
abort(400, "no counters of %s" %g.id)
counters = sorted(set(counters))
endpoints = tmp_graph.endpoints
if not endpoints:
abort(400, "no endpoints of %s" %g.id)
endpoints = sorted(set(endpoints))
index = request.args.get("index",0)
cur = int(index)
chart_ids = []
chart_urls = []
max_load_graph = int(CHART_MAX_LOAD_GRAPH)
if g.graph_type == GRAPH_TYPE_KEY:
for x in endpoints[cur:cur+max_load_graph]:
id_ = TmpGraph.add([x],counters)
if not id_:
continue
p["id"] = id_
chart_ids.append(int(id_))
src = "/chart/k?" + urllib.urlencode(p)
chart_urls.append(src)
if g.graph_type == GRAPH_TYPE_HOST:
for x in counters[cur:cur+max_load_graph]:
id_ = TmpGraph.add(endpoints, [x])
if not id_:
continue
p["id"] = id_
chart_ids.append(int(id_))
src = "/chart/h?" + urllib.urlencode(p)
chart_urls.append(src)
ret['chart_ids'] = chart_ids
ret['chart_urls'] = chart_urls
return json.dumps(ret)
示例8: chart
# 需要導入模塊: from rrd.model.graph import TmpGraph [as 別名]
# 或者: from rrd.model.graph.TmpGraph import add [as 別名]
def chart():
data = request.json or ""
type = data['type']
endpoints = []
counters_ = data['counters']
counters = []
graph_type = data['graph_type'] or GRAPH_TYPE_HOST
containers = []
if not type:
return "no type given"
if type == "node":
endpoints = data['data']
counters = counters_
elif type == "pod":
for pod in data['data']:
for container in pod['containers']:
node = container['hostname']
containers.append(container['containerId'])
for counter in counters_:
counters.append(counter + "/id=" + container['containerId'])
if len(endpoints) == 0:
endpoints.append(node)
else:
p = 1
for endpoint in endpoints:
if endpoint == node:
break
else:
p = p + 1
if p != len(endpoints):
endpoints.append(node)
elif type == "container":
for container in data['data']:
node = container['hostname']
containers.append(container['containerId'])
for counter in counters_:
counters.append(counter + "/id=" + container['containerId'])
if len(endpoints) == 0:
endpoints.append(node)
else:
p = 1
for endpoint in endpoints:
if endpoint == node:
break
else:
p = p + 1
if p != len(endpoints):
endpoints.append(node)
id_ = TmpGraph.add(endpoints, counters)
domeosid_ = DomeosGraph.add(id_, type, json.dumps(data['data']))
ret = {
"ok": False,
"id": id_,
"domeosid": domeosid_,
"params": {
"graph_type": graph_type,
},
}
if id_ and domeosid_:
ret['ok'] = True
return json.dumps(ret)
示例9: chart_big
# 需要導入模塊: from rrd.model.graph import TmpGraph [as 別名]
# 或者: from rrd.model.graph.TmpGraph import add [as 別名]
def chart_big():
if not g.id:
abort(400, "no graph id given")
tmp_graph = TmpGraph.get(g.id)
if not tmp_graph:
abort(404, "no graph which id is %s" %g.id)
if not tmp_graph.counters[0]:
abort(404, "no counter given")
domeosid = g.domeosid
if not domeosid:
abort(400, "no domeos graph id given")
domeos_graph = DomeosGraph.get(g.domeosid)
if not domeos_graph:
abort(404, "no domeos graph which id is %s" %g.domeosid)
domeos_type = domeos_graph.type
if not domeos_type:
abort(400, "no domeos type of %s" %g.domeosid)
domeos_data = domeos_graph.data
chart_urls = []
chart_ids = []
if domeos_type == 'container':
containers = json.loads(domeos_data)
for container in containers:
endpoint = []
endpoint.append(container['hostname'])
counter = []
counter.append( tmp_graph.counters[0].split('/')[0] + '/id=' + container['containerId'])
id_ = TmpGraph.add(endpoint, counter)
if not id_:
continue
chart_ids.append(int(id_))
p = {
"id": "",
"legend": g.legend,
"cf": g.cf,
"sum": g.sum,
"graph_type": g.graph_type,
"nav_header": g.nav_header,
"start": g.start,
"end": g.end,
}
src = "/chart/h?" + urllib.urlencode(p)
chart_urls.append(src)
elif domeos_type == 'pod':
pods = json.loads(domeos_data)
for pod in pods:
for container in pod['containers']:
endpoint = []
endpoint.append(container['hostname'])
counter = []
counter.append( tmp_graph.counters[0].split('/')[0] + '/id=' + container['containerId'])
id_ = TmpGraph.add(endpoint, counter)
if not id_:
continue
chart_ids.append(int(id_))
p = {
"id": "",
"legend": g.legend,
"cf": g.cf,
"sum": g.sum,
"graph_type": g.graph_type,
"nav_header": g.nav_header,
"start": g.start,
"end": g.end,
}
src = "/chart/h?" + urllib.urlencode(p)
chart_urls.append(src)
return render_template("chart/big_ng.html", **locals())