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 chains[rule.chain] = true
24 targets[rule.target] = true
28 m = Map("luci_statistics")
30 -- collectd_iptables config section
31 s = m:section( NamedSection, "collectd_iptables", "luci_statistics" )
33 -- collectd_iptables.enable
34 enable = s:option( Flag, "enable" )
38 -- collectd_iptables_match config section (Chain directives)
39 rule = m:section( TypedSection, "collectd_iptables_match" )
44 -- collectd_iptables_match.name
45 rule_table = rule:option( Value, "name" )
47 -- collectd_iptables_match.table
48 rule_table = rule:option( ListValue, "table" )
49 rule_table.default = "filter"
50 rule_table.rmempty = true
51 rule_table.optional = true
53 rule_table:value("filter")
54 rule_table:value("nat")
55 rule_table:value("mangle")
58 -- collectd_iptables_match.chain
59 rule_chain = rule:option( ListValue, "chain" )
60 rule_chain.rmempty = true
61 rule_chain.optional = true
64 for chain, void in pairs( chains ) do
65 rule_chain:value( chain )
69 -- collectd_iptables_match.target
70 rule_target = rule:option( ListValue, "target" )
71 rule_target.rmempty = true
72 rule_target.optional = true
75 for target, void in pairs( targets ) do
76 rule_target:value( target )
80 -- collectd_iptables_match.protocol
81 rule_protocol = rule:option( ListValue, "protocol" )
82 rule_protocol.rmempty = true
83 rule_protocol.optional = true
84 rule_protocol:value("")
85 rule_protocol:value("tcp")
86 rule_protocol:value("udp")
87 rule_protocol:value("icmp")
89 -- collectd_iptables_match.source
90 rule_source = rule:option( Value, "source" )
91 rule_source.default = "0.0.0.0/0"
92 rule_source.rmempty = true
93 rule_source.optional = true
95 -- collectd_iptables_match.destination
96 rule_destination = rule:option( Value, "destination" )
97 rule_destination.default = "0.0.0.0/0"
98 rule_destination.rmempty = true
99 rule_destination.optional = true
101 -- collectd_iptables_match.inputif
102 rule_inputif = rule:option( Value, "inputif" )
103 rule_inputif.rmempty = true
104 rule_inputif.optional = true
106 -- collectd_iptables_match.outputif
107 rule_outputif = rule:option( Value, "outputif" )
108 rule_outputif.rmempty = true
109 rule_outputif.optional = true
111 -- collectd_iptables_match.options
112 rule_options = rule:option( Value, "options" )
113 rule_options.rmempty = true
114 rule_options.optional = true