mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-07 01:53:34 +08:00
luci-app-turboacc-mtk: add ppe stats
This commit is contained in:
parent
363788550f
commit
721630c5c4
@ -32,6 +32,12 @@ var getTCPCCAStat = rpc.declare({
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
var getMTKPPEStat = rpc.declare({
|
||||
object: 'luci.turboacc',
|
||||
method: 'getMTKPPEStat',
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
function getServiceStatus() {
|
||||
return Promise.all([
|
||||
L.resolveDefault(getFastPathStat(), {}),
|
||||
@ -40,6 +46,25 @@ function getServiceStatus() {
|
||||
]);
|
||||
}
|
||||
|
||||
function getMTKPPEStatus() {
|
||||
return Promise.all([
|
||||
L.resolveDefault(getMTKPPEStat(), {})
|
||||
]);
|
||||
}
|
||||
|
||||
function progressbar(value, max, byte) {
|
||||
var vn = parseInt(value) || 0,
|
||||
mn = parseInt(max) || 100,
|
||||
fv = byte ? String.format('%1024.2mB', value) : value,
|
||||
fm = byte ? String.format('%1024.2mB', max) : max,
|
||||
pc = Math.floor((100 / mn) * vn);
|
||||
|
||||
return E('div', {
|
||||
'class': 'cbi-progressbar',
|
||||
'title': '%s / %s (%d%%)'.format(fv, fm, pc)
|
||||
}, E('div', { 'style': 'width:%.2f%%'.format(pc) }));
|
||||
}
|
||||
|
||||
function renderStatus(stats) {
|
||||
var spanTemp = '<em><span style="color:%s"><strong>%s</strong></span></em>';
|
||||
var renderHTML = [];
|
||||
@ -62,13 +87,15 @@ return view.extend({
|
||||
load: function() {
|
||||
return Promise.all([
|
||||
uci.load('turboacc'),
|
||||
L.resolveDefault(getSystemFeatures(), {})
|
||||
L.resolveDefault(getSystemFeatures(), {}),
|
||||
L.resolveDefault(getMTKPPEStat(), {})
|
||||
]);
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
var m, s, o;
|
||||
var features = data[1];
|
||||
var ppe_stats = data[2];
|
||||
|
||||
m = new form.Map('turboacc', _('TurboACC settings'),
|
||||
_('Open source flow offloading engine (fast path or hardware NAT).'));
|
||||
@ -87,22 +114,47 @@ return view.extend({
|
||||
});
|
||||
});
|
||||
|
||||
var acc_status = E('table', { 'class': 'table', 'width': '100%', 'cellspacing': '10' }, [
|
||||
E('tr', {}, [
|
||||
E('td', { 'width': '33%' }, _('FastPath Engine')),
|
||||
E('td', { 'id': 'fastpath_state' }, E('em', {}, _('Collecting data...')))
|
||||
]),
|
||||
E('tr', {}, [
|
||||
E('td', { 'width': '33%' }, _('Full Cone NAT')),
|
||||
E('td', { 'id': 'fullcone_state' }, E('em', {}, _('Collecting data...')))
|
||||
]),
|
||||
E('tr', {}, [
|
||||
E('td', { 'width': '33%' }, _('TCP CCA')),
|
||||
E('td', { 'id': 'tcpcca_state' }, E('em', {}, _('Collecting data...')))
|
||||
])
|
||||
]);
|
||||
|
||||
if (ppe_stats.hasOwnProperty('PPE_NUM')) {
|
||||
poll.add(function () {
|
||||
return L.resolveDefault(getMTKPPEStatus()).then(function (res) {
|
||||
var ppe_num = parseInt(res[0].PPE_NUM);
|
||||
for (var i=0; i<ppe_num; i++) {
|
||||
var ppe_bar = document.getElementById(`ppe${i}_entry`);
|
||||
ppe_bar.innerHTML = E('td', {},
|
||||
progressbar(res[0][`BIND_PPE${i}`], res[0][`ALL_PPE${i}`])).innerHTML;
|
||||
}
|
||||
});
|
||||
}, 3);
|
||||
|
||||
var ppe_num = parseInt(ppe_stats.PPE_NUM);
|
||||
|
||||
for (var i=0; i<ppe_num; i++) {
|
||||
acc_status.appendChild(E('tr', {}, [
|
||||
E('td', { 'width': '33%' }, `PPE${i} ` + _('Bind Entrys')),
|
||||
E('td', {'id': `ppe${i}_entry` },
|
||||
progressbar(ppe_stats[`BIND_PPE${i}`], ppe_stats[`ALL_PPE${i}`]))
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
return E('fieldset', { 'class': 'cbi-section' }, [
|
||||
E('legend', {}, _('Acceleration Status')),
|
||||
E('table', { 'class': 'table', 'width': '100%', 'cellspacing': '10' }, [
|
||||
E('tr', {}, [
|
||||
E('td', { 'width': '33%' }, _('FastPath Engine')),
|
||||
E('td', { 'id': 'fastpath_state' }, E('em', {}, _('Collecting data...')))
|
||||
]),
|
||||
E('tr', {}, [
|
||||
E('td', { 'width': '33%' }, _('Full Cone NAT')),
|
||||
E('td', { 'id': 'fullcone_state' }, E('em', {}, _('Collecting data...')))
|
||||
]),
|
||||
E('tr', {}, [
|
||||
E('td', { 'width': '33%' }, _('TCP CCA')),
|
||||
E('td', { 'id': 'tcpcca_state' }, E('em', {}, _('Collecting data...')))
|
||||
])
|
||||
])
|
||||
acc_status
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -194,3 +194,6 @@ msgstr "重启后应用此项设置。"
|
||||
|
||||
msgid "Number of HNAT PPE"
|
||||
msgstr "HNAT PPE数量"
|
||||
|
||||
msgid "Bind Entrys"
|
||||
msgstr "已绑定连接数"
|
||||
|
@ -70,6 +70,25 @@ local methods = {
|
||||
ccatype = ccatype and ccatype:upper() or nil
|
||||
print(json.stringify({ type = ccatype }))
|
||||
end
|
||||
},
|
||||
getMTKPPEStat = {
|
||||
call = function()
|
||||
local ppe_stat = {}
|
||||
local ppe_path = "/sys/kernel/debug/hnat/hnat_stats"
|
||||
local fd = io.open(ppe_path, 'r')
|
||||
|
||||
if fd then
|
||||
for line in fd:lines() do
|
||||
local i = string.find(line, "=")
|
||||
if i then
|
||||
ppe_stat[string.sub(line,1,i-1)] = string.sub(line,i+1)
|
||||
end
|
||||
end
|
||||
fd:close()
|
||||
end
|
||||
|
||||
print(json.stringify(ppe_stat))
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
"description": "Grant UCI access for luci-app-turboacc",
|
||||
"read": {
|
||||
"ubus": {
|
||||
"luci.turboacc": [ "getSystemFeatures", "getFastPathStat", "getFullConeStat", "getTCPCCAStat" ]
|
||||
"luci.turboacc": [ "getSystemFeatures", "getFastPathStat", "getFullConeStat", "getTCPCCAStat", "getMTKPPEStat" ]
|
||||
},
|
||||
"uci": [ "turboacc" ]
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user