luci-app-statistics: add ipstatistics plugin
authorNick Hainke <vincent@systemli.org>
Fri, 29 Jan 2021 10:03:19 +0000 (11:03 +0100)
committerHannu Nyman <hannu.nyman@iki.fi>
Thu, 4 Feb 2021 14:35:13 +0000 (16:35 +0200)
Signed-off-by: Nick Hainke <vincent@systemli.org>
applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ipstatistics.js [new file with mode: 0644]
applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ipstatistics.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/ipstatistics.json [new file with mode: 0644]

diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ipstatistics.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ipstatistics.js
new file mode 100644 (file)
index 0000000..73bd16a
--- /dev/null
@@ -0,0 +1,54 @@
+/* Licensed to the public under the Apache License 2.0. */
+
+'use strict';
+'require baseclass';
+
+return baseclass.extend({
+       title: _('IP-Statistics'),
+
+       rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
+
+               var traffic = {
+                       title: "%H: IPv4 and IPv6 Comparison",
+                       vlabel: "Bytes/s",
+                       number_format: "%5.1lf%sB/s",
+                       totals_format: "%5.1lf%sB",
+
+                       data: {
+                               sources: {
+                                       ip_stats_octets: [ "ip4rx", "ip4tx", "ip6rx", "ip6tx" ]
+                               },
+
+                               options: {
+                                       ip_stats_octets__ip4rx: {
+                                               title: "IPv4 Bytes (RX)",
+                                               total: true,
+                                               color: "00ff00"
+                                       },
+
+                                       ip_stats_octets__ip4tx: {
+                                               title: "IPv4 Bytes (TX)",
+                                               flip : true,
+                                               total: true,
+                                               color: "0000ff"
+                                       },
+
+                                       ip_stats_octets__ip6rx: {
+                                               title: "IPv6 Bytes (RX)",
+                                               total: true,
+                                               color: "ffff00"
+                                       },
+
+                                       ip_stats_octets__ip6tx: {
+                                               title: "IPv6 Bytes (TX)",
+                                               flip : true,
+                                               total: true,
+                                               color: "ff00ff"
+                                       }
+                               }
+                       }
+               };
+               
+               return [ traffic ]
+       }
+});
diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ipstatistics.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ipstatistics.js
new file mode 100644 (file)
index 0000000..37f9810
--- /dev/null
@@ -0,0 +1,16 @@
+'use strict';
+'require baseclass';
+'require form';
+'require tools.widgets as widgets';
+
+return baseclass.extend({
+       title: _('IP-Statistics Plugin Configuration'),
+       description: _('The ipstatistics plugin collects IPv4 and IPv6 statistics to compare them.'),
+
+       addFormOptions: function(s) {
+               var o;
+
+               o = s.option(form.Flag, 'enable', _('Enable this plugin'));
+               o.default = '0';
+       }
+});
index 6edcb30d4ebfcd6d803366ca893ff6b43541cfe6..d1fef13b6ed772abd62a7c708ece8365f69b52d7 100644 (file)
@@ -123,6 +123,9 @@ config statistics 'collectd_interface'
        option Interfaces 'br-lan'
        option IgnoreSelected '0'
 
+config statistics 'collectd_ipstatistics'
+       option enable '0'
+
 config statistics 'collectd_iptables'
        option enable '0'
 
diff --git a/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/ipstatistics.json b/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/ipstatistics.json
new file mode 100644 (file)
index 0000000..a13f14a
--- /dev/null
@@ -0,0 +1,4 @@
+{
+       "title": "IP-Statistics",
+       "category": "network"
+}