From 50f44afd826d1f459ab13205ba181eda280c1e51 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Tue, 4 Jun 2024 01:48:47 +0800 Subject: [PATCH] update --- plugins/task_manager/js/task_manager.js | 3 +- plugins/task_manager/task_manager_index.py | 42 ++++++++++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/plugins/task_manager/js/task_manager.js b/plugins/task_manager/js/task_manager.js index a48cd22425..2485814caa 100644 --- a/plugins/task_manager/js/task_manager.js +++ b/plugins/task_manager/js/task_manager.js @@ -745,7 +745,6 @@ function get_service_list() { var loadT = layer.msg('正在获取服务列表..', {icon: 16, time: 0, shade: [0.3, '#000']}); tmPostCallback('get_service_list', {search:search_val}, function(rdata){ layer.close(loadT); - if (rdata.data['is_mac']){ tbody_tr += "mac无法使用"; var tbody = '\ @@ -939,7 +938,7 @@ function pkill_session(pts) { var loadT = layer.msg('正在断开会话..', {icon: 16, time: 0, shade: [0.3, '#000']}); tmPostCallback('pkill_session', {pts:pts}, function(data){ layer.close(loadT); - + var rdata = data.data; layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2}); if (rdata.status){ diff --git a/plugins/task_manager/task_manager_index.py b/plugins/task_manager/task_manager_index.py index c798ddde5f..9e7518d6da 100755 --- a/plugins/task_manager/task_manager_index.py +++ b/plugins/task_manager/task_manager_index.py @@ -1117,6 +1117,42 @@ def get_run_list(self, get={}): data['run_list'] = self.search_run(data['run_list'], get['search']) return data + # 检查服务是否为系统服务get_systemctl_list——>引用cont_systemctl + def cont_systemctl(self, name): + conts = ['systemd', 'rhel', 'plymouth', 'rc-', '@', 'init', 'ipr', 'dbus', '-local'] + for c in conts: + if name.find(c) != -1: return False + return True + + # 获取系统服务运行级别 get_service_list——>引用get_systemctl_list + def get_systemctl_list(self, serviceList, runlevel): + systemctl_user_path = '/usr/lib/systemd/system/' + systemctl_run_path = '/etc/systemd/system/multi-user.target.wants/' + if not os.path.exists(systemctl_user_path) or not os.path.exists(systemctl_run_path): return serviceList + r = '.service' + for d in os.listdir(systemctl_user_path): + if d.find(r) == -1: continue; + if not self.cont_systemctl(d): continue; + isrun = '关闭' + serviceInfo = {} + serviceInfo['name'] = d.replace(r, '') + serviceInfo['runlevel_0'] = isrun + serviceInfo['runlevel_1'] = isrun + serviceInfo['runlevel_2'] = isrun + serviceInfo['runlevel_3'] = isrun + serviceInfo['runlevel_4'] = isrun + serviceInfo['runlevel_5'] = isrun + serviceInfo['runlevel_6'] = isrun + if os.path.exists(systemctl_run_path + d): + isrun = '开启' + serviceInfo['runlevel_' + runlevel] = isrun + serviceInfo['runlevel_3'] = isrun + serviceInfo['runlevel_5'] = isrun + + serviceInfo['ps'] = self.get_run_ps(serviceInfo['name']) + serviceList.append(serviceInfo) + return serviceList + # 外部接口 查询服务启动级别 /etc/init.d/ def get_service_list(self, get = {}): data = {} @@ -1148,9 +1184,9 @@ def get_service_list(self, get = {}): data['runlevel'] = self.get_my_runlevel() data['serviceList'] = sorted(serviceList, key=lambda x: x['name'], reverse=False) data['serviceList'] = self.get_systemctl_list(data['serviceList'], data['runlevel']) - if hasattr(get, 'search'): - if get.search != '': - data['serviceList'] = self.search_service(data['serviceList'], get.search) + if 'search' in get: + if get['search'] != '': + data['serviceList'] = self.search_service(data['serviceList'], get['search']) return data # 获取存放计划任务的路径