From b878aa8cedc3b8d58ddc778ce210fb41b9f4f4c3 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 20 May 2008 19:15:47 +0000 Subject: [PATCH] * ffluci/statistics: updated menu, added collectd interface and iptables cbi models --- .../model/cbi/admin_statistics/interface.lua | 41 ++++++ .../model/cbi/admin_statistics/iptables.lua | 126 ++++++++++++++++++ .../src/model/menu/70luci-statistics.lua | 10 +- 3 files changed, 172 insertions(+), 5 deletions(-) diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/interface.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/interface.lua index e69de29bb..e7e3042a9 100644 --- a/applications/luci-statistics/src/model/cbi/admin_statistics/interface.lua +++ b/applications/luci-statistics/src/model/cbi/admin_statistics/interface.lua @@ -0,0 +1,41 @@ +--[[ + +Luci configuration model for statistics - collectd interface plugin configuration +(c) 2008 Freifunk Leipzig / Jo-Philipp Wich + +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", "Interface Plugin", +[[Das Interface-Plugin sammelt Informationen zum Netzwerkverkehr auf den einzelnen Schnittstellen.]]) + +-- collectd_interface config section +s = m:section( NamedSection, "collectd_interface", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_interface.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_interface.interfaces (Interface) +interfaces = s:option( MultiValue, "Interfaces", "Überwachte Schnittstellen", "mehrere Einträge mit Strg selektieren" ) +interfaces.widget = "select" +interfaces:depends( "enable", 1 ) +for k, v in pairs(ffluci.model.uci.sections("network")) do + if v[".type"] == "interface" and k ~= "loopback" then + interfaces:value(k) + end +end + +-- collectd_interface.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/iptables.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/iptables.lua index e69de29bb..65e045b73 100644 --- a/applications/luci-statistics/src/model/cbi/admin_statistics/iptables.lua +++ b/applications/luci-statistics/src/model/cbi/admin_statistics/iptables.lua @@ -0,0 +1,126 @@ +--[[ + +Luci configuration model for statistics - collectd iptables plugin configuration +(c) 2008 Freifunk Leipzig / Jo-Philipp Wich + +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.iptparser") + +ip = ffluci.sys.iptparser.IptParser() +chains = { } +targets = { } + +for i, rule in ipairs( ip:find() ) do + chains[rule.chain] = true + targets[rule.target] = true +end + + +m = Map("luci_statistics", "Iptables Plugin", +[[Das Iptables-Plugin ermöglicht die Überwachung bestimmter Firewallregeln um +Werte wie die Anzahl der verarbeiteten Pakete oder die insgesamt erfasste Datenmenge +zu speichern.]]) + +-- collectd_iptables config section +s = m:section( NamedSection, "collectd_iptables", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_iptables.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + + +-- collectd_iptables_match config section (Chain directives) +rule = m:section( TypedSection, "collectd_iptables_match", "Regel hinzufügen", +[[Hier werden die Kriterien festgelegt, nach welchen die Firewall-Regeln zur Überwachung +ausgewählt werden.]]) +rule.addremove = true +rule.anonymous = true + + +-- collectd_iptables_match.name +rule_table = rule:option( Value, "name", "Name der Regel", "wird im Diagram verwendet" ) + +-- collectd_iptables_match.table +rule_table = rule:option( ListValue, "table", "Firewall-Tabelle" ) +rule_table.default = "filter" +rule_table.rmempty = true +rule_table.optional = true +rule_table:value("") +rule_table:value("filter") +rule_table:value("nat") +rule_table:value("mangle") + + +-- collectd_iptables_match.chain +rule_chain = rule:option( ListValue, "chain", "Firewall-Kette (Chain)" ) +rule_chain.rmempty = true +rule_chain.optional = true +rule_chain:value("") + +for chain, void in pairs( chains ) do + rule_chain:value( chain ) +end + + +-- collectd_iptables_match.target +rule_target = rule:option( ListValue, "target", "Firewall-Aktion (Target)" ) +rule_target.rmempty = true +rule_target.optional = true +rule_target:value("") + +for target, void in pairs( targets ) do + rule_target:value( target ) +end + + +-- collectd_iptables_match.protocol +rule_protocol = rule:option( ListValue, "protocol", "Netzwerkprotokoll" ) +rule_protocol.rmempty = true +rule_protocol.optional = true +rule_protocol:value("") +rule_protocol:value("tcp") +rule_protocol:value("udp") +rule_protocol:value("icmp") + + +-- collectd_iptables_match.source +rule_source = rule:option( Value, "source", "Quell-IP-Bereich", "Bereich in CIDR Notation" ) +rule_source.default = "0.0.0.0/0" +rule_source.rmempty = true +rule_source.optional = true + + +-- collectd_iptables_match.destination +rule_destination = rule:option( Value, "destination", "Ziel-IP-Bereich", "Bereich in CIDR Notation" ) +rule_destination.default = "0.0.0.0/0" +rule_destination.rmempty = true +rule_destination.optional = true + +-- collectd_iptables_match.inputif +rule_inputif = rule:option( Value, "inputif", "eingehende Schnittstelle", "z.B. eth0.0" ) +rule_inputif.default = "0.0.0.0/0" +rule_inputif.rmempty = true +rule_inputif.optional = true + +-- collectd_iptables_match.outputif +rule_outputif = rule:option( Value, "outputif", "ausgehende Schnittstelle", "z.B. eth0.1" ) +rule_outputif.default = "0.0.0.0/0" +rule_outputif.rmempty = true +rule_outputif.optional = true + +-- collectd_iptables_match.options +rule_options = rule:option( Value, "options", "Optionen", "z.B. reject-with tcp-reset" ) +rule_options.default = "0.0.0.0/0" +rule_options.rmempty = true +rule_options.optional = true + +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 ded0b8676..3e3405fd0 100644 --- a/applications/luci-statistics/src/model/menu/70luci-statistics.lua +++ b/applications/luci-statistics/src/model/menu/70luci-statistics.lua @@ -4,13 +4,13 @@ add( "admin", "statistics", "Statistiken", 70 ) --act( "ascent", "Ascent" ) --act( "cpufreq", "Cpufreq" ) act( "csv", "CSV" ) ---act( "df", "Speicher" ) ---act( "disk", "Festplatte" ) +act( "df", "Speicher" ) +act( "disk", "Festplatte" ) act( "dns", "DNS" ) ---act( "email", "E-Mail" ) +act( "email", "E-Mail" ) act( "exec", "Exec" ) --act( "hddtemp", "Festplattentemperatur" ) -act( "interface", "Netzwerkschnittstellen" ) +act( "interface", "Schnittstellen" ) act( "iptables", "Firewall" ) --act( "irq", "Interrupts" ) --act( "libvirt", "Virtualisierung" ) @@ -26,7 +26,7 @@ act( "iptables", "Firewall" ) --act( "perl", "Perl" ) act( "ping", "Ping" ) --act( "powerdns", "Powerdns Server" ) -act( "processes", "Prozessüberwachung" ) +act( "processes", "Prozesse" ) --act( "rrdtool", "RRD Tool" ) --act( "sensors", "Sensoren" ) --act( "snmp", "SNMP Datenquellen" ) -- 2.25.1