From eaa763cbdb33f292ed13f9b2c2b4b985323f7b5c Mon Sep 17 00:00:00 2001
From: Jo-Philipp Wich
Date: Fri, 23 May 2008 19:23:06 +0000
Subject: [PATCH] * ffluci/statistics: port statistics to new controller api,
add mysel to NOTICE
---
NOTICE | 5 +-
.../src/controller/admin/statistics.lua | 1 -
.../luci_statistics/luci_statistics.lua | 88 +++++++++++++++++++
.../src/controller/public/statistics.lua | 1 -
.../collectd.lua} | 0
.../csv.lua | 0
.../df.lua | 0
.../disk.lua | 0
.../dns.lua | 0
.../email.lua | 0
.../exec.lua | 0
.../interface.lua | 0
.../iptables.lua | 0
.../irq.lua | 0
.../netlink.lua | 0
.../network.lua | 0
.../ping.lua | 0
.../processes.lua | 0
.../rrdtool.lua | 0
.../tcpconns.lua | 0
.../unixsock.lua | 0
.../src/model/menu/70luci-statistics.lua | 31 -------
.../src/view/admin_statistics/index.htm | 8 ++
.../view/admin_statistics/networkplugins.htm | 18 ++++
.../view/admin_statistics/outputplugins.htm | 19 ++++
.../view/admin_statistics/systemplugins.htm | 18 ++++
26 files changed, 155 insertions(+), 34 deletions(-)
delete mode 100644 applications/luci-statistics/src/controller/admin/statistics.lua
create mode 100644 applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua
delete mode 100644 applications/luci-statistics/src/controller/public/statistics.lua
rename applications/luci-statistics/src/model/cbi/{admin_statistics/index.lua => luci_statistics/collectd.lua} (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/csv.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/df.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/disk.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/dns.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/email.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/exec.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/interface.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/iptables.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/irq.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/netlink.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/network.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/ping.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/processes.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/rrdtool.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/tcpconns.lua (100%)
rename applications/luci-statistics/src/model/cbi/{admin_statistics => luci_statistics}/unixsock.lua (100%)
delete mode 100644 applications/luci-statistics/src/model/menu/70luci-statistics.lua
create mode 100644 applications/luci-statistics/src/view/admin_statistics/index.htm
create mode 100644 applications/luci-statistics/src/view/admin_statistics/networkplugins.htm
create mode 100644 applications/luci-statistics/src/view/admin_statistics/outputplugins.htm
create mode 100644 applications/luci-statistics/src/view/admin_statistics/systemplugins.htm
diff --git a/NOTICE b/NOTICE
index df8a5aebf..dea5e6742 100644
--- a/NOTICE
+++ b/NOTICE
@@ -2,4 +2,7 @@ FFLuCI - Freifunk Lua Configuration Interface
Copyright 2008 Steven Barth
Licensed under the Apache License, Version 2.0.
--- Contributors: please add your own notice here
\ No newline at end of file
+-- Contributors: please add your own notice here
+Luci-Statistics - Statistics for FFLuCI
+Copyright 2008 Jo-Philipp Wich
+Licensed under the Apache License, Version 2.0.
diff --git a/applications/luci-statistics/src/controller/admin/statistics.lua b/applications/luci-statistics/src/controller/admin/statistics.lua
deleted file mode 100644
index 3318f70cd..000000000
--- a/applications/luci-statistics/src/controller/admin/statistics.lua
+++ /dev/null
@@ -1 +0,0 @@
-module("ffluci.controller.admin.statistics", package.seeall)
diff --git a/applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua b/applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua
new file mode 100644
index 000000000..ad914d80e
--- /dev/null
+++ b/applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua
@@ -0,0 +1,88 @@
+--[[
+
+ Luci controller for statistics
+ Copyright 2008 Jo-Philipp Wich
+
+ $Id$
+
+]]--
+
+module("ffluci.controller.luci_statistics.luci_statistics", package.seeall)
+
+fs = require("ffluci.fs")
+tpl = require("ffluci.template")
+
+function _entry( path, ... )
+ if fs.isfile( "/usr/lib/collectd/" .. path[4] .. ".so" ) then
+ entry( path, ... )
+ end
+end
+
+
+function index()
+ entry({"admin", "statistics"}, statistics_index, "Statistiken", 80)
+ entry({"admin", "statistics", "collectd"}, cbi("luci_statistics/collectd"), "Collectd", 10)
+
+ entry({"admin", "statistics", "output"}, statistics_outputplugins, "Ausgabeplugins", 20)
+ _entry({"admin", "statistics", "output", "rrdtool"}, cbi("luci_statistics/rrdtool"), "RRDTool", 10)
+ _entry({"admin", "statistics", "output", "network"}, cbi("luci_statistics/network"), "Netzwerk", 20)
+ _entry({"admin", "statistics", "output", "unixsock"}, cbi("luci_statistics/unixsock"), "Unix Socket", 30)
+ _entry({"admin", "statistics", "output", "csv"}, cbi("luci_statistics/csv"), "CSV", 40)
+
+ entry({"admin", "statistics", "system"}, statistics_systemplugins, "Systemplugins", 30)
+ _entry({"admin", "statistics", "system", "exec"}, cbi("luci_statistics/exec"), "Exec", 10)
+ _entry({"admin", "statistics", "system", "email"}, cbi("luci_statistics/email"), "E-Mail", 20)
+ _entry({"admin", "statistics", "system", "df"}, cbi("luci_statistics/df"), "Speicherplatz", 30)
+ _entry({"admin", "statistics", "system", "disk"}, cbi("luci_statistics/disk"), "Datenträger", 40)
+ _entry({"admin", "statistics", "system", "irq"}, cbi("luci_statistics/irq"), "Interrupts", 50)
+ _entry({"admin", "statistics", "system", "processes"}, cbi("luci_statistics/processes"), "Prozesse", 60)
+
+ entry({"admin", "statistics", "network"}, statistics_networkplugins, "Netzwerkplugins", 40)
+ _entry({"admin", "statistics", "network", "interface"}, cbi("luci_statistics/interface"), "Schnittstellen", 10)
+ _entry({"admin", "statistics", "network", "netlink"}, cbi("luci_statistics/netlink"), "Netlink", 20)
+ _entry({"admin", "statistics", "network", "iptables"}, cbi("luci_statistics/iptables"), "Firewall", 30)
+ _entry({"admin", "statistics", "network", "tcpconns"}, cbi("luci_statistics/tcpconns"), "Verbindungen", 40)
+ _entry({"admin", "statistics", "network", "ping"}, cbi("luci_statistics/ping"), "Ping", 50)
+ _entry({"admin", "statistics", "network", "dns"}, cbi("luci_statistics/dns"), "DNS", 60)
+end
+
+
+function statistics_index()
+ tpl.render("admin_statistics/index")
+end
+
+function statistics_outputplugins()
+ plugins = {
+ rrdtool="RRDTool",
+ network="Netzwerk",
+ unixsock="Unix Socket",
+ csv="CSV"
+ }
+
+ tpl.render("admin_statistics/outputplugins", {plugins=plugins})
+end
+
+function statistics_systemplugins()
+ plugins = {
+ exec="Exec",
+ email="E-Mail",
+ disk="Datenträger",
+ irq="Interrupts",
+ processes="Prozesse"
+ }
+
+ tpl.render("admin_statistics/systemplugins", {plugins=plugins})
+end
+
+function statistics_networkplugins()
+ plugins = {
+ interface="Schnittstellen",
+ netlink="Netlink",
+ iptables="Firewall",
+ tcpconns="Verbindungen",
+ ping="Ping",
+ dns="DNS"
+ }
+
+ tpl.render("admin_statistics/networkplugins", {plugins=plugins})
+end
diff --git a/applications/luci-statistics/src/controller/public/statistics.lua b/applications/luci-statistics/src/controller/public/statistics.lua
deleted file mode 100644
index d7ed1e327..000000000
--- a/applications/luci-statistics/src/controller/public/statistics.lua
+++ /dev/null
@@ -1 +0,0 @@
-module("ffluci.controller.public.statistics", package.seeall)
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/index.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/collectd.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/index.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/collectd.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/csv.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/csv.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/csv.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/csv.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/df.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/df.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/df.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/df.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/disk.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/disk.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/disk.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/disk.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/dns.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/dns.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/dns.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/dns.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/email.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/email.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/email.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/email.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/exec.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/exec.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/exec.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/exec.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/interface.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/interface.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/interface.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/interface.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/iptables.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/iptables.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/iptables.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/iptables.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/irq.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/irq.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/irq.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/irq.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/netlink.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/netlink.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/netlink.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/netlink.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/network.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/network.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/network.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/network.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/ping.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/ping.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/ping.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/ping.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/processes.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/processes.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/processes.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/processes.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/rrdtool.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/rrdtool.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/rrdtool.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/rrdtool.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/tcpconns.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/tcpconns.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/tcpconns.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/tcpconns.lua
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/unixsock.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/unixsock.lua
similarity index 100%
rename from applications/luci-statistics/src/model/cbi/admin_statistics/unixsock.lua
rename to applications/luci-statistics/src/model/cbi/luci_statistics/unixsock.lua
diff --git a/applications/luci-statistics/src/model/menu/70luci-statistics.lua b/applications/luci-statistics/src/model/menu/70luci-statistics.lua
deleted file mode 100644
index e53a0a0d4..000000000
--- a/applications/luci-statistics/src/model/menu/70luci-statistics.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-add( "admin", "statistics", "Statistiken", 70 )
---act( "apache", "Apache" )
---act( "apcups", "Apcups" )
---act( "ascent", "Ascent" )
---act( "cpufreq", "Cpufreq" )
-act( "csv", "CSV" )
-act( "df", "Speicher" )
-act( "disk", "Festplatte" )
-act( "dns", "DNS" )
-act( "email", "E-Mail" )
-act( "exec", "Exec" )
-act( "interface", "Schnittstellen" )
-act( "iptables", "Firewall" )
-act( "irq", "Interrupts" )
-act( "logfile", "Protokolldateien" )
-act( "netlink", "Netlink" )
-act( "network", "Netzwerk" )
---act( "nginx", "nginx Server" )
---act( "ntpd", "NTP Server" )
-act( "ping", "Ping" )
---act( "powerdns", "Powerdns Server" )
-act( "processes", "Prozesse" )
-act( "rrdtool", "RRDTool" )
---act( "sensors", "Sensoren" )
---act( "snmp", "SNMP Datenquellen" )
---act( "syslog", "Systemlog" )
---act( "tail", "Dateiverfolgung" )
---act( "teamspeak2", "TeamSpeak 2" )
-act( "tcpconns", "TCP Verbindungen" )
-act( "unixsock", "UNIX Socket" )
---act( "vmem", "Vmem" )
diff --git a/applications/luci-statistics/src/view/admin_statistics/index.htm b/applications/luci-statistics/src/view/admin_statistics/index.htm
new file mode 100644
index 000000000..2c1befa50
--- /dev/null
+++ b/applications/luci-statistics/src/view/admin_statistics/index.htm
@@ -0,0 +1,8 @@
+<%+header%>
+
+<%:stat Statistiken%>
+
+<%:stat_desc Die Statistiken bauen auf Collectd auf und nutzen
+RRD Tool um Graphen aus den erfassten Daten zu rendern.%>
+
+<%+footer%>
diff --git a/applications/luci-statistics/src/view/admin_statistics/networkplugins.htm b/applications/luci-statistics/src/view/admin_statistics/networkplugins.htm
new file mode 100644
index 000000000..0c6d7f7ad
--- /dev/null
+++ b/applications/luci-statistics/src/view/admin_statistics/networkplugins.htm
@@ -0,0 +1,18 @@
+<%+header%>
+
+<%:stat_networkplugins Netzwerkplugins%>
+
+<%:stat_networkplugins_desc Netzwerkplugins sammeln Werte über offene TCP-Verbindung, allgemeines Verkehrsaufkommen
+auf verschiedenen Schnittstellen, DNS-Verkehr u.v.m.%>
+
+<%:stat_networkplugins_installed Installierte Netzwerkplugins:%>
+
+ <% for plugin, desc in pairs(plugins) do %>
+ <% if ffluci.fs.isfile("/usr/lib/collectd/" .. plugin .. ".so") then %>
+ - <%=desc%>
+ <% end %>
+ <% end %>
+
+
+
+<%+footer%>
diff --git a/applications/luci-statistics/src/view/admin_statistics/outputplugins.htm b/applications/luci-statistics/src/view/admin_statistics/outputplugins.htm
new file mode 100644
index 000000000..ed8651407
--- /dev/null
+++ b/applications/luci-statistics/src/view/admin_statistics/outputplugins.htm
@@ -0,0 +1,19 @@
+<%+header%>
+
+<%:stat_outputplugins Ausgabeplugins%>
+
+<%:stat_outputplugins_desc Ausgabeplugins stellen verschiedene Möglichkeiten zur Speicherung
+der Daten bereit. Es können auch mehrere Plugins gleichzeitig aktiviert werden um beispielsweise
+die gesammelten Werte in RRD-Datenbanken zu sichern und zusätzlich über das Netzwerk zu versenden.%>
+
+<%:stat_outputplugins_installed Installierte Ausgabeplugins:%>
+
+ <% for plugin, desc in pairs(plugins) do %>
+ <% if ffluci.fs.isfile("/usr/lib/collectd/" .. plugin .. ".so") then %>
+ - <%=desc%>
+ <% end %>
+ <% end %>
+
+
+
+<%+footer%>
diff --git a/applications/luci-statistics/src/view/admin_statistics/systemplugins.htm b/applications/luci-statistics/src/view/admin_statistics/systemplugins.htm
new file mode 100644
index 000000000..cbb469a1f
--- /dev/null
+++ b/applications/luci-statistics/src/view/admin_statistics/systemplugins.htm
@@ -0,0 +1,18 @@
+<%+header%>
+
+<%:stat_systemplugins Systemplugins%>
+
+<%:stat_systemplugins_desc Systemplugins sammeln Werte über den aktuellen Systemzustand und den Ressourcenverbrauch
+auf dem Gerät.%>
+
+<%:stat_systemplugins_installed Installierte Systemplugins:%>
+
+ <% for plugin, desc in pairs(plugins) do %>
+ <% if ffluci.fs.isfile("/usr/lib/collectd/" .. plugin .. ".so") then %>
+ - <%=desc%>
+ <% end %>
+ <% end %>
+
+
+
+<%+footer%>
--
2.25.1