Allow alternate binaries for iptables input plugin. (#4682)
This commit is contained in:
parent
bcb65a5ee8
commit
6361fd3774
|
@ -2004,6 +2004,8 @@
|
||||||
# ## Setting 'use_lock' to true runs iptables with the "-w" option.
|
# ## Setting 'use_lock' to true runs iptables with the "-w" option.
|
||||||
# ## Adjust your sudo settings appropriately if using this option ("iptables -wnvl")
|
# ## Adjust your sudo settings appropriately if using this option ("iptables -wnvl")
|
||||||
# use_lock = false
|
# use_lock = false
|
||||||
|
# ## Define an alternate executable, such as "ip6tables". Default is "iptables".
|
||||||
|
# # binary = "ip6tables"
|
||||||
# ## defines the table to monitor:
|
# ## defines the table to monitor:
|
||||||
# table = "filter"
|
# table = "filter"
|
||||||
# ## defines the chains to monitor.
|
# ## defines the chains to monitor.
|
||||||
|
|
|
@ -45,6 +45,8 @@ Defining multiple instances of this plugin in telegraf.conf can lead to concurre
|
||||||
use_sudo = false
|
use_sudo = false
|
||||||
# run iptables with the lock option
|
# run iptables with the lock option
|
||||||
use_lock = false
|
use_lock = false
|
||||||
|
# Define an alternate executable, such as "ip6tables". Default is "iptables".
|
||||||
|
# binary = "ip6tables"
|
||||||
# defines the table to monitor:
|
# defines the table to monitor:
|
||||||
table = "filter"
|
table = "filter"
|
||||||
# defines the chains to monitor:
|
# defines the chains to monitor:
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
type Iptables struct {
|
type Iptables struct {
|
||||||
UseSudo bool
|
UseSudo bool
|
||||||
UseLock bool
|
UseLock bool
|
||||||
|
Binary string
|
||||||
Table string
|
Table string
|
||||||
Chains []string
|
Chains []string
|
||||||
lister chainLister
|
lister chainLister
|
||||||
|
@ -38,6 +39,8 @@ func (ipt *Iptables) SampleConfig() string {
|
||||||
## Setting 'use_lock' to true runs iptables with the "-w" option.
|
## Setting 'use_lock' to true runs iptables with the "-w" option.
|
||||||
## Adjust your sudo settings appropriately if using this option ("iptables -wnvl")
|
## Adjust your sudo settings appropriately if using this option ("iptables -wnvl")
|
||||||
use_lock = false
|
use_lock = false
|
||||||
|
## Define an alternate executable, such as "ip6tables". Default is "iptables".
|
||||||
|
# binary = "ip6tables"
|
||||||
## defines the table to monitor:
|
## defines the table to monitor:
|
||||||
table = "filter"
|
table = "filter"
|
||||||
## defines the chains to monitor.
|
## defines the chains to monitor.
|
||||||
|
@ -70,7 +73,13 @@ func (ipt *Iptables) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ipt *Iptables) chainList(table, chain string) (string, error) {
|
func (ipt *Iptables) chainList(table, chain string) (string, error) {
|
||||||
iptablePath, err := exec.LookPath("iptables")
|
var binary string
|
||||||
|
if ipt.Binary != "" {
|
||||||
|
binary = ipt.Binary
|
||||||
|
} else {
|
||||||
|
binary = "iptables"
|
||||||
|
}
|
||||||
|
iptablePath, err := exec.LookPath(binary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue