提交 3538b30667011f5ffc4abfee49db5e1a57c5bbc8
Merge branch 'master' of http://gitlab.ctune.cn/weijunh/DMapManager
2022.01.12
正在显示
4 个修改的文件
包含
57 行增加
和
53 行删除
@@ -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: { |
@@ -48,8 +48,8 @@ def pull_metric(): | @@ -48,8 +48,8 @@ def pull_metric(): | ||
48 | continue | 48 | continue |
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", | ||
52 | - "disk_write_count","network_sent","network_recv"] | 51 | + "disk_read", "disk_write", "disk_read_count", |
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) |
@@ -88,28 +88,30 @@ def start_schedule(): | @@ -88,28 +88,30 @@ def start_schedule(): | ||
88 | def get_sample_data(orginal, name, host): | 88 | def get_sample_data(orginal, name, host): |
89 | res = [] | 89 | res = [] |
90 | size = len(orginal) | 90 | size = len(orginal) |
91 | - orginal_stamp = {'head': 1, 'tail': size} | 91 | + # orginal_stamp = {'head': 1, 'tail': size} |
92 | if size > 1: | 92 | if size > 1: |
93 | - stamp = {'P0': 1, | ||
94 | - 'P50': math.floor(0.5*size), | ||
95 | - 'P90': math.floor(0.9*size), | ||
96 | - 'P95': math.floor(0.95*size), | ||
97 | - # 'P99': math.floor(0.99*size), | ||
98 | - 'P100': size} | 93 | + stamp = { |
94 | + # 'P0': 1, | ||
95 | + 'P50': math.floor(0.5*size), | ||
96 | + # 'P90': math.floor(0.9*size), | ||
97 | + 'P95': math.floor(0.95*size), | ||
98 | + # 'P99': math.floor(0.99*size), | ||
99 | + 'P100': size} | ||
99 | elif size == 1: | 100 | elif size == 1: |
100 | - stamp = {'P0': 1, | ||
101 | - 'P50': size, | ||
102 | - 'P90': size, | ||
103 | - 'P95': size, | ||
104 | - # 'P99': size, | ||
105 | - 'P100': size} | 101 | + stamp = { |
102 | + # 'P0': 1, | ||
103 | + 'P50': size, | ||
104 | + # 'P90': size, | ||
105 | + 'P95': size, | ||
106 | + # 'P99': size, | ||
107 | + 'P100': size} | ||
106 | else: | 108 | else: |
107 | return res | 109 | return res |
108 | 110 | ||
109 | - for key in dict.keys(orginal_stamp): | ||
110 | - cur_data = orginal[orginal_stamp[key]-1] | ||
111 | - info = get_data(key, host, name, cur_data) | ||
112 | - res.append(info) | 111 | + # for key in dict.keys(orginal_stamp): |
112 | + # cur_data = orginal[orginal_stamp[key]-1] | ||
113 | + # info = get_data(key, host, name, cur_data) | ||
114 | + # res.append(info) | ||
113 | 115 | ||
114 | data = sorted(orginal, key=lambda x: x[name]) | 116 | data = sorted(orginal, key=lambda x: x[name]) |
115 | for key in dict.keys(stamp): | 117 | for key in dict.keys(stamp): |
请
注册
或
登录
后发表评论