luci: add getETHInfo method

Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
sbwml 2024-12-10 23:29:21 +08:00
parent 9d4f357904
commit 3dc3696915
2 changed files with 21 additions and 1 deletions

View File

@ -664,6 +664,26 @@ const methods = {
return { onlineusers: error() }; return { onlineusers: error() };
} }
} }
},
getETHInfo: {
call: function() {
if (!access('/sbin/ethinfo'))
return {};
const fd = popen('/sbin/ethinfo');
if (fd) {
let ethinfo = fd.read('all');
if (!ethinfo)
ethinfo = '{}';
ethinfo = json(ethinfo);
fd.close();
return { result: ethinfo };
} else {
return { result: error() };
}
}
} }
}; };

View File

@ -3,7 +3,7 @@
"description": "Grant access to autocore", "description": "Grant access to autocore",
"read": { "read": {
"ubus": { "ubus": {
"luci": [ "getCPUInfo", "getTempInfo", "getCPUBench", "getCPUUsage", "getOnlineUsers" ] "luci": [ "getCPUInfo", "getTempInfo", "getCPUBench", "getCPUUsage", "getOnlineUsers", "getETHInfo" ]
} }
} }
} }