luci-app-statistics: add snmp6 collector
authorNick Hainke <vincent@systemli.org>
Fri, 11 Dec 2020 21:29:44 +0000 (22:29 +0100)
committerHannu Nyman <hannu.nyman@iki.fi>
Sat, 9 Jan 2021 16:53:01 +0000 (18:53 +0200)
Add IPv6 statistics.

Signed-off-by: Nick Hainke <vincent@systemli.org>
applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/snmp6.js [new file with mode: 0644]
applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/snmp6.js [new file with mode: 0644]
applications/luci-app-statistics/root/etc/config/luci_statistics
applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/snmp6.json [new file with mode: 0644]

diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/snmp6.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/snmp6.js
new file mode 100644 (file)
index 0000000..27e47d2
--- /dev/null
@@ -0,0 +1,92 @@
+/* Licensed to the public under the Apache License 2.0. */
+
+'use strict';
+'require baseclass';
+
+return baseclass.extend({
+       title: _('SNMP6'),
+
+       rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
+
+               var traffic = {
+                       title: "%H: IPv6 on %pi",
+                       vlabel: "Bytes/s",
+
+                       data: {
+                               sources: {
+                                       if_octets: [ "tx", "rx" ]
+                               },
+
+                               options: {
+                                       if_octets__tx: {
+                                               title: "Bytes (TX)",
+                                               total: true,
+                                               color: "00ff00"
+                                       },
+
+                                       if_octets__rx: {
+                                               title: "Bytes (RX)",
+                                               flip : true,
+                                               total: true,
+                                               color: "0000ff"
+                                       }
+                               }
+                       }
+               };
+
+               var mcast_traffic = {
+                       title: "%H: IPv6 Multicast-Traffic on %pi",
+                       vlabel: "Bytes/s",
+
+                       data: {
+                               sources: {
+                                       if_octets_mcast: [ "tx", "rx" ]
+                               },
+
+                               options: {
+                                       if_octets_mcast__tx: {
+                                               title: "Bytes (TX)",
+                                               total: true,
+                                               color: "00ff00"
+                                       },
+
+                                       if_octets_mcast__rx: {
+                                               title: "Bytes (RX)",
+                                               flip : true,
+                                               total: true,
+                                               color: "0000ff"
+                                       }
+                               }
+                       }
+               };
+
+
+               var bcast_traffic = {
+                       title: "%H: IPv6 Broadcast-Traffic on %pi",
+                       vlabel: "Bytes/s",
+
+                       data: {
+                               sources: {
+                                       if_octets_bcast: [ "tx", "rx" ]
+                               },
+
+                               options: {
+                                       if_octets_bcast__tx: {
+                                               title: "Bytes (TX)",
+                                               total: true,
+                                               color: "00ff00"
+                                       },
+
+                                       if_octets_bcast__rx: {
+                                               title: "Bytes (RX)",
+                                               flip : true,
+                                               total: true,
+                                               color: "0000ff"
+                                       }
+                               }
+                       }
+               };
+               
+               return [ traffic, mcast_traffic, bcast_traffic ]
+       }
+});
diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/snmp6.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/snmp6.js
new file mode 100644 (file)
index 0000000..91f9537
--- /dev/null
@@ -0,0 +1,37 @@
+'use strict';
+'require baseclass';
+'require form';
+'require tools.widgets as widgets';
+
+return baseclass.extend({
+       title: _('SNMP6 Plugin Configuration'),
+       description: _('The snmp6 plugin collects IPv6 statistics for selected interfaces.'),
+
+       addFormOptions: function(s) {
+               var o;
+
+               o = s.option(form.Flag, 'enable', _('Enable this plugin'));
+               o.default = '0';
+
+               o = s.option(widgets.DeviceSelect, 'Interfaces', _('Basic monitoring'));
+               o.multiple = true;
+               o.noaliases = true;
+               o.depends('enable', '1');
+
+               o = s.option(form.Flag, 'IgnoreSelected', _('Monitor all except specified'));
+               o.depends('enable', '1');
+       },
+
+       configSummary: function(section) {
+               var basic = L.toArray(section.Interfaces),
+                   count = basic.length,
+                   invert = section.IgnoreSelected == '1';
+
+               if (invert && count == 0)
+                       return _('Monitoring all interfaces');
+               else if (invert)
+                       return N_(count, 'Monitoring all but one interface', 'Monitoring all but %d interfaces').format(count);
+               else if (count)
+                       return N_(count, 'Monitoring one interface', 'Monitoring %d interfaces').format(count);
+       }
+});
index 3d4e80780d72121f0c5a9733decdccc00105947c..6edcb30d4ebfcd6d803366ca893ff6b43541cfe6 100644 (file)
@@ -188,6 +188,11 @@ config statistics 'collectd_processes'
 config statistics 'collectd_sensors'
        option enable '0'
 
+config statistics 'collectd_snmp6'
+       option enable '0'
+       option Interfaces 'br-lan'
+       option IgnoreSelected '0'
+
 config statistics 'collectd_splash_leases'
        option enable '0'
 
diff --git a/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/snmp6.json b/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/snmp6.json
new file mode 100644 (file)
index 0000000..175b21e
--- /dev/null
@@ -0,0 +1,9 @@
+{
+       "title": "Snmp6",
+       "category": "network",
+       "legend": [
+               [],
+               ["IgnoreSelected"],
+               ["Interfaces"]
+       ]
+}