提交 dac80d95d2d0a4e377b2c58969ebb00df979f65e

作者 qianyingz
1 个父辈 5bde3e49

监控模块

@@ -127,14 +127,16 @@ class Api(ApiTemplate): @@ -127,14 +127,16 @@ class Api(ApiTemplate):
127 size = len(orginal) 127 size = len(orginal)
128 orginal_stamp = {'head': 1, 'tail': size} 128 orginal_stamp = {'head': 1, 'tail': size}
129 if size > 1: 129 if size > 1:
130 - stamp = {'P0': 1, 130 + stamp = {
  131 + # 'P0': 1,
131 'P50': math.floor(0.5*size), 132 'P50': math.floor(0.5*size),
132 'P90': math.floor(0.9*size), 133 'P90': math.floor(0.9*size),
133 'P95': math.floor(0.95*size), 134 'P95': math.floor(0.95*size),
134 # 'P99': math.floor(0.99*size), 135 # 'P99': math.floor(0.99*size),
135 'P100': size} 136 'P100': size}
136 elif size == 1: 137 elif size == 1:
137 - stamp = {'P0': 1, 138 + stamp = {
  139 + # 'P0': 1,
138 'P50': size, 140 'P50': size,
139 'P90': size, 141 'P90': size,
140 'P95': size, 142 'P95': size,
@@ -10,12 +10,12 @@ class Api(ApiTemplate): @@ -10,12 +10,12 @@ class Api(ApiTemplate):
10 def para_check(self): 10 def para_check(self):
11 if not self.para.get("host"): 11 if not self.para.get("host"):
12 raise Exception("缺乏host参数") 12 raise Exception("缺乏host参数")
13 - if not self.para.get("user"):  
14 - raise Exception("缺乏user参数")  
15 - if not self.para.get("type"):  
16 - raise Exception("缺乏type参数")  
17 - if not self.para.get("passwd"):  
18 - raise Exception("缺乏passwd参数") 13 + # if not self.para.get("user"):
  14 + # raise Exception("缺乏user参数")
  15 + # if not self.para.get("type"):
  16 + # raise Exception("缺乏type参数")
  17 + # if not self.para.get("passwd"):
  18 + # raise Exception("缺乏passwd参数")
19 19
20 def process(self): 20 def process(self):
21 21
@@ -24,9 +24,9 @@ class Api(ApiTemplate): @@ -24,9 +24,9 @@ class Api(ApiTemplate):
24 res["data"] = {} 24 res["data"] = {}
25 try: 25 try:
26 host = self.para.get("host") # server 26 host = self.para.get("host") # server
27 - user = self.para.get("user")  
28 - password = self.para.get("passwd")  
29 - type = self.para.get("type") 27 + # user = self.para.get("user")
  28 + # password = self.para.get("passwd")
  29 + # type = self.para.get("type")
30 host_name = self.para.get("host_name") 30 host_name = self.para.get("host_name")
31 srcid = uuid.uuid1().__str__() 31 srcid = uuid.uuid1().__str__()
32 32
@@ -35,7 +35,7 @@ class Api(ApiTemplate): @@ -35,7 +35,7 @@ class Api(ApiTemplate):
35 res["result"] = False 35 res["result"] = False
36 else: 36 else:
37 monitorHost = MonitorHost( 37 monitorHost = MonitorHost(
38 - srcid=srcid, host=host, user=user, password=password, type=type, host_name=host_name) 38 + srcid=srcid, host=host, host_name=host_name)
39 db.session.add(monitorHost) 39 db.session.add(monitorHost)
40 db.session.commit() 40 db.session.commit()
41 res['data'] = {'host': host, 'srcid': srcid} 41 res['data'] = {'host': host, 'srcid': srcid}
@@ -53,21 +53,21 @@ class Api(ApiTemplate): @@ -53,21 +53,21 @@ class Api(ApiTemplate):
53 "type": "string", 53 "type": "string",
54 "description": "主机地址", 54 "description": "主机地址",
55 "required": "true"}, 55 "required": "true"},
56 - {"name": "user",  
57 - "in": "formData",  
58 - "type": "string",  
59 - "description": "用户",  
60 - "required": "true"},  
61 - {"name": "passwd",  
62 - "in": "formData",  
63 - "type": "string",  
64 - "description": "密码",  
65 - "required": "true"},  
66 - {"name": "type",  
67 - "in": "formData",  
68 - "type": "string",  
69 - "description": "服务器类型",  
70 - "required": "true"}, 56 + # {"name": "user",
  57 + # "in": "formData",
  58 + # "type": "string",
  59 + # "description": "用户",
  60 + # "required": "true"},
  61 + # {"name": "passwd",
  62 + # "in": "formData",
  63 + # "type": "string",
  64 + # "description": "密码",
  65 + # "required": "true"},
  66 + # {"name": "type",
  67 + # "in": "formData",
  68 + # "type": "string",
  69 + # "description": "服务器类型",
  70 + # "required": "true"},
