def monitor_graphite_groups(): """graphite key 与 group 关联 """ graphitekey = db.session.query(GraphiteKeys).all() db.session.close() keys = [] for s in graphitekey: keys.append({"value": s.id, "text": s.name}) tv = Treeview() treeview = tv.get() #print "打印keys" #print keys #[{'text': u'system.cpu.load1', 'value': 1L}, {'text': u'system.cpu.load5', 'value': 2L}, {'text': u'system.cpu.load15', 'value': 3L}] #print json.dumps(keys) #[{"text": "system.cpu.load1", "value": 1}, {"text": "system.cpu.load5", "value": 2}, {"text": "system.cpu.load15", "value": 3}] #print "打印treeview" #print treeview #[{'text': u'MS', 'nodes': [{'text': u'APP', 'pid': 1L, 'type': 'product', 'id': 3L}, {'text': u'Web', 'pid': 1L, 'type': 'product', 'id': 2L}], 'type': 'service', 'id': 1L}] #print json.dumps(treeview) #[{"text": "MS", "nodes": [{"text": "APP", "pid": 1, "type": "product", "id": 3}, {"text": "Web", "pid": 1, "type": "product", "id": 2}], "type": "service", "id": 1}] return render_template("monitor/graphite_group_keys.html", treeview=json.dumps(treeview), hosts=json.dumps(keys), show_monitor=True, show_graphite_groups=True)
def monitor_zabbix(): zb = Zabbix() templates = zb.zb.template.get(ouput=["templateid","name"]) templates_data = [] for temp in templates: templates_data.append({"label":temp['name'],"value": temp['templateid']}) tv = Treeview() treeview = tv.get() return render_template("monitor/monitor_zabbix.html", treeview=json.dumps(treeview),templates=json.dumps(templates_data))
def monitor_zabbix(): zb = Zabbix() templates = zb.zb.template.get(output=["templateid", "name"]) templates_data = [] for temp in templates: templates_data.append({"label": temp["name"], "value": temp["templateid"]}) tv = Treeview() treeview = tv.get() return render_template("monitor/monitor_zabbix.html", treeview = json.dumps(treeview), templates = json.dumps(templates_data))
def monitor_graphite_groups(): """graphite key 与 group 关联 """ graphitekey = db.session.query(GraphiteKeys).all() db.session.close() keys = [] for s in graphitekey: keys.append({"value": s.id, "text": s.name}) tv = Treeview() treeview = tv.get() return render_template("monitor/graphite_group_keys.html", treeview=json.dumps(treeview), hosts=json.dumps(keys))
def monitor_zabbix(): zb = Zabbix() templates = zb.zb.template.get(output=["templateid", "name"]) # [{u'name': u'Template OS Linux', u'templateid': u'10001'},.......] #print templates templates_data = [] for temp in templates: templates_data.append({ "label": temp['name'], "value": temp['templateid'] }) tv = Treeview() treeview = tv.get() #[{'value': u'10001', 'label': u'Template OS Linux'},.......] #print templates_data #[{'text': u'ms', 'nodes': [{'text': u'app', 'pid': 1L, 'type': 'product', 'id': 3L}, {'text': u'web', 'pid': 1L, 'type': 'product', 'id': 2L}], 'type': 'service', 'id': 1L}] #print treeview return render_template("monitor/monitor_zabbix.html", treeview=json.dumps(treeview), templates=json.dumps(templates_data), show_zabbix=True, show_monitor=True)