From 3ac4f567dfdfd6ee989ceffb025241e605790b6d Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 18 Nov 2023 09:52:45 +0100 Subject: luci-app-vnstat2: use more efficient way to get database interfaces 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 --- .../htdocs/luci-static/resources/view/vnstat2/config.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'applications/luci-app-vnstat2') diff --git a/applications/luci-app-vnstat2/htdocs/luci-static/resources/view/vnstat2/config.js b/applications/luci-app-vnstat2/htdocs/luci-static/resources/view/vnstat2/config.js index 10cd85641c..4d4bfd0dbe 100644 --- a/applications/luci-app-vnstat2/htdocs/luci-static/resources/view/vnstat2/config.js +++ b/applications/luci-app-vnstat2/htdocs/luci-static/resources/view/vnstat2/config.js @@ -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') || []; -- cgit v1.2.3