summaryrefslogtreecommitdiffstats
path: root/applications/luci-app-lldpd/root/usr/share/rpcd/ucode/luci.lldpd
blob: 3774e222cec2f43f73edb6fb07978dab14ed6d36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'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 };