mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-24 03:35:59 +08:00
fixbugs
This commit is contained in:
@@ -141,18 +141,17 @@ exports.getStorageQuota = (callback) ->
|
||||
cache.try 'linux.getStorageQuota', (SETEX) ->
|
||||
child_process.exec "sudo repquota -a", (err, stdout) ->
|
||||
logger.error err if err
|
||||
lines = _.filter stdout.split('\n')[5...-1], (i) -> i
|
||||
lines = _.filter stdout.split('\n')[5 ... -1], (i) -> i
|
||||
|
||||
lines = _.map lines, (line) ->
|
||||
fields = _.filter line.split(' '), (i) -> i and i != ' '
|
||||
[username, __, size_used, size_soft, size_hard, inode_used, inode_soft, inode_hard, inode_grace] = fields
|
||||
[username, __, size_used, size_soft, size_hard, inode_used, inode_soft, inode_hard, inode_grace] = line.split /\s+/
|
||||
|
||||
if /days/.test inode_used
|
||||
[size_grace, inode_used, inode_soft, inode_hard, inode_grace] = [inode_used, inode_soft, inode_hard, inode_grace]
|
||||
|
||||
return {
|
||||
username: username
|
||||
size_used: parseFloat (parseInt(size_used) / 1024 / 1024).toFixed(1)
|
||||
size_used: parseFloat (parseInt(size_used) / 1024).toFixed(1)
|
||||
inode_used: parseInt inode_used
|
||||
}
|
||||
|
||||
@@ -237,12 +236,15 @@ exports.getResourceUsageByAccounts = (callback) ->
|
||||
logger.error err if err
|
||||
resources_usage_by_accounts = []
|
||||
|
||||
for username, usage of monitor.resources_usage
|
||||
for username in _.union _.keys(monitor.resources_usage), _.keys(result.storage_quota)
|
||||
usage = monitor.resources_usage[username]
|
||||
storage = result.storage_quota[username]
|
||||
|
||||
resources_usage_by_accounts.push
|
||||
username: username
|
||||
cpu: usage.cpu ? 0
|
||||
memory: usage.memory ? 0
|
||||
storage: result.storage_quota[username]?.size_used ? 0
|
||||
cpu: usage?.cpu ? 0
|
||||
memory: usage?.memory ? 0
|
||||
storage: storage?.size_used ? 0
|
||||
process: _.filter(result.process_list, (i) -> i.user == username).length
|
||||
|
||||
SETEX resources_usage_by_accounts, 20
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"": "Linux",
|
||||
"server_monitor": "Server Status",
|
||||
"widget": {
|
||||
"hour_cpu": "CPU usage in last hour",
|
||||
"hour_memory": "Memory usage in last hour",
|
||||
"hour_cpu": "CPU in last hour",
|
||||
"hour_memory": "Memory in last hour",
|
||||
"storage": "Storage used",
|
||||
"month_transfer": "traffic of this month"
|
||||
},
|
||||
|
||||
@@ -22,7 +22,7 @@ exports.monitoring = (callback) ->
|
||||
REDIS_KEY = "#{config.redis.prefix}:linux.recent_resources_usage"
|
||||
ITEM_IN_RESOURCES_LIST = 3600 * 1000 / config.plugins.linux.monitor_cycle
|
||||
|
||||
linux.getMemoryInfo (err, memory_info) ->
|
||||
linux.getMemoryInfo (memory_info) ->
|
||||
linux.getProcessList (plist) ->
|
||||
plist = _.reject plist, (item) ->
|
||||
return item.rss == 0
|
||||
@@ -62,7 +62,7 @@ exports.monitoring = (callback) ->
|
||||
usage.memory = parseFloat (usage.memory / recent_resources_usage.length / base).toFixed(1)
|
||||
|
||||
async.each _.keys(resources_usage), (username, callback) ->
|
||||
Account.search username, (err, account) ->
|
||||
Account.search username, (account) ->
|
||||
unless account
|
||||
return callback()
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ block content
|
||||
td= item.process
|
||||
td #{item.cpu}s
|
||||
td #{item.memory.toFixed(1)}M
|
||||
td #{(item.storage / 1024).toFixed(1)}M
|
||||
td #{(item.storage).toFixed(1)}M
|
||||
|
||||
.row
|
||||
.panel.panel-default.process-list
|
||||
|
||||
Reference in New Issue
Block a user