Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.

Commit 3048b16

Browse files
committed
[Update] 修改心跳数据
1 parent 4d98807 commit 3048b16

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

jms/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def valid_auth(self):
7979
user = self.get_profile()
8080
if not user:
8181
msg = "Connect server error or access key is invalid, " \
82-
"remove `./keys/.access_key` run again"
82+
"remove `./data/keys/.access_key` run again"
8383
logger.error(msg)
8484
delay += 3
8585
time.sleep(3)

jms/terminal.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ def register_terminal_v2(self, name, token, comment="Coco"):
7171
return terminal
7272
else:
7373
msg = resp.content.decode()
74-
if msg.find("unique") >= 0:
75-
msg = "The name have been used: {}".format(name)
74+
if msg.find("unique"):
75+
msg = "The name have been used: {} {}".format(name, msg)
7676
logger.error(msg)
7777
return None
7878

79-
def terminal_heartbeat(self, sessions):
79+
def terminal_heartbeat(self, data):
8080
"""和Jumpserver维持心跳, 当Terminal断线后,jumpserver可以知晓
8181
8282
:return tasks that this terminal need handle
@@ -93,24 +93,6 @@ def terminal_heartbeat(self, sessions):
9393
"session_online": 10
9494
}
9595
"""
96-
p = psutil.Process(os.getpid())
97-
cpu_used = p.cpu_percent(interval=1.0)
98-
memory_used = int(p.memory_info().rss / 1024 / 1024)
99-
connections = len(p.connections())
100-
threads = p.num_threads()
101-
session_online = len([s for s in sessions if not s["is_finished"]])
102-
# logger.debug("CPU: {} MEM: {}M CONN: {} THRE: {} SESS: {}".format(
103-
# cpu_used, memory_used, connections, threads, session_online
104-
# ))
105-
data = {
106-
"cpu_used": cpu_used,
107-
"memory_used": memory_used,
108-
"connections": connections,
109-
"threads": threads,
110-
"boot_time": p.create_time(),
111-
"session_online": session_online,
112-
"sessions": sessions,
113-
}
11496
try:
11597
resp = self.http.post('terminal-heartbeat', data=data, use_auth=True)
11698
except (ResponseError, RequestError) as e:

0 commit comments

Comments
 (0)