mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-24 03:35:59 +08:00
在 widget 上显示进程列表
This commit is contained in:
@@ -19,9 +19,9 @@ exports.post '/update_password', (req, res) ->
|
||||
unless req.body.password or not /^[A-Za-z0-9\-_]+$/.test req.body.password
|
||||
return res.error 'invalid_password'
|
||||
|
||||
child_process.exec "echo '#{req.account.username}:#{req.body.password}' | sudo chpassword", (err, stdout, stderr) ->
|
||||
throw err if err
|
||||
res.json {}
|
||||
child_process.exec "echo '#{req.account.username}:#{req.body.password}' | sudo chpasswd", (err, stdout, stderr) ->
|
||||
throw err if err
|
||||
res.json 200, {}
|
||||
|
||||
exports.post '/kill', (req, res) ->
|
||||
pid = parseInt req.body.pid
|
||||
|
||||
@@ -3,6 +3,7 @@ jade = require 'jade'
|
||||
path = require 'path'
|
||||
|
||||
plugin = require '../../core/plugin'
|
||||
monitor = require '../linux/monitor'
|
||||
|
||||
module.exports =
|
||||
enable: (account, callback) ->
|
||||
@@ -24,8 +25,17 @@ module.exports =
|
||||
callback()
|
||||
|
||||
widget: (account, callback) ->
|
||||
jade.renderFile path.join(__dirname, 'view/widget.jade'), {}, (err, html) ->
|
||||
callback html
|
||||
monitor.getProcessList (plist) ->
|
||||
plist = _.filter plist, (i) ->
|
||||
return i.user == account.username
|
||||
|
||||
for item in plist
|
||||
item.command = (/[^A-Za-z0.9//]+(.*)/.exec(item.command))[1]
|
||||
|
||||
jade.renderFile path.join(__dirname, 'view/widget.jade'),
|
||||
plist: plist
|
||||
, (err, html) ->
|
||||
callback html
|
||||
|
||||
preview: (callback) ->
|
||||
jade.renderFile path.join(__dirname, 'view/preview.jade'), {}, (err, html) ->
|
||||
|
||||
@@ -17,15 +17,10 @@ header SSH
|
||||
td CPU
|
||||
td 操作
|
||||
tbody
|
||||
tr
|
||||
td sshd
|
||||
td 5M
|
||||
td 1%
|
||||
td
|
||||
button.btn.btn-danger.btn-xs Kill
|
||||
tr
|
||||
td node
|
||||
td 10M
|
||||
td 2%
|
||||
td
|
||||
button.btn.btn-danger.btn-xs Kill
|
||||
for process in plist
|
||||
tr(data-id= '#{process.pid}')
|
||||
td= process.command
|
||||
td #{(process.rss / 1024).toFixed(1)}M
|
||||
td #{process.cpu_per}%
|
||||
td
|
||||
button.btn.btn-danger.btn-xs Kill
|
||||
|
||||
Reference in New Issue
Block a user