Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
midoks committed Jun 3, 2024
1 parent 9884bbd commit 50f44af
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
3 changes: 1 addition & 2 deletions plugins/task_manager/js/task_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 += "<tr><td colspan='10' style='text-align:center;'>mac无法使用</td></tr>";
var tbody = '<thead>\
Expand Down Expand Up @@ -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){
Expand Down
42 changes: 39 additions & 3 deletions plugins/task_manager/task_manager_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<span style="color:red;" title="点击开启">关闭</span>'
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 = '<span style="color:green;" title="点击关闭">开启</span>'
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 = {}
Expand Down Expand Up @@ -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

# 获取存放计划任务的路径
Expand Down

0 comments on commit 50f44af

Please sign in to comment.