Skip to content

Commit

Permalink
luci-app-vnstat2: use more efficient way to get database interfaces
Browse files Browse the repository at this point in the history
The currently used command "vnstat --json f 1" can be very slow when the
database contains many entries. This can result in an XHR timeout error
on the configuration page.

Use the "--dbiflist" option instead, which was added in vnStat 2.7.

Fixes: #6702
Signed-off-by: Jan Hoffmann <jan@3e8.eu>
  • Loading branch information
janh committed Nov 18, 2023
1 parent 63d5e23 commit 3ac4f56
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ return view.extend({
o = s.option(form.DummyValue, '_database');

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 = [];
if (result.code == 0) {
var vnstatData = JSON.parse(result.stdout);
for (var i = 0; i < vnstatData.interfaces.length; i++) {
databaseInterfaces.push(vnstatData.interfaces[i].name);
}
databaseInterfaces = result.stdout.trim().split('\n');
}

var configInterfaces = uci.get_first('vnstat', 'vnstat', 'interface') || [];
Expand Down

0 comments on commit 3ac4f56

Please sign in to comment.