-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
Bug: inputs.iptables plugin does not read some rules, because it expects comments only in the end of each line of iptables output, but some of these lines do not end with comment.
Example:
# iptables -nvL SHAPER -t mangle -x | tail -2
0 0 ACCEPT all -- * * 1.3.5.7 0.0.0.0/0 /* test */
0 0 CLASSIFY all -- * * 1.3.5.7 0.0.0.0/0 /* test2 */ CLASSIFY set 1:4
# telegraf --config /etc/telegraf/telegraf.conf --input-filter iptables --test
* Plugin: inputs.iptables, Collection 1
> iptables,ruleid=test,dc=somedc,host=somehost,table=mangle,chain=SHAPER bytes=0i,pkts=0i 1501092198000000000
As you can see, test2 rule ommited by plugin parser.
Reason:
https://github.com/influxdata/telegraf/blob/master/plugins/inputs/iptables/iptables.go#L98
var valuesRe = regexp.MustCompile(^\s*([0-9]+)\s+([0-9]+)\s+.?(/*\s(.)\s*/)?$)
Fix: The end of regexp */)?$ must be rewriten to something like */)?+.*?$
I don't know golang and it's toolchain, so cannot check it, but I'm pretty sure the problem is here.