summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-statistics/src/controller
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-05-25 02:37:39 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-05-25 02:37:39 +0000
commit1e70a05156492ccb7918b566ae027f448746fa43 (patch)
treeb592cf1b67799e57b286a16ad5c03011798bf1a0 /applications/luci-statistics/src/controller
parent32aa488d9b585bbeb8d880d763923f9f1c6cd0e2 (diff)
* ffluci/statistcs: implement rrdtool stuff, extend controller to public pages - wip
Diffstat (limited to 'applications/luci-statistics/src/controller')
-rw-r--r--applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua51
1 files changed, 35 insertions, 16 deletions
diff --git a/applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua b/applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua
index ad914d80e2..a30db7c09c 100644
--- a/applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua
+++ b/applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua
@@ -1,19 +1,14 @@
---[[
-
- Luci controller for statistics
- Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
- $Id$
-
-]]--
-
module("ffluci.controller.luci_statistics.luci_statistics", package.seeall)
-fs = require("ffluci.fs")
-tpl = require("ffluci.template")
+local fs = require("ffluci.fs")
+local tpl = require("ffluci.template")
+local rrd = require("ffluci.statistics.rrdtool")
+local data = require("ffluci.statistics.datatree").Instance()
+
function _entry( path, ... )
- if fs.isfile( "/usr/lib/collectd/" .. path[4] .. ".so" ) then
+ local file = path[4] or path[3]
+ if fs.isfile( "/usr/lib/collectd/" .. file .. ".so" ) then
entry( path, ... )
end
end
@@ -32,10 +27,11 @@ function index()
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", "system", "cpu"}, cbi("luci_statistics/cpu"), "Prozessor", 30)
+ _entry({"admin", "statistics", "system", "df"}, cbi("luci_statistics/df"), "Speicherplatz", 40)
+ _entry({"admin", "statistics", "system", "disk"}, cbi("luci_statistics/disk"), "Datenträger", 50)
+ _entry({"admin", "statistics", "system", "irq"}, cbi("luci_statistics/irq"), "Interrupts", 60)
+ _entry({"admin", "statistics", "system", "processes"}, cbi("luci_statistics/processes"), "Prozesse", 70)
entry({"admin", "statistics", "network"}, statistics_networkplugins, "Netzwerkplugins", 40)
_entry({"admin", "statistics", "network", "interface"}, cbi("luci_statistics/interface"), "Schnittstellen", 10)
@@ -44,6 +40,14 @@ function index()
_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)
+
+
+ -- public views
+ entry({"freifunk", "statistics"}, statistics_index, "Statistiken", 80)
+
+ for i, plugin in ipairs( data:plugins() ) do
+ _entry({"freifunk", "statistics", plugin}, statistics_render, plugin, i)
+ end
end
@@ -86,3 +90,18 @@ function statistics_networkplugins()
tpl.render("admin_statistics/networkplugins", {plugins=plugins})
end
+
+
+function statistics_render()
+ local plugin = ffluci.dispatcher.request[3]
+ local images = { }
+
+ for i, inst in ipairs( data:plugin_instances( plugin ) ) do
+ local graph = rrd.Graph()
+ for i, img in ipairs( graph:render( "OpenWrt", plugin, inst ) ) do
+ table.insert( images, img )
+ end
+ end
+
+ tpl.render("public_statistics/graph", { images=images, plugin=plugin } )
+end