From f8552afb1c32aece90bba337708f650440850605 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Sat, 12 Dec 2020 18:29:54 +0200 Subject: [PATCH] luci-app-statistics: add dhcpleases Add the dhcpleases plugin: https://github.com/openwrt/packages/pull/14204 Added-Frontend-by: Hannu Nyman Signed-off-by: Nick Hainke [Minor changes to graph: alt_autoscale, precision, label] Signed-off-by: Hannu Nyman --- .../rrdtool/definitions/dhcpleases.js | 25 +++++++++++++++++++ .../view/statistics/plugins/dhcpleases.js | 21 ++++++++++++++++ .../root/etc/config/luci_statistics | 4 +++ .../luci/statistics/plugins/dhcpleases.json | 9 +++++++ 4 files changed, 59 insertions(+) create mode 100644 applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dhcpleases.js create mode 100644 applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dhcpleases.js create mode 100644 applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/dhcpleases.json diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dhcpleases.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dhcpleases.js new file mode 100644 index 0000000000..b54a0af27e --- /dev/null +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dhcpleases.js @@ -0,0 +1,25 @@ +/* Licensed to the public under the Apache License 2.0. */ + +'use strict'; +'require baseclass'; + +return baseclass.extend({ + title: _('DHCP Leases'), + + rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + return { + title: "%H: DHCP leases", + alt_autoscale_max: true, + vlabel: "Leases given", + number_format: "%3.0lf", + data: { + types: [ "count" ], + options: { + count: { + title: "Leases" + } + } + } + }; + } +}); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dhcpleases.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dhcpleases.js new file mode 100644 index 0000000000..df185f7d8c --- /dev/null +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dhcpleases.js @@ -0,0 +1,21 @@ +'use strict'; +'require baseclass'; +'require form'; + +return baseclass.extend({ + title: _('DHCP Leases Plugin Configuration'), + description: _('The dhcpleases plugin collects information about assigned DHCP leases.'), + + addFormOptions: function(s) { + var o; + + o = s.option(form.Flag, 'enable', _('Enable this plugin')); + + o = s.option(form.Value, 'Path', _('DHCP leases file')); + o.default = '/tmp/dhcp.leases'; + }, + + configSummary: function(section) { + return _('Monitoring DHCP leases enabled'); + } +}); diff --git a/applications/luci-app-statistics/root/etc/config/luci_statistics b/applications/luci-app-statistics/root/etc/config/luci_statistics index 5a2b94b675..4c50867c0f 100644 --- a/applications/luci-app-statistics/root/etc/config/luci_statistics +++ b/applications/luci-app-statistics/root/etc/config/luci_statistics @@ -86,6 +86,10 @@ config statistics 'collectd_df' option IgnoreSelected '0' option ValuesPercentage '0' +config statistics 'collectd_dhcpleases' + option enable '0' + option Path '/tmp/dhcp.leases' + config statistics 'collectd_disk' option enable '0' option Disks 'hda1 hdb' diff --git a/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/dhcpleases.json b/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/dhcpleases.json new file mode 100644 index 0000000000..e6d5450ebf --- /dev/null +++ b/applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/dhcpleases.json @@ -0,0 +1,9 @@ +{ + "title": "Dhcpleases", + "category": "network", + "legend": [ + [], + [], + ["Path"] + ] +} -- 2.30.2