* ffluci/statistics: add cbi models for irq, netlink and network plugins, updated menu, default config and config generator

This commit is contained in:
Jo-Philipp Wich 2008-05-21 03:08:47 +00:00
parent f77474efc7
commit 5306660d04
6 changed files with 373 additions and 27 deletions

View file

@ -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'

View file

@ -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,
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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" )