[inputs.ping] Windows - Exec method - interface property does not work
Relevant telegraf.conf
[[inputs.ping]]
method = "exec"
interval = "15s"
ping_interval = 1.0
timeout = 1.0
deadline = 10
count = 10
urls = [
"8.8.8.8",
"8.8.4.4"
]
interface = "10.60.136.191"
[[inputs.ping]]
method = "exec"
interval = "15s"
ping_interval = 1.0
timeout = 1.0
deadline = 10
count = 10
urls = [
"8.8.8.8",
"8.8.4.4"
]
interface = "10.60.136.192"
Logs from Telegraf
N/A
System info
Telegraf 1.34.4
Docker
No response
Steps to reproduce
- Assign multiple IP addresses to a Windows device.
- Configure Telegraf to send pings (method =
exec) from each IP address using theinterfaceproperty. - Open
Task Managerand view theCommand Linefor the Ping command from thedetailstab. - Note that the
-Scommand line argument is not present.
Expected behavior
The -S command line argument should be present to indicate that the Ping command will use the nominated source address.
Actual behavior
The -S command line argument is not present and Ping uses the default source address instead of the specified address.
Additional info
I can see that Unix based systems support passing the appropriate argument for the interface property. See here:
https://github.com/influxdata/telegraf/blob/bfb9ff2b7183ab40d6474fd0d970ddcf7ddaf6d4/plugins/inputs/ping/ping_notwindows.go#L154-L166
The same support is missing for Windows though:
https://github.com/influxdata/telegraf/blob/bfb9ff2b7183ab40d6474fd0d970ddcf7ddaf6d4/plugins/inputs/ping/ping_windows.go#L80-L95
As Windows supports specifying the source address, I would think it is as simple as adding something similar to the below to resolve this.
if p.Interface != "" {
args = append(args, "-S", p.Interface)
}