0
0
mirror of https://github.com/openwrt/luci.git synced 2025-04-09 01:04:43 +00:00
Files
Paul Donald c40253ada3 luci-app-lldpd: Fix mysterious Command failed: Unknown error
Executing the following command:

ubus call luci.lldpd getStatus

always returned 'Command failed: Unknown error', but the underlying

lldpcli -f json0 show *

worked fine. Fixed with a chained ?.read?

Tested on 23.05.3

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2024-10-10 22:03:46 +02:00

22 lines
451 B
Plaintext

'use strict';
import { popen } from 'fs';
function lldpcli_json(section) {
return json(popen(`lldpcli -f json0 show ${section}`, 'r')?.read?.('all'));
}
const methods = {
getStatus: {
call: function() {
return {
statistics: lldpcli_json("statistics"),
neighbors: lldpcli_json("neighbors details"),
interfaces: lldpcli_json("interfaces"),
chassis: lldpcli_json("chassis")
};
}
}
};
return { 'luci.lldpd': methods };