Revert "cpu"

This reverts commit 13e0935ce083afe8c151ef971f641d30ed34a1cd.
This commit is contained in:
sbwml 2022-07-30 06:26:35 +08:00
parent 95c3126773
commit 998d3ea8f8
3 changed files with 1 additions and 47 deletions

View File

@ -51,7 +51,6 @@ define Package/autocore/install/Default
$(CP) ./files/generic/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/ $(CP) ./files/generic/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/
$(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include $(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include
$(INSTALL_DATA) ./files/generic/19_cpu.js $(1)/www/luci-static/resources/view/status/include/
$(INSTALL_DATA) ./files/generic/29_ethinfo.js $(1)/www/luci-static/resources/view/status/include/ $(INSTALL_DATA) ./files/generic/29_ethinfo.js $(1)/www/luci-static/resources/view/status/include/
endef endef

View File

@ -1,45 +0,0 @@
'use strict';
'require rpc';
var callCPUFreeInfo = rpc.declare({
object: 'luci',
method: 'getCPUUsage'
});
function progressbar(value, max) {
var vn = parseInt(value) || 0,
mn = parseInt(max) || 100,
pc = Math.floor((100 / mn) * vn);
return E('div', {
'class': 'cbi-progressbar',
'title': '%s%% / %s%%'.format(vn, mn, pc)
}, E('div', { 'style': 'width:%.2f%%'.format(pc) }));
}
return L.Class.extend({
title: _('CPU'),
load: function() {
return L.resolveDefault(callCPUFreeInfo(), {});
},
render: function(info) {
var fields = [
_('Used'), (info.cpuusage) ? info.cpuusage : 0, 100
];
var table = E('div', { 'class': 'table cpu' });
for (var i = 0; i < fields.length; i += 3) {
table.appendChild(E('div', { 'class': 'tr' }, [
E('div', { 'class': 'td left', 'width': '33%' }, [ fields[i] ]),
E('div', { 'class': 'td left' }, [
(fields[i + 1] != null) ? progressbar(fields[i + 1], fields[i + 2], true) : '?'
])
]));
}
return table;
}
});

View File

@ -650,7 +650,7 @@ local methods = {
local sys = require "luci.sys" local sys = require "luci.sys"
local cpuusage = {} local cpuusage = {}
cpuusage.cpuusage = sys.exec("busybox top -n1 | awk '/^CPU/ {printf(\"%d%\", 100 - $8)}'") or "6%" cpuusage.cpuusage = sys.exec("busybox top -n1 | awk '/^CPU/ {printf(\"%d%%\", 100 - $8)}'") or "6%"
return cpuusage return cpuusage
end end
}, },