fix: ps 中长用户名被省略

This commit is contained in:
jysperm
2014-07-24 05:08:10 +08:00
parent 96be0a1aa5
commit 5cb3b048d4

View File

@@ -19,8 +19,9 @@ exports.run = ->
setInterval exports.monitoring, config.plugins.linux.monitor_cycle
exports.loadPasswd = (callback) ->
app.redis.get 'rp:passwd_cache', (err, passwd_cache) ->
if passwd_cache
app.redis.get 'rp:passwd_cache', (err, result) ->
if result
passwd_cache = JSON.parse result
callback()
else
fs.readFile '/etc/passwd', (err, content) ->
@@ -43,11 +44,11 @@ exports.getProcessList = (callback) ->
callback JSON.parse plist
else
exports.loadPasswd ->
child_process.exec "ps awufx", (err, stdout, stderr) ->
child_process.exec "ps awufxn", (err, stdout, stderr) ->
plist = stdout.split('\n')[1...-1]
plist = _.map plist, (item) ->
rx = /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$/
rx = /^\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$/
result = rx.exec item
return {
user: do ->