* ffluci/statistics: add cbi model for rrdtool, fix stat-genconfig to allow correctly spelled list value parameters, updated default config

This commit is contained in:
Jo-Philipp Wich 2008-05-22 13:09:45 +00:00
parent 68fd8eacdd
commit 0e33719761
6 changed files with 211 additions and 56 deletions

View file

@ -1,12 +1,12 @@
config 'statistics' 'general' config 'statistics' 'general'
option 'BaseDir' '/var/run/collectd' 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 'PIDFile' '/var/run/collectd.pid'
option 'PluginDir' '/usr/lib/collectd' option 'PluginDir' '/usr/lib/collectd'
option 'TypesDB' '/etc/collectd/types.db' option 'TypesDB' '/etc/collectd/types.db'
option 'Interval' '30' option 'Interval' '30'
option 'ReadThreads' '5' option 'ReadThreads' '2'
config 'statistics' 'collectd_ping' config 'statistics' 'collectd_ping'
option 'enable' '1' option 'enable' '1'
@ -14,7 +14,7 @@ config 'statistics' 'collectd_ping'
option 'Hosts' '127.0.0.1' option 'Hosts' '127.0.0.1'
config 'statistics' 'collectd_csv' config 'statistics' 'collectd_csv'
option 'enable' '1' option 'enable' '0'
option 'StoreRates' '0' option 'StoreRates' '0'
option 'DataDir' '/tmp' option 'DataDir' '/tmp'
@ -32,12 +32,13 @@ config 'statistics' 'collectd_disk'
config 'statistics' 'collectd_dns' config 'statistics' 'collectd_dns'
option 'enable' '1' option 'enable' '1'
option 'Interfaces' 'ffdhcp ff lan wan' option 'Interfaces' 'ffdhcp ff br-lan'
option 'IgnoreSources' '127.0.0.1' option 'IgnoreSources' '127.0.0.1'
config 'statistics' 'collectd_email' config 'statistics' 'collectd_email'
option 'enable' '1' option 'enable' '1'
option 'SocketFile' '/var/run/collectd-email.socket' option 'SocketFile' '/var/run/collectd/email.sock'
option 'SocketGroup' 'nogroup'
config 'statistics' 'collectd_exec' config 'statistics' 'collectd_exec'
option 'enable' '1' option 'enable' '1'
@ -50,7 +51,7 @@ config 'collectd_exec_notify'
config 'statistics' 'collectd_interface' config 'statistics' 'collectd_interface'
option 'enable' '1' option 'enable' '1'
option 'Interfaces' 'ffdhcp ff lan wan' option 'Interfaces' 'br-lan br-ff'
option 'IgnoreSelected' '0' option 'IgnoreSelected' '0'
config 'statistics' 'collectd_iptables' config 'statistics' 'collectd_iptables'
@ -77,7 +78,7 @@ config 'statistics' 'collectd_irq'
option 'Irqs' '2 3 4 7' option 'Irqs' '2 3 4 7'
config 'statistics' 'collectd_logfile' config 'statistics' 'collectd_logfile'
option 'enable' '1' option 'enable' '0'
option 'LogLevel' 'notice' option 'LogLevel' 'notice'
option 'File' '/var/log/collectd.log' option 'File' '/var/log/collectd.log'
option 'Timestamp' '1' option 'Timestamp' '1'
@ -89,7 +90,7 @@ config 'statistics' 'collectd_netlink'
option 'QDiscs' 'br-lan br-ff' option 'QDiscs' 'br-lan br-ff'
config 'statistics' 'collectd_network' config 'statistics' 'collectd_network'
option 'enable' '1' option 'enable' '0'
config 'collectd_network_listen' config 'collectd_network_listen'
option 'host' '0.0.0.0' option 'host' '0.0.0.0'
@ -99,7 +100,6 @@ config 'collectd_network_server'
config 'statistics' 'collectd_processes' config 'statistics' 'collectd_processes'
option 'enable' '1' option 'enable' '1'
option 'Processs' 'olsrd tincd bmxd'
config 'statistics' 'collectd_tcpconns' config 'statistics' 'collectd_tcpconns'
option 'enable' '1' option 'enable' '1'
@ -107,6 +107,15 @@ config 'statistics' 'collectd_tcpconns'
option 'LocalPorts' '22 80 443' option 'LocalPorts' '22 80 443'
config 'statistics' 'collectd_unixsock' config 'statistics' 'collectd_unixsock'
option 'enable' '1' option 'enable' '0'
option 'SocketFile' '/var/run/collectd-query.sock' option 'SocketFile' '/var/run/collectd/query.sock'
option 'SocketGroup' 'nogroup'
config 'statistics' 'collectd_wireless'
option 'enable' '1'
config 'statistics' 'collectd_rrdtool'
option 'enable' '1'
option 'DataDir' '/tmp'
option 'RRARows' '100'
option 'RRASingle' '1'