71 {"name": "host_name", 71 {"name": "host_name",
72 "in": "formData", 72 "in": "formData",
73 "type": "string", 73 "type": "string",
@@ -18,14 +18,14 @@ class Api(ApiTemplate): @@ -18,14 +18,14 @@ class Api(ApiTemplate):
18 res["data"] = {} 18 res["data"] = {}
19 try: 19 try:
20 srcid = self.para.get("srcid") # server 20 srcid = self.para.get("srcid") # server
21 - passwd = self.para.get("passwd") 21 + passwd = None
22 host_name = self.para.get("host_name") 22 host_name = self.para.get("host_name")
23 # Catalog.query.filter_by(guid=self.para.get("guid")).update({"name":self.para.get("name")}) 23 # Catalog.query.filter_by(guid=self.para.get("guid")).update({"name":self.para.get("name")})
24 24
25 if passwd or host_name: 25 if passwd or host_name:
26 monitor_host = MonitorHost.query.filter_by(srcid=srcid) 26 monitor_host = MonitorHost.query.filter_by(srcid=srcid)
27 - if passwd:  
28 - monitor_host.update({"password": passwd}) 27 + # if passwd:
  28 + # monitor_host.update({"password": passwd})
29 if host_name: 29 if host_name:
30 monitor_host.update({"host_name": host_name}) 30 monitor_host.update({"host_name": host_name})
31 db.session.commit() 31 db.session.commit()
@@ -50,10 +50,10 @@ class Api(ApiTemplate): @@ -50,10 +50,10 @@ class Api(ApiTemplate):
50 "in": "formData", 50 "in": "formData",
51 "type": "string", 51 "type": "string",
52 "description": "主机名"}, 52 "description": "主机名"},
53 - {"name": "passwd",  
54 - "in": "formData",  
55 - "type": "string",  
56 - "description": "密码"} 53 + # {"name": "passwd",
  54 + # "in": "formData",
  55 + # "type": "string",
  56 + # "description": "密码"}
57 ], 57 ],
58 "responses": { 58 "responses": {
59 200: { 59 200: {
@@ -49,7 +49,7 @@ def pull_metric(): @@ -49,7 +49,7 @@ def pull_metric():
49 49
50 type_list = ["cpu_per", "memory_per", "disk_per", 50 type_list = ["cpu_per", "memory_per", "disk_per",
51 "disk_read", "disk_write","disk_read_count", 51 "disk_read", "disk_write","disk_read_count",
52 - "disk_write_count","network_sent","network_recv"] 52 + "disk_write_count","network_send","network_recv"]
53 for type in type_list: 53 for type in type_list:
54 sample_data = get_sample_data( 54 sample_data = get_sample_data(
55 metric_data, type, host_name) 55 metric_data, type, host_name)
注册登录 后发表评论