Merge pull request #6704 from janh/vnstat2-use-dbiflist

luci-app-vnstat2: use more efficient way to get database interfaces
This commit is contained in:
Jo-Philipp Wich 2023-11-19 01:01:05 +01:00 committed by GitHub
commit 6d9cc9a518
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,13 +58,10 @@ return view.extend({
o = s.option(form.DummyValue, '_database'); o = s.option(form.DummyValue, '_database');
o.load = function(section_id) { o.load = function(section_id) {
return fs.exec('/usr/bin/vnstat', ['--json', 'f', '1']).then(L.bind(function(result) { return fs.exec('/usr/bin/vnstat', ['--dbiflist', '1']).then(L.bind(function(result) {
var databaseInterfaces = []; var databaseInterfaces = [];
if (result.code == 0) { if (result.code == 0) {
var vnstatData = JSON.parse(result.stdout); databaseInterfaces = result.stdout.trim().split('\n');
for (var i = 0; i < vnstatData.interfaces.length; i++) {
databaseInterfaces.push(vnstatData.interfaces[i].name);
}
} }
var configInterfaces = uci.get_first('vnstat', 'vnstat', 'interface') || []; var configInterfaces = uci.get_first('vnstat', 'vnstat', 'interface') || [];