From: Hannu Nyman Date: Tue, 30 May 2023 16:27:47 +0000 (+0300) Subject: luci-app-statistics: enhance tcpconns plugin X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=38f5b55446ac3f15c3907c06f6a4ea00b4f6a7f3;p=project%2Fluci.git luci-app-statistics: enhance tcpconns plugin Modernize tcpconns plugin to match the features in collectd: * Support summary of all ports * 'All listening ports' can be concurrent to specified ports, not just alternative Signed-off-by: Hannu Nyman (cherry picked from commit c9c395920e424cd188a663a6c3f4acfdf8d65012) --- diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/tcpconns.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/tcpconns.js index 84471ebb87..526b10f3c3 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/tcpconns.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/tcpconns.js @@ -19,25 +19,30 @@ return baseclass.extend({ o = s.option(form.DynamicList, 'LocalPorts', _('Monitor local ports')); o.optional = true; o.datatype = 'port'; - o.default = '22 80'; - o.depends({ enable: '1', ListeningPorts: '0' }); + o.default = '22'; + o.depends('enable', '1'); o = s.option(form.DynamicList, 'RemotePorts', _('Monitor remote ports')); o.optional = true; o.datatype = 'port'; - o.depends({ enable: '1', ListeningPorts: '0' }); + o.depends('enable', '1'); + + o = s.option(form.Flag, 'AllPortsSummary', _('Summary of all ports')); + o.rmempty = false; + o.depends('enable', '1'); }, configSummary: function(section) { var lports = L.toArray(section.LocalPorts), - rports = L.toArray(section.RemotePorts); - - if (section.ListeningPorts == '1') - return _('Monitoring local listen ports'); - else - return _('Monitoring %s and %s').format( - N_(lports.length, 'one local port', '%d local ports').format(lports.length), - N_(rports.length, 'one remote port', '%d remote ports').format(rports.length) - ); + rports = L.toArray(section.RemotePorts), + listen = section.ListeningPorts == '1', + summary = section.AllPortsSummary == '1'; + + return _('Monitoring %s and %s, %s %s').format( + N_(lports.length, 'one local', '%d local').format(lports.length), + N_(rports.length, 'one remote port', '%d remote ports').format(rports.length), + listen ? _('all local listening ports,') : '', + summary ? _('summary of all ports') : _('no summary') + ); } }); diff --git a/applications/luci-app-statistics/root/etc/config/luci_statistics b/applications/luci-app-statistics/root/etc/config/luci_statistics index bb9ca15e8e..2008a7966a 100644 --- a/applications/luci-app-statistics/root/etc/config/luci_statistics +++ b/applications/luci-app-statistics/root/etc/config/luci_statistics @@ -203,7 +203,8 @@ config statistics 'collectd_splash_leases' config statistics 'collectd_tcpconns' option enable '0' option ListeningPorts '0' - option LocalPorts '22 80' + list LocalPorts '22' + option AllPortsSummary '0' config statistics 'collectd_thermal' option enable '0' diff --git a/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/tcpconns.json b/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/tcpconns.json index f932994b43..e26e8acffb 100644 --- a/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/tcpconns.json +++ b/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/tcpconns.json @@ -3,7 +3,7 @@ "category": "network", "legend": [ [], - ["ListeningPorts"], + ["ListeningPorts", "AllPortsSummary"], ["LocalPorts", "RemotePorts"] ] }