config 'statistics' 'general'
option 'BaseDir' '/var/run/collectd'
- option 'Include' '/etc/collectd/conf.d/*.conf'
+ option 'Include' '/etc/collectd/conf.d'
option 'PIDFile' '/var/run/collectd.pid'
option 'PluginDir' '/usr/lib/collectd'
option 'TypesDB' '/etc/collectd/types.db'
option 'Interval' '30'
- option 'ReadThreads' '5'
+ option 'ReadThreads' '2'
config 'statistics' 'collectd_ping'
option 'enable' '1'
option 'Hosts' '127.0.0.1'
config 'statistics' 'collectd_csv'
- option 'enable' '1'
+ option 'enable' '0'
option 'StoreRates' '0'
option 'DataDir' '/tmp'
config 'statistics' 'collectd_dns'
option 'enable' '1'
- option 'Interfaces' 'ffdhcp ff lan wan'
+ option 'Interfaces' 'ffdhcp ff br-lan'
option 'IgnoreSources' '127.0.0.1'
config 'statistics' 'collectd_email'
option 'enable' '1'
- option 'SocketFile' '/var/run/collectd-email.socket'
+ option 'SocketFile' '/var/run/collectd/email.sock'
+ option 'SocketGroup' 'nogroup'
config 'statistics' 'collectd_exec'
option 'enable' '1'
config 'statistics' 'collectd_interface'
option 'enable' '1'
- option 'Interfaces' 'ffdhcp ff lan wan'
+ option 'Interfaces' 'br-lan br-ff'
option 'IgnoreSelected' '0'
config 'statistics' 'collectd_iptables'
option 'Irqs' '2 3 4 7'
config 'statistics' 'collectd_logfile'
- option 'enable' '1'
+ option 'enable' '0'
option 'LogLevel' 'notice'
option 'File' '/var/log/collectd.log'
option 'Timestamp' '1'
option 'QDiscs' 'br-lan br-ff'
config 'statistics' 'collectd_network'
- option 'enable' '1'
+ option 'enable' '0'
config 'collectd_network_listen'
option 'host' '0.0.0.0'
config 'statistics' 'collectd_processes'
option 'enable' '1'
- option 'Processs' 'olsrd tincd bmxd'
config 'statistics' 'collectd_tcpconns'
option 'enable' '1'
option 'LocalPorts' '22 80 443'
config 'statistics' 'collectd_unixsock'
+ option 'enable' '0'
+ option 'SocketFile' '/var/run/collectd/query.sock'
+ option 'SocketGroup' 'nogroup'
+
+config 'statistics' 'collectd_wireless'
option 'enable' '1'
- option 'SocketFile' '/var/run/collectd-query.sock'
+config 'statistics' 'collectd_rrdtool'
+ option 'enable' '1'
+ option 'DataDir' '/tmp'
+ option 'RRARows' '100'
+ option 'RRASingle' '1'
if type(config) == "table" and ( plugin == "general" or config.enable == "1" ) then
- if plugin ~= "general" then print( "<Plugin " .. plugin .. ">" ) end
+ local params = ""
if type( plugins[plugin] ) == "function" then
- plugins[plugin]( config )
+ params = plugins[plugin]( config )
else
- config_generic( config, plugins[plugin][1], plugins[plugin][2], plugins[plugin][3], plugin == "general" )
+ params = config_generic( config, plugins[plugin][1], plugins[plugin][2], plugins[plugin][3], plugin == "general" )
end
+
if plugin ~= "general" then
- print( "</Plugin>\n" )
+ print( "LoadPlugin " .. plugin )
+
+ if params:len() > 0 then
+ print( "<Plugin " .. plugin .. ">\n" .. params .. "</Plugin>\n" )
+ else
+ print( "" )
+ end
else
- print( "\n" )
+ print( params .. "\n" )
end
-
end
end
function config_generic( c, singles, bools, lists, nopad )
+ local str = ""
if type(c) == "table" then
if type(singles) == "table" then
for i, key in ipairs( singles ) do
- _string( c[key], key, nopad )
+ str = str .. _string( c[key], key, nopad )
end
end
if type(bools) == "table" then
for i, key in ipairs( bools ) do
- _bool( c[key], key, nopad )
+ str = str .. _bool( c[key], key, nopad )
end
end
if type(lists) == "table" then
- _list_expand( c, lists, nopad )
+ str = str .. _list_expand( c, lists, nopad )
end
-
end
+ return str
end
function config_exec( c )
+ local str = ""
for s in pairs(sections) do
for key, type in pairs({ Exec="collectd_exec_input", NotificationExec="collectd_exec_notify" }) do
if sections[s][".type"] == type then
cmd = sections[s].cmdline
- user = sections[s].cmduser or "root"
- group = sections[s].cmdgroup or "root"
+ user = sections[s].cmduser or "nobody"
+ group = sections[s].cmdgroup or "nogroup"
- print( "\t" .. key .. " " .. user .. ":" .. group .. ' "' .. cmd .. '"' )
+ str = str .. "\t" .. key .. " " .. user .. ":" .. group .. ' "' .. cmd .. "\"\n"
end
end
end
+
+ return str
end
function config_iptables( c )
+ local str = ""
for s in pairs(sections) do
if sections[s][".type"] == "collectd_iptables_match" then
for i, rule in ipairs( ipt:find( search ) ) do
- name = sections[s].name
- if i > 1 then name = name .. " (" .. i .. ")" end
-
- print( "\tChain " .. rule.table .. " " .. rule.chain .. " " .. rule.index .. ' "' .. name .. '"' )
+ name = sections[s].name:gsub( "%s+", "_" )
+ if i > 1 then name = name .. "_(" .. i .. ")" end
+ str = str .. "\tChain " .. rule.table .. " " .. rule.chain .. " " .. rule.index .. ' "' .. name .. "\"\n"
end
end
end
+
+ return str
end
function config_network( c )
+ local str = ""
- 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
+ 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
+ host = sections[s].host
+ port = sections[s].port
if host then
if port then
- print( "\t" .. key .. " " .. host .. " " .. port )
+ str = str .. "\t" .. key .. " " .. host .. " " .. port .. "\n"
else
- print( "\t" .. key .. " " .. host )
+ str = str .. "\t" .. key .. " " .. host .. "\n"
end
end
end
end
end
- _string( c["TimeToLive"], "TimeToLive" )
- _string( c["CacheFlush"], "CacheFlush" )
- _bool( c["Forward"], "Forward" )
+ return str .. _string( c["TimeToLive"], "TimeToLive" )
+ .. _string( c["CacheFlush"], "CacheFlush" )
+ .. _bool( c["Forward"], "Forward" )
end
function _list_expand( c, l, nopad )
+ local str = ""
+
for i, n in ipairs(l) do
if c[n] then
- _expand( c[n], n:gsub( "(%w+)s", "%1" ), nopad )
+ if n:find("(%w+)ses") then
+ k = n:gsub("(%w+)ses", "%1s")
+ else
+ k = n:gsub("(%w+)s", "%1")
+ end
+
+ str = str .. _expand( c[n], k, nopad )
end
end
+
+ return str
end
function _expand( s, n, nopad )
if type(s) == "string" then
+ local str = ""
+
for i, v in ipairs( ffluci.util.split( s, "%s+", nil, true ) ) do
- _string( v, n, nopad )
+ str = str .. _string( v, n, nopad )
end
+
+ return str
end
end
function _bool( s, n, nopad )
+ local str = ""
local pad = ""
if not nopad then pad = "\t" end
if s and s == "1" then
- print( pad .. n .. " true" )
+ str = pad .. n .. " true"
else
- print( pad .. n .. " false" )
+ str = pad .. n .. " false"
end
+
+ return str .. "\n"
end
function _string( s, n, nopad )
+ local str = ""
local pad = ""
if not nopad then pad = "\t" end
if s then
- if not s:find("%d") then
- if not s:find("%s") then
- print( pad .. n .. " " .. s )
+ if s:find("[^%d]") then
+ if not s:find("[^%w]") then
+ str = pad .. n .. " " .. s
else
- print( pad .. n .. ' "' .. s '"' )
+ str = pad .. n .. ' "' .. s .. '"'
end
else
- print( pad .. n .. " " .. s )
+ str = pad .. n .. " " .. s
end
+
+ str = str .. "\n"
end
+
+ return str
end
},
email = {
- { "SocketFile", "SocketUser", "SocketPerms", "MaxConns" },
+ { "SocketFile", "SocketGroup", "SocketPerms", "MaxConns" },
{ },
{ }
},
netlink = {
{ },
{ "IgnoreSelected" },
- { "Interfaces", "VerboseInterfaces", "QDiscs", "Classs", "Filters" }
+ { "Interfaces", "VerboseInterfaces", "QDiscs", "Classes", "Filters" }
},
network = config_network,
processes = {
{ },
{ },
- { "Processs" }
+ { "Processes" }
+ },
+
+ rrdtool = {
+ { "DataDir", "StepSize", "HeartBeat", "RRARows", "XFF", "CacheFlush", "CacheTimeout" },
+ { "RRASingle" },
+ { "RRATimespans" }
},
tcpconns = {
},
unixsock = {
- { "SocketFile", "SocketUser", "SocketPerms" },
+ { "SocketFile", "SocketGroup", "SocketPerms" },
+ { },
+ { }
+ },
+
+ wireless = {
+ { },
{ },
{ }
},
--- /dev/null
+--[[
+
+Luci configuration model for statistics - collectd rrdtool 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", "RRDTool Plugin",
+[[Das RRDTool-Plugin schreibt die gesammelten Werte in sogenannte RRD Datenbanken, welche die
+Grundlage für die Statistik-Diagramme bilden.<br /><br />
+<strong>Die Einstellungen auf dieser Seite sollten nur in Ausnahmefällen geändert werden,
+falsche Einstellungen führen zu einem sehr hohem Platzverbrauch im Temp-Verzeichnis und das
+Gerät kann nur noch im Failsafe-Modus repariert werden!</strong>]])
+
+-- collectd_rrdtool config section
+s = m:section( NamedSection, "collectd_rrdtool", "luci_statistics", "Pluginkonfiguration" )
+
+-- collectd_rrdtool.enable
+enable = s:option( Flag, "enable", "Plugin aktivieren" )
+enable.default = 1
+
+-- collectd_rrdtool.datadir (DataDir)
+datadir = s:option( Value, "DataDir", "Speicherort für die RRD Datenbanken" )
+datadir.default = "/tmp"
+datadir.rmempty = true
+datadir.optional = true
+datadir:depends( "enable", 1 )
+
+-- collectd_rrdtool.stepsize (StepSize)
+stepsize = s:option( Value, "StepSize", "Schritt-Interval", "in Sekunden" )
+stepsize.default = 30
+stepsize.isinteger = true
+stepsize.rmempty = true
+stepsize.optional = true
+stepsize:depends( "enable", 1 )
+
+-- collectd_rrdtool.heartbeat (HeartBeat)
+heartbeat = s:option( Value, "HeartBeat", "Heart-Beat-Interval", "in Sekunden" )
+heartbeat.default = 60
+heartbeat.isinteger = true
+heartbeat.rmempty = true
+heartbeat.optional = true
+heartbeat:depends( "enable", 1 )
+
+-- collectd_rrdtool.rrasingle (RRASingle)
+rrasingle = s:option( Flag, "RRASingle", 'Jeweils nur ein RRA anlegen', "reduziert die Größe der RRDs" )
+rrasingle.default = true
+rrasingle.rmempty = true
+rrasingle.optional = true
+rrasingle:depends( "enable", 1 )
+
+-- collectd_rrdtool.rratimespans (RRATimespan)
+rratimespans = s:option( Value, "RRATimespans", "Gespeicherte Zeitspannen", "in Sekunden; mehrere mit Leerzeichen trennen" )
+rratimespans.default = "600 86400 604800 2678400 31622400"
+rratimespans.rmempty = true
+rratimespans.optional = true
+rratimespans:depends( "enable", 1 )
+
+-- collectd_rrdtool.rrarows (RRARows)
+rrarows = s:option( Value, "RRARows", "Anzahl der Datenpunkte pro Zeitspanne" )
+rrarows.isinteger = true
+rrarows.default = 100
+rrarows.rmempty = true
+rrarows.optional = true
+rrarows:depends( "enable", 1 )
+
+-- collectd_rrdtool.xff (XFF)
+xff = s:option( Value, "XFF", "RRD XFiles Faktor" )
+xff.default = 0.1
+xff.isnumber = true
+xff.rmempty = true
+xff.optional = true
+xff:depends( "enable", 1 )
+
+-- collectd_rrdtool.cachetimeout (CacheTimeout)
+cachetimeout = s:option( Value, "CacheTimeout", "Daten für Zeitspanne cachen", "in Sekunden" )
+cachetimeout.isinteger = true
+cachetimeout.default = 100
+cachetimeout.rmempty = true
+cachetimeout.optional = true
+cachetimeout:depends( "enable", 1 )
+
+-- collectd_rrdtool.cacheflush (CacheFlush)
+cacheflush = s:option( Value, "CacheFlush", "Cache nach Zeitspanne leeren", "in Sekunden" )
+cacheflush.isinteger = true
+cacheflush.default = 100
+cacheflush.rmempty = true
+cacheflush.optional = true
+cacheflush:depends( "enable", 1 )
+
+return m