summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-05-21 03:08:47 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-05-21 03:08:47 +0000
commit5306660d04e81b15d7338ccb3e5229ba1e6dc129 (patch)
treeab0816b5e2d7993653eb3cf682544a5571c94ad8
parentf77474efc7181610420681e2871186b03e0ade73 (diff)
* ffluci/statistics: add cbi models for irq, netlink and network plugins, updated menu, default config and config generator
-rw-r--r--applications/luci-statistics/files/etc/config/luci_statistics91
-rwxr-xr-xapplications/luci-statistics/files/usr/bin/stat-genconfig79
-rw-r--r--applications/luci-statistics/src/model/cbi/admin_statistics/irq.lua39
-rw-r--r--applications/luci-statistics/src/model/cbi/admin_statistics/netlink.lua84
-rw-r--r--applications/luci-statistics/src/model/cbi/admin_statistics/network.lua84
-rw-r--r--applications/luci-statistics/src/model/menu/70luci-statistics.lua21
6 files changed, 372 insertions, 26 deletions
diff --git a/applications/luci-statistics/files/etc/config/luci_statistics b/applications/luci-statistics/files/etc/config/luci_statistics
index 512657cdd6..19e39c720e 100644
--- a/applications/luci-statistics/files/etc/config/luci_statistics
+++ b/applications/luci-statistics/files/etc/config/luci_statistics
@@ -1,5 +1,5 @@
-config 'core' 'general'
+config 'statistics' 'general'
option 'BaseDir' '/var/run/collectd'
option 'Include' '/etc/collectd/conf.d/*.conf'
option 'PIDFile' '/var/run/collectd.pid'
@@ -8,3 +8,92 @@ config 'core' 'general'
option 'Interval' '30'
option 'ReadThreads' '5'
+config 'statistics' 'collectd_ping'
+ option 'enable' '1'
+ option 'TTL' '127'
+ option 'Hosts' '127.0.0.1'
+
+config 'statistics' 'collectd_csv'
+ option 'enable' '1'
+ option 'StoreRates' '0'
+ option 'DataDir' '/tmp'
+
+config 'statistics' 'collectd_df'
+ option 'enable' '1'
+ option 'Devices' '/dev/mtdblock/4'
+ option 'MountPoints' '/jffs'
+ option 'FSTypes' 'tmpfs'
+ option 'IgnoreSelected' '0'
+
+config 'statistics' 'collectd_disk'
+ option 'enable' '1'
+ option 'Disks' 'hda1 hdb'
+ option 'IgnoreSelected' '0'
+
+config 'statistics' 'collectd_dns'
+ option 'enable' '1'
+ option 'Interfaces' 'ffdhcp ff lan wan'
+ option 'IgnoreSources' '127.0.0.1'
+
+config 'statistics' 'collectd_email'
+ option 'enable' '1'
+ option 'SocketFile' '/var/run/collectd-email.socket'
+
+config 'statistics' 'collectd_exec'
+ option 'enable' '1'
+
+config 'collectd_exec_input'
+ option 'cmdline' '/usr/bin/stat-input-olsr'
+
+config 'collectd_exec_notify'
+ option 'cmdline' '/usr/bin/stat-output-syslog'
+
+config 'statistics' 'collectd_interface'
+ option 'enable' '1'
+ option 'Interfaces' 'ffdhcp ff lan wan'
+ option 'IgnoreSelected' '0'
+
+config 'statistics' 'collectd_iptables'
+ option 'enable' '1'
+
+config 'collectd_iptables_match'
+ option 'table' 'nat'
+ option 'chain' 'luci_freifunk_postrouting'
+ option 'target' 'MASQUERADE'
+ option 'source' '192.168.1.0/24'
+ option 'outputif' 'br-ff'
+ option 'name' 'Verkehr LAN-Clients'
+
+config 'collectd_iptables_match'
+ option 'chain' 'luci_freifunk_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_irq'
+ option 'enable' '1'
+ option 'Irqs' '2 3 4 7'
+
+config 'statistics' 'collectd_logfile'
+ option 'enable' '1'
+ option 'LogLevel' 'notice'
+ option 'File' '/var/log/collectd.log'
+ option 'Timestamp' '1'
+
+config 'statistics' 'collectd_netlink'
+ option 'enable' '1'
+ option 'IgnoreSelected' '0'
+ option 'VerboseInterfaces' 'br-lan br-ff'
+ option 'QDiscs' 'br-lan br-ff'
+
+config 'statistics' 'collectd_network'
+ option 'enable' '1'
+
+config 'collectd_network_listen'
+ option 'host' '0.0.0.0'
+
+config 'collectd_network_server'
+ option 'host' '0.0.0.0'
+
diff --git a/applications/luci-statistics/files/usr/bin/stat-genconfig b/applications/luci-statistics/files/usr/bin/stat-genconfig
index 4f7aa6eb0f..f5a3529ae8 100755
--- a/applications/luci-statistics/files/usr/bin/stat-genconfig
+++ b/applications/luci-statistics/files/usr/bin/stat-genconfig
@@ -50,19 +50,13 @@ function config_generic( c, singles, bools, lists )
if type(singles) == "table" then
for i, key in ipairs( singles ) do
- if c[key] then
- print( "\t" .. key .. ' "' .. c[key] .. '"' )
- end
+ _string( c[key], key )
end
end
if type(bools) == "table" then
for i, key in ipairs( bools ) do
- if c[key] == 1 then
- print( "\t" .. key .. " true" )
- else
- print( "\t" .. key .. " false" )
- end
+ _bool( c[key], key )
end
end
@@ -119,9 +113,34 @@ function config_iptables( c )
end
end
end
+end
+
+function config_network( c )
+
+ for s in pairs(sections) do
+ for key, type in pairs({ Listen="collectd_network_listen", Server="collectd_network_server" }) do
+ if sections[s][".type"] == type then
+
+ host = sections[s].host
+ port = sections[s].port
+
+ if host then
+ if port then
+ print( "\t" .. key .. " " .. host .. " " .. port )
+ else
+ print( "\t" .. key .. " " .. host )
+ end
+ end
+ end
+ end
+ end
+ _string( c["TimeToLive"], "TimeToLive" )
+ _string( c["CacheFlush"], "CacheFlush" )
+ _bool( c["Forward"], "Forward" )
end
+
function _list_expand( c, l )
for i, n in ipairs(l) do
if c[n] then
@@ -131,14 +150,34 @@ function _list_expand( c, l )
end
function _expand( s, n )
-
if type(s) == "string" then
for i, v in ipairs( ffluci.util.split( s, "%s+", nil, true ) ) do
- print( "\t" .. n .. ' "' .. v .. '"' )
+ _string( v, n )
end
end
end
+function _bool( s, n )
+ if s and s == "1" then
+ print( "\t" .. n .. " true" )
+ else
+ print( "\t" .. n .. " false" )
+ end
+end
+
+function _string( s, n )
+ if s then
+ if not s:find("%d") then
+ if not s:find("%s") then
+ print( "\t" .. n .. " " .. s )
+ else
+ print( "\t" .. n .. ' "' .. s '"' )
+ end
+ else
+ print( "\t" .. n .. " " .. s )
+ end
+ end
+end
plugins = {
@@ -182,6 +221,26 @@ plugins = {
iptables = config_iptables,
+ irq = {
+ { },
+ { "IgnoreSelected" },
+ { "Irqs" }
+ },
+
+ logfile = {
+ { "LogLevel", "File" },
+ { "Timestamp" },
+ { }
+ },
+
+ netlink = {
+ { },
+ { "IgnoreSelected" },
+ { "Interfaces", "VerboseInterfaces", "QDiscs", "Classs", "Filters" }
+ },
+
+ network = config_network,
+
}
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/irq.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/irq.lua
new file mode 100644
index 0000000000..2d15e5232f
--- /dev/null
+++ b/applications/luci-statistics/src/model/cbi/admin_statistics/irq.lua
@@ -0,0 +1,39 @@
+--[[
+
+Luci configuration model for statistics - collectd irq plugin configuration
+(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+]]--
+
+m = Map("luci_statistics", "IRQ Plugin",
+[[Das IRQ-Plugin sammelt Informationen zur Auslastung einzelner Interrupts.
+Werden keine Interrupts angegeben, überwacht das Plugin alle vorhanden IRQs im System.
+]])
+
+-- collectd_irq config section
+s = m:section( NamedSection, "collectd_irq", "luci_statistics", "Pluginkonfiguration" )
+
+-- collectd_irq.enable
+enable = s:option( Flag, "enable", "Plugin aktivieren" )
+enable.default = 0
+
+-- collectd_irq.irqs (Irq)
+irqs = s:option( Value, "Irqs", "Überwachte Interrupts", "mehrere mit Leerzeichen trennen" )
+irqs.optional = true
+irqs:depends( "enable", 1 )
+
+-- collectd_irq.ignoreselected (IgnoreSelected)
+ignoreselected = s:option( Flag, "IgnoreSelected", "Alle Interrupts außer ausgewählte überwachen" )
+ignoreselected.default = 0
+ignoreselected.optional = "true"
+ignoreselected:depends( "enable", 1 )
+
+return m
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/netlink.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/netlink.lua
new file mode 100644
index 0000000000..f027f37780
--- /dev/null
+++ b/applications/luci-statistics/src/model/cbi/admin_statistics/netlink.lua
@@ -0,0 +1,84 @@
+--[[
+
+Luci configuration model for statistics - collectd netlink plugin configuration
+(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+]]--
+
+require("ffluci.sys")
+
+
+m = Map("luci_statistics", "Interface Plugin",
+[[Das Netlink-Plugin sammelt erweiterte Informationen wie Qdisc-, Class- und Filter-Werten auf einzelnen Schnittstellen.]])
+
+-- collectd_netlink config section
+s = m:section( NamedSection, "collectd_netlink", "luci_statistics", "Pluginkonfiguration" )
+
+-- collectd_netlink.enable
+enable = s:option( Flag, "enable", "Plugin aktivieren" )
+enable.default = 0
+
+-- collectd_netlink.interfaces (Interface)
+interfaces = s:option( MultiValue, "Interfaces", "einfach Überwachte Schnittstellen", "mehrere Einträge mit Strg selektieren" )
+interfaces.widget = "select"
+interfaces.optional = true
+interfaces:depends( "enable", 1 )
+interfaces:value("")
+for i, v in ipairs(ffluci.sys.net.devices()) do
+ interfaces:value(v)
+end
+
+-- collectd_netlink.verboseinterfaces (VerboseInterface)
+verboseinterfaces = s:option( MultiValue, "VerboseInterfaces", "detailliert Überwachte Schnittstellen", "mehrere Einträge mit Strg selektieren" )
+verboseinterfaces.widget = "select"
+verboseinterfaces.optional = true
+verboseinterfaces:depends( "enable", 1 )
+verboseinterfaces:value("")
+for i, v in ipairs(ffluci.sys.net.devices()) do
+ verboseinterfaces:value(v)
+end
+
+-- collectd_netlink.qdiscs (QDisc)
+qdiscs = s:option( MultiValue, "QDiscs", "Queue Discipline auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" )
+qdiscs.widget = "select"
+qdiscs.optional = true
+qdiscs:depends( "enable", 1 )
+qdiscs:value("")
+for i, v in ipairs(ffluci.sys.net.devices()) do
+ qdiscs:value(v)
+end
+
+-- collectd_netlink.classs (Class)
+classs = s:option( MultiValue, "Classs", "Shapingklassen auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" )
+classs.widget = "select"
+classs.optional = true
+classs:depends( "enable", 1 )
+classs:value("")
+for i, v in ipairs(ffluci.sys.net.devices()) do
+ classs:value(v)
+end
+
+-- collectd_netlink.filters (Filter)
+filters = s:option( MultiValue, "Filters", "Filterklassen auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" )
+filters.widget = "select"
+filters.optional = true
+filters:depends( "enable", 1 )
+filters:value("")
+for i, v in ipairs(ffluci.sys.net.devices()) do
+ filters:value(v)
+end
+
+-- collectd_netlink.ignoreselected (IgnoreSelected)
+ignoreselected = s:option( Flag, "IgnoreSelected", "Alle Schnittstellen außer ausgewählte überwachen" )
+ignoreselected.default = 0
+ignoreselected:depends( "enable", 1 )
+
+return m
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/network.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/network.lua
new file mode 100644
index 0000000000..ab3c6303c5
--- /dev/null
+++ b/applications/luci-statistics/src/model/cbi/admin_statistics/network.lua
@@ -0,0 +1,84 @@
+--[[
+
+Luci configuration model for statistics - collectd network plugin configuration
+(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+]]--
+
+
+m = Map("luci_statistics", "Network Plugin",
+[[Das Network-Plugin ermöglicht den netzwerkgestützen Austausch von Statistikdaten.]])
+
+-- collectd_network config section
+s = m:section( NamedSection, "collectd_network", "luci_statistics", "Pluginkonfiguration" )
+
+-- collectd_network.enable
+enable = s:option( Flag, "enable", "Plugin aktivieren" )
+enable.default = 0
+
+
+-- collectd_network_listen config section (Listen)
+listen = m:section( TypedSection, "collectd_network_listen", "Schnittstellen für eingehende Verbindungen",
+[[Legt fest auf welchen Schnittstellen bzw. IP-Adressen collectd auf eingehende Verbindungen wartet.]])
+listen.addremove = true
+listen.anonymous = true
+
+
+-- collectd_network_listen.host
+listen_host = listen:option( Value, "host", "Listen-Host", "Host-, IP- oder IPv6-Adresse" )
+listen_host.default = "0.0.0.0"
+
+-- collectd_network_listen.port
+listen_port = listen:option( Value, "port", "Listen-Port", "Partnummer 0 - 65535" )
+listen_port.default = 25826
+listen_port.isinteger = true
+listen_port.optional = true
+
+
+-- collectd_network_server config section (Server)
+server = m:section( TypedSection, "collectd_network_server", "Schnittstellen für ausgehende Verbindungen",
+[[Legt fest auf welchen Schnittstellen bzw. IP-Adressen collectd als Server agiert.]])
+server.addremove = true
+server.anonymous = true
+
+
+-- collectd_network_server.host
+server_host = server:option( Value, "host", "Server-Host", "Host-, IP- oder IPv6-Adresse" )
+server_host.default = "0.0.0.0"
+
+-- collectd_network_server.port
+server_port = server:option( Value, "port", "Server-Port", "Partnummer 0 - 65535" )
+server_port.default = 25826
+server_port.isinteger = true
+server_port.optional = true
+
+-- collectd_network.timetolive (TimeToLive)
+ttl = s:option( Value, "TimeToLive", "Time-to-Live für die Pakete", "Werte 0 bis 255" )
+ttl.default = 128
+ttl.isinteger = true
+ttl.optional = true
+ttl:depends( "enable", 1 )
+
+-- collectd_network.forward (Forward)
+forward = s:option( Flag, "Forward", "Weiterleitung zwischen verschiedenen Listen- und Server-Adressen" )
+forward.default = 0
+forward.optional = true
+forward:depends( "enable", 1 )
+
+-- collectd_network.forward (CacheFlush)
+forward = s:option( Value, "CacheFlush", "Löschintervall für temporäre Daten", "in Sekunden" )
+forward.default = 86400
+forward.isinteger = true
+forward.optional = true
+forward:depends( "enable", 1 )
+
+
+return m
diff --git a/applications/luci-statistics/src/model/menu/70luci-statistics.lua b/applications/luci-statistics/src/model/menu/70luci-statistics.lua
index 3e3405fd00..c28c1fc284 100644
--- a/applications/luci-statistics/src/model/menu/70luci-statistics.lua
+++ b/applications/luci-statistics/src/model/menu/70luci-statistics.lua
@@ -9,32 +9,23 @@ act( "disk", "Festplatte" )
act( "dns", "DNS" )
act( "email", "E-Mail" )
act( "exec", "Exec" )
---act( "hddtemp", "Festplattentemperatur" )
act( "interface", "Schnittstellen" )
act( "iptables", "Firewall" )
---act( "irq", "Interrupts" )
---act( "libvirt", "Virtualisierung" )
---act( "logfile", "Protokolldateien" )
---act( "mbmon", "Mainboardsensoren" )
---act( "memcached", "Memcached" )
---act( "mysql", "MySQL" )
---act( "netlink", "Netlink" )
---act( "network", "Netzwerk" )
+act( "irq", "Interrupts" )
+act( "logfile", "Protokolldateien" )
+act( "netlink", "Netlink" )
+act( "network", "Netzwerk" )
--act( "nginx", "nginx Server" )
--act( "ntpd", "NTP Server" )
---act( "nut", "Nut" )
---act( "perl", "Perl" )
act( "ping", "Ping" )
--act( "powerdns", "Powerdns Server" )
-act( "processes", "Prozesse" )
+--act( "processes", "Prozesse" )
--act( "rrdtool", "RRD Tool" )
--act( "sensors", "Sensoren" )
--act( "snmp", "SNMP Datenquellen" )
--act( "syslog", "Systemlog" )
--act( "tail", "Dateiverfolgung" )
--act( "teamspeak2", "TeamSpeak 2" )
-act( "tcpconns", "TCP Verbindungen" )
+--act( "tcpconns", "TCP Verbindungen" )
--act( "unixsock", "UNIX Sockets" )
---act( "uuid", "UUID" )
--act( "vmem", "Vmem" )
---act( "vserver", "VServer" )