mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-30 03:45:14 +08:00
update 2026-05-27 19:55:46
This commit is contained in:
1 parent
762a95b5ae
commit
84f707b52b
758 files changed
-362299
No files matched your search
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"admin/status/log-viewer": {
|
||||
"title": "Log Viewer",
|
||||
"order": 5,
|
||||
"action": {
|
||||
"type": "alias",
|
||||
"path": "admin/status/log-viewer/syslog"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-log-viewer" ]
|
||||
}
|
||||
},
|
||||
|
||||
"admin/status/log-viewer/syslog": {
|
||||
"title": "System Log",
|
||||
"order": 1,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "log-viewer/syslog"
|
||||
}
|
||||
},
|
||||
|
||||
"admin/status/log-viewer/dmesg": {
|
||||
"title": "Kernel Log",
|
||||
"order": 2,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "log-viewer/dmesg"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"luci-app-log-viewer": {
|
||||
"description": "Grant access to log-viewer procedures",
|
||||
"read": {
|
||||
"cgi-io": [ "exec" ],
|
||||
"file": {
|
||||
"/sbin/logread*": [ "exec" ],
|
||||
"/usr/sbin/logread*": [ "exec" ],
|
||||
"/bin/dmesg -r": [ "exec" ]
|
||||
},
|
||||
"ubus": {
|
||||
"system": [ "info" ],
|
||||
"luci.log-viewer": [ "getSyslogSize", "getSyslogHash", "getDmesgSize", "getDmesgHash", "getLogfileSize" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { popen, stat } from 'fs';
|
||||
|
||||
const dmesgCmd = '/bin/dmesg';
|
||||
const logreadCmd = (
|
||||
(stat('/sbin/logread')?.perm?.user_exec) ? '/sbin/logread' :
|
||||
((stat('/usr/sbin/logread')?.perm?.user_exec) ? '/usr/sbin/logread' : null));
|
||||
|
||||
if(!logreadCmd) {
|
||||
die('Error! Logread not found!');
|
||||
}
|
||||
|
||||
function getCmdOutput(cmd, number) {
|
||||
let ret = '';
|
||||
const fd = popen(cmd, 'r');
|
||||
if(fd) {
|
||||
let c = fd.read('all');
|
||||
fd.close();
|
||||
if(c) {
|
||||
c = trim(c);
|
||||
ret = number ? int(c) : c;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const methods = {
|
||||
getSyslogSize: {
|
||||
call: function() {
|
||||
return { 'bytes': getCmdOutput(logreadCmd + ' | wc -c', true) };
|
||||
},
|
||||
},
|
||||
|
||||
getSyslogHash: {
|
||||
call: function() {
|
||||
return { 'hash': getCmdOutput(logreadCmd + ' -t -l 1') };
|
||||
},
|
||||
},
|
||||
|
||||
getDmesgSize: {
|
||||
call: function() {
|
||||
return { 'bytes': getCmdOutput(dmesgCmd + ' | wc -c', true) };
|
||||
},
|
||||
},
|
||||
|
||||
getDmesgHash: {
|
||||
call: function() {
|
||||
return { 'hash': getCmdOutput(dmesgCmd + ' | tail -n 1') };
|
||||
},
|
||||
},
|
||||
|
||||
getLogfileSize: {
|
||||
args: { fpath: 'fpath' },
|
||||
call: function(request) {
|
||||
let ret = '';
|
||||
const path = request.args?.fpath;
|
||||
if(path) {
|
||||
ret = stat(path)?.size;
|
||||
}
|
||||
return { 'bytes': ret ?? '' };
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return { 'luci.log-viewer': methods };
|
||||
Reference in new issue
Block a user