monitor_host_list.py
1.3 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from sqlalchemy.sql.functions import func
from .models import MonitorHost, db
from sqlalchemy import and_
from app.util.component.ApiTemplate import ApiTemplate
class Api(ApiTemplate):
api_name = "监控主机列表"
def process(self):
# 返回结果
res = {}
res["data"] = []
logs = []
try:
datas = db.session.query(
MonitorHost.host.label("host"), MonitorHost.srcid.label(
"srcid"), MonitorHost.type.label("type"),
MonitorHost.host_name.label("host_name"),
MonitorHost.user.label("user")).all()
res["data"] = list(map(lambda data:
{'host': data.host, 'srcid': data.srcid,
'type': data.type, 'host_name': data.host_name,
'user': data.user},
datas))
res["result"] = True
except Exception as e:
raise e
return res
api_doc = {
"tags": ["监控接口"],
"parameters": [
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}