telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

[inputs.ping] Windows - Exec method - interface property does not work

Open mbhs-josh opened this issue 7 months ago • 0 comments

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

  1. Assign multiple IP addresses to a Windows device.
  2. Configure Telegraf to send pings (method = exec) from each IP address using the interface property.
  3. Open Task Manager and view the Command Line for the Ping command from the details tab.
  4. Note that the -S command 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) 
 } 

mbhs-josh avatar May 29 '25 01:05 mbhs-josh