3 Luci configuration model for statistics - collectd iptables plugin configuration
4 (c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
16 require("luci.sys.iptparser")
18 ip = luci.sys.iptparser.IptParser()
22 for i, rule in ipairs( ip:find() ) do
23 if rule.chain and rule.target then
24 chains[rule.chain] = true
25 targets[rule.target] = true
30 m = Map("luci_statistics",
31 translate("Iptables Plugin Configuration"),
33 "The iptables plugin will monitor selected firewall rules and " ..
34 "collect informations about processed bytes and packets per rule."
37 -- collectd_iptables config section
38 s = m:section( NamedSection, "collectd_iptables", "luci_statistics" )
40 -- collectd_iptables.enable
41 enable = s:option( Flag, "enable", translate("Enable this plugin") )
45 -- collectd_iptables_match config section (Chain directives)
46 rule = m:section( TypedSection, "collectd_iptables_match",
47 translate("Add matching rule"),
49 "Here you can define various criteria by which the monitored " ..
50 "iptables rules are selected."
56 -- collectd_iptables_match.name
57 rule_table = rule:option( Value, "name",
58 translate("Name of the rule"), translate("max. 16 chars") )
60 -- collectd_iptables_match.table
61 rule_table = rule:option( ListValue, "table", translate("Table") )
62 rule_table.default = "filter"
63 rule_table.rmempty = true
64 rule_table.optional = true
66 rule_table:value("filter")
67 rule_table:value("nat")
68 rule_table:value("mangle")
71 -- collectd_iptables_match.chain
72 rule_chain = rule:option( ListValue, "chain", translate("Chain") )
73 rule_chain.rmempty = true
74 rule_chain.optional = true
77 for chain, void in pairs( chains ) do
78 rule_chain:value( chain )
82 -- collectd_iptables_match.target
83 rule_target = rule:option( ListValue, "target", translate("Action (target)") )
84 rule_target.rmempty = true
85 rule_target.optional = true
88 for target, void in pairs( targets ) do
89 rule_target:value( target )
93 -- collectd_iptables_match.protocol
94 rule_protocol = rule:option( ListValue, "protocol", translate("Network protocol") )
95 rule_protocol.rmempty = true
96 rule_protocol.optional = true
97 rule_protocol:value("")
98 rule_protocol:value("tcp")
99 rule_protocol:value("udp")
100 rule_protocol:value("icmp")
102 -- collectd_iptables_match.source
103 rule_source = rule:option( Value, "source", translate("Source ip range") )
104 rule_source.default = "0.0.0.0/0"
105 rule_source.rmempty = true
106 rule_source.optional = true
108 -- collectd_iptables_match.destination
109 rule_destination = rule:option( Value, "destination", translate("Destination ip range") )
110 rule_destination.default = "0.0.0.0/0"
111 rule_destination.rmempty = true
112 rule_destination.optional = true
114 -- collectd_iptables_match.inputif
115 rule_inputif = rule:option( Value, "inputif",
116 translate("Incoming interface"), translate("e.g. br-lan") )
117 rule_inputif.rmempty = true
118 rule_inputif.optional = true
120 -- collectd_iptables_match.outputif
121 rule_outputif = rule:option( Value, "outputif",
122 translate("Outgoing interface"), translate("e.g. br-ff") )
123 rule_outputif.rmempty = true
124 rule_outputif.optional = true
126 -- collectd_iptables_match.options
127 rule_options = rule:option( Value, "options",
128 translate("Options"), translate("e.g. reject-with tcp-reset") )
129 rule_options.rmempty = true
130 rule_options.optional = true