From 8b1de85db8a965acc5d68635c88b462b3631ed92 Mon Sep 17 00:00:00 2001 From: Hannu Nyman Date: Tue, 15 Sep 2015 10:09:57 +0300 Subject: [PATCH 1/4] for-15.05 statistics: Add support for entropy stats Backport the addition of statistics on the available entropy from 7df0df48c006bbe3a8f4f73cd7b0bdc9bec0f80e Signed-off-by: Hannu Nyman --- .../luci_statistics/luci_statistics.lua | 3 ++- .../model/cbi/luci_statistics/entropy.lua | 14 ++++++++++++++ .../rrdtool/definitions/entropy.lua | 19 +++++++++++++++++++ .../root/etc/config/luci_statistics | 3 +++ .../root/usr/bin/stat-genconfig | 6 ++++++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/entropy.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/entropy.lua diff --git a/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua b/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua index c532b4a6d3..49eab5acd4 100644 --- a/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua +++ b/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua @@ -30,6 +30,7 @@ function index() disk = _("Disk Usage"), dns = _("DNS"), email = _("Email"), + entropy = _("Entropy"), exec = _("Exec"), interface = _("Interfaces"), iptables = _("Firewall"), @@ -53,7 +54,7 @@ function index() -- our collectd menu local collectd_menu = { output = { "csv", "network", "rrdtool", "unixsock" }, - system = { "cpu", "df", "disk", "email", "exec", "irq", "load", "memory", "nut", "processes", "uptime" }, + system = { "cpu", "df", "disk", "email", "entropy", "exec", "irq", "load", "memory", "nut", "processes", "uptime" }, network = { "conntrack", "dns", "interface", "iptables", "netlink", "olsrd", "ping", "splash_leases", "tcpconns", "iwinfo" } } diff --git a/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/entropy.lua b/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/entropy.lua new file mode 100644 index 0000000000..d18bf910f9 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/entropy.lua @@ -0,0 +1,14 @@ +-- Copyright 2015 Hannu Nyman +-- Licensed to the public under the Apache License 2.0. + +m = Map("luci_statistics", + translate("Entropy Plugin Configuration"), + translate("The entropy plugin collects statistics about the available entropy.")) + +s = m:section( NamedSection, "collectd_entropy", "luci_statistics" ) + +enable = s:option( Flag, "enable", translate("Enable this plugin") ) +enable.default = 0 + +return m + diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/entropy.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/entropy.lua new file mode 100644 index 0000000000..3d30a70afb --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/entropy.lua @@ -0,0 +1,19 @@ +-- Copyright 2015 Hannu Nyman +-- Licensed to the public under the Apache License 2.0. + +module("luci.statistics.rrdtool.definitions.entropy", package.seeall) + +function rrdargs( graph, plugin, plugin_instance, dtype ) + + return { + title = "%H: Available entropy", + vlabel = "bits", + number_format = "%4.0lf", + data = { + types = { "entropy" }, + options = { entropy = { title = "Entropy %di" } } + } + } + +end + diff --git a/applications/luci-app-statistics/root/etc/config/luci_statistics b/applications/luci-app-statistics/root/etc/config/luci_statistics index e39db3513a..b91b20f95b 100644 --- a/applications/luci-app-statistics/root/etc/config/luci_statistics +++ b/applications/luci-app-statistics/root/etc/config/luci_statistics @@ -45,6 +45,9 @@ config 'statistics' 'collectd_email' option 'SocketFile' '/var/run/collectd/email.sock' option 'SocketGroup' 'nogroup' +config 'statistics' 'collectd_entropy' + option 'enable' '0' + config 'statistics' 'collectd_exec' option 'enable' '0' diff --git a/applications/luci-app-statistics/root/usr/bin/stat-genconfig b/applications/luci-app-statistics/root/usr/bin/stat-genconfig index cb94e28118..8acae46c61 100755 --- a/applications/luci-app-statistics/root/usr/bin/stat-genconfig +++ b/applications/luci-app-statistics/root/usr/bin/stat-genconfig @@ -303,6 +303,12 @@ plugins = { { } }, + entropy = { + { }, + { }, + { } + }, + exec = config_exec, interface = { From a2a61aae0f2237f32a32d680b0055f330ab4499c Mon Sep 17 00:00:00 2001 From: Hannu Nyman Date: Sat, 29 Aug 2015 10:59:01 +0300 Subject: [PATCH 2/4] statistics: cleanup config file No functional changes, but the file is reorganised: * group settings: general settings / output plugins / input plugins * sort settings inside a group * remove quotes from option names to match the current uci behaviour * whitespace corrections Signed-off-by: Hannu Nyman (cherry picked from commit 6a4226b3d1cd71e5d3abd7219552aa7fb9dd6f65) --- .../root/etc/config/luci_statistics | 239 +++++++++--------- 1 file changed, 123 insertions(+), 116 deletions(-) diff --git a/applications/luci-app-statistics/root/etc/config/luci_statistics b/applications/luci-app-statistics/root/etc/config/luci_statistics index b91b20f95b..f4e2faf455 100644 --- a/applications/luci-app-statistics/root/etc/config/luci_statistics +++ b/applications/luci-app-statistics/root/etc/config/luci_statistics @@ -1,146 +1,153 @@ -config 'statistics' 'rrdtool' - option 'default_timespan' '1hour' - option 'image_width' '600' - option 'image_path' '/tmp/rrdimg' +# general settings -config 'statistics' 'collectd' - option 'BaseDir' '/var/run/collectd' - option 'Include' '/etc/collectd/conf.d' - option 'PIDFile' '/var/run/collectd.pid' - option 'PluginDir' '/usr/lib/collectd' - option 'TypesDB' '/usr/share/collectd/types.db' - option 'Interval' '30' - option 'ReadThreads' '2' +config statistics 'collectd' + option BaseDir '/var/run/collectd' + option Include '/etc/collectd/conf.d' + option PIDFile '/var/run/collectd.pid' + option PluginDir '/usr/lib/collectd' + option TypesDB '/usr/share/collectd/types.db' + option Interval '30' + option ReadThreads '2' -config 'statistics' 'collectd_ping' - option 'enable' '0' - option 'TTL' '127' - option 'Interval' '30' - option 'Hosts' '127.0.0.1' +config statistics 'rrdtool' + option default_timespan '1hour' + option image_width '600' + option image_path '/tmp/rrdimg' -config 'statistics' 'collectd_csv' - option 'enable' '0' - option 'StoreRates' '0' - option 'DataDir' '/tmp' +# output plugins -config 'statistics' 'collectd_df' - option 'enable' '0' - option 'Devices' '/dev/mtdblock/4' - option 'MountPoints' '/jffs' - option 'FSTypes' 'tmpfs' - option 'IgnoreSelected' '0' +config statistics 'collectd_rrdtool' + option enable '1' + option DataDir '/tmp/rrd' + option RRARows '100' + option RRASingle '1' + option RRATimespans '1hour 1day 1week 1month 1year' -config 'statistics' 'collectd_disk' - option 'enable' '0' - option 'Disks' 'hda1 hdb' - option 'IgnoreSelected' '0' +config statistics 'collectd_csv' + option enable '0' + option StoreRates '0' + option DataDir '/tmp' -config 'statistics' 'collectd_dns' - option 'enable' '0' - option 'Interfaces' 'ffdhcp ff br-lan' - option 'IgnoreSources' '127.0.0.1' +config statistics 'collectd_email' + option enable '0' + option SocketFile '/var/run/collectd/email.sock' + option SocketGroup 'nogroup' -config 'statistics' 'collectd_email' - option 'enable' '0' - option 'SocketFile' '/var/run/collectd/email.sock' - option 'SocketGroup' 'nogroup' +config statistics 'collectd_logfile' + option enable '0' + option LogLevel 'notice' + option File '/var/log/collectd.log' + option Timestamp '1' -config 'statistics' 'collectd_entropy' - option 'enable' '0' +config statistics 'collectd_network' + option enable '0' -config 'statistics' 'collectd_exec' - option 'enable' '0' +config statistics 'collectd_unixsock' + option enable '0' + option SocketFile '/var/run/collectd/query.sock' + option SocketGroup 'nogroup' -config 'statistics' 'collectd_interface' - option 'enable' '1' - option 'Interfaces' 'br-lan br-ff' - option 'IgnoreSelected' '0' +# input plugins -config 'statistics' 'collectd_iptables' - option 'enable' '1' +config statistics 'collectd_conntrack' + option enable '1' -config 'collectd_iptables_match' - option 'table' 'nat' - option 'chain' 'luci_fw_postrouting' - option 'target' 'MASQUERADE' - option 'source' '192.168.1.0/24' - option 'outputif' 'br-ff' - option 'name' 'Verkehr LAN-Clients' +config statistics 'collectd_cpu' + option enable '1' -config 'collectd_iptables_match' - option 'chain' 'luci_fw_postrouting' - option 'table' 'nat' - option 'target' 'MASQUERADE' - option 'source' '10.61.230.0/24' - option 'outputif' 'br-ff' - option 'name' 'Verkehr WLAN-Clients' +config statistics 'collectd_df' + option enable '0' + option Devices '/dev/mtdblock/4' + option MountPoints '/jffs' + option FSTypes 'tmpfs' + option IgnoreSelected '0' -config 'statistics' 'collectd_irq' - option 'enable' '0' - option 'Irqs' '2 3 4 7' +config statistics 'collectd_disk' + option enable '0' + option Disks 'hda1 hdb' + option IgnoreSelected '0' -config 'statistics' 'collectd_load' - option 'enable' '1' +config statistics 'collectd_dns' + option enable '0' + option Interfaces 'ffdhcp ff br-lan' + option IgnoreSources '127.0.0.1' -config 'statistics' 'collectd_logfile' - option 'enable' '0' - option 'LogLevel' 'notice' - option 'File' '/var/log/collectd.log' - option 'Timestamp' '1' +config statistics 'collectd_entropy' + option enable '0' -config 'statistics' 'collectd_netlink' - option 'enable' '0' - option 'IgnoreSelected' '0' - option 'VerboseInterfaces' 'br-lan br-ff' - option 'QDiscs' 'br-lan br-ff' +config statistics 'collectd_exec' + option enable '0' -config 'statistics' 'collectd_network' - option 'enable' '0' +config statistics 'collectd_interface' + option enable '1' + option Interfaces 'br-lan br-ff' + option IgnoreSelected '0' -config 'statistics' 'collectd_processes' - option 'enable' '1' - option 'Processes' 'uhttpd dnsmasq dropbear' +config statistics 'collectd_iptables' + option enable '1' -config statistics 'collectd_splash_leases' - option enable '1' +config collectd_iptables_match + option table 'nat' + option chain 'luci_fw_postrouting' + option target 'MASQUERADE' + option source '192.168.1.0/24' + option outputif 'br-ff' + option name 'Verkehr LAN-Clients' -config 'statistics' 'collectd_tcpconns' - option 'enable' '1' - option 'ListeningPorts' '0' - option 'LocalPorts' '22 80' +config collectd_iptables_match + option chain 'luci_fw_postrouting' + option table 'nat' + option target 'MASQUERADE' + option source '10.61.230.0/24' + option outputif 'br-ff' + option name 'Verkehr WLAN-Clients' -config 'statistics' 'collectd_unixsock' - option 'enable' '0' - option 'SocketFile' '/var/run/collectd/query.sock' - option 'SocketGroup' 'nogroup' +config statistics 'collectd_irq' + option enable '0' + option Irqs '2 3 4 7' -config 'statistics' 'collectd_cpu' - option 'enable' '1' +config statistics 'collectd_iwinfo' + option enable '1' -config 'statistics' 'collectd_rrdtool' - option 'enable' '1' - option 'DataDir' '/tmp/rrd' - option 'RRARows' '100' - option 'RRASingle' '1' - option 'RRATimespans' '1hour 1day 1week 1month 1year' +config statistics 'collectd_load' + option enable '1' -config 'statistics' 'collectd_memory' - option 'enable' '1' +config statistics 'collectd_memory' + option enable '1' -config 'statistics' 'collectd_conntrack' - option 'enable' '1' +config statistics 'collectd_netlink' + option enable '0' + option IgnoreSelected '0' + option VerboseInterfaces 'br-lan br-ff' + option QDiscs 'br-lan br-ff' -config 'statistics' 'collectd_olsrd' - option 'enable' '1' - option 'Port' '2006' - option 'Host' '127.0.0.1' +config statistics 'collectd_nut' + option enable '0' + option UPS 'myupsname' -config 'statistics' 'collectd_iwinfo' - option 'enable' '1' +config statistics 'collectd_olsrd' + option enable '1' + option Port '2006' + option Host '127.0.0.1' -config 'statistics' 'collectd_nut' - option 'enable' '0' - option 'UPS' 'myupsname' +config statistics 'collectd_ping' + option enable '0' + option TTL '127' + option Interval '30' + option Hosts '127.0.0.1' + +config statistics 'collectd_processes' + option enable '1' + option Processes 'uhttpd dnsmasq dropbear' + +config statistics 'collectd_splash_leases' + option enable '1' + +config statistics 'collectd_tcpconns' + option enable '1' + option ListeningPorts '0' + option LocalPorts '22 80' + +config statistics 'collectd_uptime' + option enable '1' -config 'statistics' 'collectd_uptime' - option 'enable' '1' From 8e156d6e5c387fc0cd3775b793d2c9cb7de2c623 Mon Sep 17 00:00:00 2001 From: Hannu Nyman Date: Sat, 29 Aug 2015 11:15:39 +0300 Subject: [PATCH 3/4] statistics: adjust default settings to match default plugins Adjust default settings to match the plugins installed by default (default plugins: iwinfo, interface, load) * disable plugins not installed by default to avoid error messages at start * remove references to Freifunk interfaces, as most users do not have those Signed-off-by: Hannu Nyman (cherry picked from commit 4f429c5c8d95bdd74a7e005364cb511410caea5e) --- .../root/etc/config/luci_statistics | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/applications/luci-app-statistics/root/etc/config/luci_statistics b/applications/luci-app-statistics/root/etc/config/luci_statistics index f4e2faf455..abcee3e938 100644 --- a/applications/luci-app-statistics/root/etc/config/luci_statistics +++ b/applications/luci-app-statistics/root/etc/config/luci_statistics @@ -50,10 +50,10 @@ config statistics 'collectd_unixsock' # input plugins config statistics 'collectd_conntrack' - option enable '1' + option enable '0' config statistics 'collectd_cpu' - option enable '1' + option enable '0' config statistics 'collectd_df' option enable '0' @@ -69,7 +69,7 @@ config statistics 'collectd_disk' config statistics 'collectd_dns' option enable '0' - option Interfaces 'ffdhcp ff br-lan' + option Interfaces 'br-lan' option IgnoreSources '127.0.0.1' config statistics 'collectd_entropy' @@ -80,11 +80,11 @@ config statistics 'collectd_exec' config statistics 'collectd_interface' option enable '1' - option Interfaces 'br-lan br-ff' + option Interfaces 'br-lan' option IgnoreSelected '0' config statistics 'collectd_iptables' - option enable '1' + option enable '0' config collectd_iptables_match option table 'nat' @@ -92,7 +92,7 @@ config collectd_iptables_match option target 'MASQUERADE' option source '192.168.1.0/24' option outputif 'br-ff' - option name 'Verkehr LAN-Clients' + option name 'LAN-Clients traffic' config collectd_iptables_match option chain 'luci_fw_postrouting' @@ -100,7 +100,7 @@ config collectd_iptables_match option target 'MASQUERADE' option source '10.61.230.0/24' option outputif 'br-ff' - option name 'Verkehr WLAN-Clients' + option name 'WLAN-Clients traffic' config statistics 'collectd_irq' option enable '0' @@ -113,20 +113,20 @@ config statistics 'collectd_load' option enable '1' config statistics 'collectd_memory' - option enable '1' + option enable '0' config statistics 'collectd_netlink' option enable '0' option IgnoreSelected '0' - option VerboseInterfaces 'br-lan br-ff' - option QDiscs 'br-lan br-ff' + option VerboseInterfaces 'br-lan' + option QDiscs 'br-lan' config statistics 'collectd_nut' option enable '0' option UPS 'myupsname' config statistics 'collectd_olsrd' - option enable '1' + option enable '0' option Port '2006' option Host '127.0.0.1' @@ -137,17 +137,17 @@ config statistics 'collectd_ping' option Hosts '127.0.0.1' config statistics 'collectd_processes' - option enable '1' + option enable '0' option Processes 'uhttpd dnsmasq dropbear' config statistics 'collectd_splash_leases' - option enable '1' + option enable '0' config statistics 'collectd_tcpconns' - option enable '1' + option enable '0' option ListeningPorts '0' option LocalPorts '22 80' config statistics 'collectd_uptime' - option enable '1' + option enable '0' From d91f0ef027115c600f556091516563f5c9b04543 Mon Sep 17 00:00:00 2001 From: Hannu Nyman Date: Sun, 30 Aug 2015 14:00:29 +0300 Subject: [PATCH 4/4] statistics: remove references to Lucid from scripts Both init.d and uci-defaults scripts included in luci-app-statistics still contained stuff related to lucid, which package was removed by https://github.com/openwrt/luci/commit/91b97bc9f625d09431dc1c753209a037d7c42fbc Changes to scripts: * init.d: lucid reference removed, /var/etc creation moved earlier (before first possible use) * uci-defaults: lucid parameters & restart removed (but busybox httpd stuff was left intact, although it might be unnecessary) Signed-off-by: Hannu Nyman (cherry picked from commit 0d5070c51089deb448476f1abadcea8e185eaf9b) --- .../root/etc/init.d/luci_statistics | 10 +--------- .../root/etc/uci-defaults/luci-statistics | 20 ------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/applications/luci-app-statistics/root/etc/init.d/luci_statistics b/applications/luci-app-statistics/root/etc/init.d/luci_statistics index 936f3a63c3..ab75b69df0 100755 --- a/applications/luci-app-statistics/root/etc/init.d/luci_statistics +++ b/applications/luci-app-statistics/root/etc/init.d/luci_statistics @@ -3,23 +3,15 @@ START=79 start() { ### replace shipped config with symlink + mkdir -p /var/etc if [ ! -L /etc/collectd.conf ]; then test -f /etc/collectd.conf && mv /etc/collectd.conf /etc/collectd.conf.bak ln -s /var/etc/collectd.conf /etc/collectd.conf fi ### create config - mkdir -p /var/etc /usr/bin/stat-genconfig > /var/etc/collectd.conf - ### prepare rrdimg directory - if [ -f /etc/config/lucid ] && [ -x /etc/init.d/lucid ] && /etc/init.d/lucid enabled && \ - [ "$(uci get luci_statistics.rrdtool.image_path 2>/dev/null)" != "$(uci get lucid.statistics.physical 2>/dev/null)" ]; then - uci set lucid.statistics.physical=$(uci get luci_statistics.rrdtool.image_path) - uci commit lucid - /etc/init.d/lucid restart - fi - ### workaround broken permissions on /tmp chmod 1777 /tmp } diff --git a/applications/luci-app-statistics/root/etc/uci-defaults/luci-statistics b/applications/luci-app-statistics/root/etc/uci-defaults/luci-statistics index e94a8637c8..28e35298a2 100755 --- a/applications/luci-app-statistics/root/etc/uci-defaults/luci-statistics +++ b/applications/luci-app-statistics/root/etc/uci-defaults/luci-statistics @@ -8,29 +8,9 @@ uci -q batch <<-EOF >/dev/null commit ucitrack EOF -# register LuCId virtual path handler -[ -f /etc/config/lucid ] && \ -uci -q batch <<-EOF >/dev/null - delete lucid.statistics - - set lucid.statistics=DirectoryPublisher - set lucid.statistics.name='RRDTool Image Cache' - set lucid.statistics.physical=/tmp/rrdimg - set lucid.statistics.virtual=/rrdimg - set lucid.statistics.domain='' - - add_list lucid.http.publisher=statistics - add_list lucid.https.publisher=statistics - - commit lucid -EOF - # symlink for busybox httpd [ -x /usr/sbin/httpd ] && [ ! -h /www/rrdimg ] && \ ln -s /tmp/rrdimg /www/rrdimg -# restart LuCId service -[ -x /etc/init.d/lucid ] && /etc/init.d/lucid enabled && /etc/init.d/lucid restart - rm -f /tmp/luci-indexcache exit 0