View file

@ -31,64 +31,75 @@ function section( plugin )
if type(config) == "table" and ( plugin == "general" or config.enable == "1" ) then 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 if type( plugins[plugin] ) == "function" then
plugins[plugin]( config ) params = plugins[plugin]( config )
else 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 end
if plugin ~= "general" then if plugin ~= "general" then
print( "</Plugin>\n" ) print( "LoadPlugin " .. plugin )
else
print( "\n" )
end
if params:len() > 0 then
print( "<Plugin " .. plugin .. ">\n" .. params .. "</Plugin>\n" )
else
print( "" )
end
else
print( params .. "\n" )
end
end end
end end
function config_generic( c, singles, bools, lists, nopad ) function config_generic( c, singles, bools, lists, nopad )
local str = ""
if type(c) == "table" then if type(c) == "table" then
if type(singles) == "table" then if type(singles) == "table" then
for i, key in ipairs( singles ) do for i, key in ipairs( singles ) do
_string( c[key], key, nopad ) str = str .. _string( c[key], key, nopad )
end end
end end
if type(bools) == "table" then if type(bools) == "table" then
for i, key in ipairs( bools ) do for i, key in ipairs( bools ) do
_bool( c[key], key, nopad ) str = str .. _bool( c[key], key, nopad )
end end
end end
if type(lists) == "table" then if type(lists) == "table" then
_list_expand( c, lists, nopad ) str = str .. _list_expand( c, lists, nopad )
end end
end end
return str
end end
function config_exec( c ) function config_exec( c )
local str = ""
for s in pairs(sections) do for s in pairs(sections) do
for key, type in pairs({ Exec="collectd_exec_input", NotificationExec="collectd_exec_notify" }) do for key, type in pairs({ Exec="collectd_exec_input", NotificationExec="collectd_exec_notify" }) do
if sections[s][".type"] == type then if sections[s][".type"] == type then
cmd = sections[s].cmdline cmd = sections[s].cmdline
user = sections[s].cmduser or "root" user = sections[s].cmduser or "nobody"
group = sections[s].cmdgroup or "root" group = sections[s].cmdgroup or "nogroup"
print( "\t" .. key .. " " .. user .. ":" .. group .. ' "' .. cmd .. '"' ) str = str .. "\t" .. key .. " " .. user .. ":" .. group .. ' "' .. cmd .. "\"\n"
end end
end end
end end
return str
end end
function config_iptables( c ) function config_iptables( c )
local str = ""
for s in pairs(sections) do for s in pairs(sections) do
if sections[s][".type"] == "collectd_iptables_match" then if sections[s][".type"] == "collectd_iptables_match" then
@ -109,17 +120,19 @@ function config_iptables( c )
for i, rule in ipairs( ipt:find( search ) ) do for i, rule in ipairs( ipt:find( search ) ) do
name = sections[s].name name = sections[s].name:gsub( "%s+", "_" )
if i > 1 then name = name .. " (" .. i .. ")" end if i > 1 then name = name .. "_(" .. i .. ")" end
print( "\tChain " .. rule.table .. " " .. rule.chain .. " " .. rule.index .. ' "' .. name .. '"' ) str = str .. "\tChain " .. rule.table .. " " .. rule.chain .. " " .. rule.index .. ' "' .. name .. "\"\n"
end
end
end
end return str
end
end
end end
function config_network( c ) function config_network( c )
local str = ""
for s in pairs(sections) do for s in pairs(sections) do
for key, type in pairs({ Listen="collectd_network_listen", Server="collectd_network_server" }) do for key, type in pairs({ Listen="collectd_network_listen", Server="collectd_network_server" }) do
@ -130,65 +143,87 @@ function config_network( c )
if host then if host then
if port then if port then
print( "\t" .. key .. " " .. host .. " " .. port ) str = str .. "\t" .. key .. " " .. host .. " " .. port .. "\n"
else else
print( "\t" .. key .. " " .. host ) str = str .. "\t" .. key .. " " .. host .. "\n"
end end
end end
end end
end end
end end
_string( c["TimeToLive"], "TimeToLive" ) return str .. _string( c["TimeToLive"], "TimeToLive" )
_string( c["CacheFlush"], "CacheFlush" ) .. _string( c["CacheFlush"], "CacheFlush" )
_bool( c["Forward"], "Forward" ) .. _bool( c["Forward"], "Forward" )
end end
function _list_expand( c, l, nopad ) function _list_expand( c, l, nopad )
local str = ""
for i, n in ipairs(l) do for i, n in ipairs(l) do
if c[n] then 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
end end
return str
end end
function _expand( s, n, nopad ) function _expand( s, n, nopad )
if type(s) == "string" then if type(s) == "string" then
local str = ""
for i, v in ipairs( ffluci.util.split( s, "%s+", nil, true ) ) do for i, v in ipairs( ffluci.util.split( s, "%s+", nil, true ) ) do
_string( v, n, nopad ) str = str .. _string( v, n, nopad )
end end
return str
end end
end end
function _bool( s, n, nopad ) function _bool( s, n, nopad )
local str = ""
local pad = "" local pad = ""
if not nopad then pad = "\t" end if not nopad then pad = "\t" end
if s and s == "1" then if s and s == "1" then
print( pad .. n .. " true" ) str = pad .. n .. " true"
else else
print( pad .. n .. " false" ) str = pad .. n .. " false"
end end
return str .. "\n"
end end
function _string( s, n, nopad ) function _string( s, n, nopad )
local str = ""
local pad = "" local pad = ""
if not nopad then pad = "\t" end if not nopad then pad = "\t" end
if s then if s then
if not s:find("%d") then if s:find("[^%d]") then
if not s:find("%s") then if not s:find("[^%w]") then
print( pad .. n .. " " .. s ) str = pad .. n .. " " .. s
else else
print( pad .. n .. ' "' .. s '"' ) str = pad .. n .. ' "' .. s .. '"'
end end
else else
print( pad .. n .. " " .. s ) str = pad .. n .. " " .. s
end end
str = str .. "\n"
end end
return str
end end
@ -224,7 +259,7 @@ plugins = {
}, },
email = { email = {
{ "SocketFile", "SocketUser", "SocketPerms", "MaxConns" }, { "SocketFile", "SocketGroup", "SocketPerms", "MaxConns" },
{ }, { },
{ } { }
}, },
@ -254,7 +289,7 @@ plugins = {
netlink = { netlink = {
{ }, { },
{ "IgnoreSelected" }, { "IgnoreSelected" },
{ "Interfaces", "VerboseInterfaces", "QDiscs", "Classs", "Filters" } { "Interfaces", "VerboseInterfaces", "QDiscs", "Classes", "Filters" }
}, },
network = config_network, network = config_network,
@ -262,7 +297,13 @@ plugins = {
processes = { processes = {
{ }, { },
{ }, { },
{ "Processs" } { "Processes" }
},
rrdtool = {
{ "DataDir", "StepSize", "HeartBeat", "RRARows", "XFF", "CacheFlush", "CacheTimeout" },
{ "RRASingle" },
{ "RRATimespans" }
}, },
tcpconns = { tcpconns = {
@ -272,7 +313,13 @@ plugins = {
}, },
unixsock = { unixsock = {
{ "SocketFile", "SocketUser", "SocketPerms" }, { "SocketFile", "SocketGroup", "SocketPerms" },
{ },
{ }
},
wireless = {
{ },
{ }, { },
{ } { }
}, },

View file

@ -56,8 +56,8 @@ for i, v in ipairs(ffluci.sys.net.devices()) do
qdiscs:value(v) qdiscs:value(v)
end end
-- collectd_netlink.classs (Class) -- collectd_netlink.classes (Class)
classs = s:option( MultiValue, "Classs", "Shapingklassen auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" ) classs = s:option( MultiValue, "Classes", "Shapingklassen auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" )
classs.widget = "select" classs.widget = "select"
classs.optional = true classs.optional = true
classs:depends( "enable", 1 ) classs:depends( "enable", 1 )

View file

@ -24,7 +24,7 @@ enable = s:option( Flag, "enable", "Plugin aktivieren" )
enable.default = 0 enable.default = 0
-- collectd_processes.processs (Process) -- collectd_processes.processs (Process)
processes = s:option( Value, "Processs", "Überwachte Prozesse", "mehrere mit Leerzeichen trennen" ) processes = s:option( Value, "Processes", "Überwachte Prozesse", "mehrere mit Leerzeichen trennen" )
processes.default = "olsrd bmxd httpd dnsmasq dropbear tinc" processes.default = "olsrd bmxd httpd dnsmasq dropbear tinc"
processes:depends( "enable", 1 ) processes:depends( "enable", 1 )

View file

@ -0,0 +1,99 @@
--[[
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

View file

@ -20,7 +20,7 @@ act( "network", "Netzwerk" )
act( "ping", "Ping" ) act( "ping", "Ping" )
--act( "powerdns", "Powerdns Server" ) --act( "powerdns", "Powerdns Server" )
act( "processes", "Prozesse" ) act( "processes", "Prozesse" )
--act( "rrdtool", "RRD Tool" ) act( "rrdtool", "RRDTool" )
--act( "sensors", "Sensoren" ) --act( "sensors", "Sensoren" )
--act( "snmp", "SNMP Datenquellen" ) --act( "snmp", "SNMP Datenquellen" )
--act( "syslog", "Systemlog" ) --act( "syslog", "Systemlog" )