Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pings.input native bind to interface doesn't work? #6642

Closed
Marctraider opened this issue Nov 9, 2019 · 2 comments · Fixed by #6667 or #8770
Closed

pings.input native bind to interface doesn't work? #6642

Marctraider opened this issue Nov 9, 2019 · 2 comments · Fixed by #6667 or #8770
Labels
bug unexpected problem or unintended behavior

Comments

@Marctraider
Copy link

Marctraider commented Nov 9, 2019

Relevant telegraf.conf:

[agent]
  hostname = "192.168.1.1"
  interval = "1s"
  logfile = "/var/log/telegraf/telegraf.log"
  flush_interval = "1s"
  metric_batch_size = 250
  metric_buffer_limit = 2500


[[inputs.cpu]]

[[inputs.mem]]

[[inputs.system]]

[[inputs.disk]]
  mount_points = ["/"]

[[inputs.processes]]

[[inputs.net]]
  fieldpass = [ "bytes_*" ]


[[inputs.ping]]
  ## Hosts to send ping packets to.
name_suffix = "_eth1"
  urls = ["46.19.33.172"]
  method = "exec"
  #count = 1
  #ping_interval = 1.0
  #timeout = 1.0
  #interface = "eth1"
  binary = "ping"
  arguments = ["-W", "0.250", "-c", "4", "-i", "0.25", "-I", "eth1", "-Q", "192", "-s", "20"]

[[inputs.ping]]
name_suffix = "_eth2"
  ## Hosts to send ping packets to.
  urls = ["46.19.33.172"]
  method = "native"
  count = 1
  ping_interval = 1.0
  timeout = 1.0
  interface = "eth2"
#  binary = "ping"
#  arguments = ["-W", "0.250", "-c", "4", "-i", "0.5", "-I", "eth2", "-Q", "192", "-s", "20"]



[[outputs.influxdb]]
  database = "telegraf"
  urls = [ "http://127.0.0.1:8086" ]
  username = "telegraf"
  password = "telegraf"
  timeout = "5s"

System info:

On both of these anyway:

Telegraf unknown (git: bugfix/6576 25a212c)
Telegraf unknown (git: master 58df6f6)

Steps to reproduce:

  1. Use one ping to isp interface with binary exec method
  2. Use one ping to isp interface with native method

Expected behavior:

tcpdump -nni eth1 icmp
and
tcpdump -nni eth2 icmp
should both show icmp activity?

Actual behavior:

Ping with native doesn't work with bind to interface.

Additional info:

The only output i get from telegraf.log is a huge load of lines of
"2019-11-09T01:50:04Z W! [agent] [inputs.ping] did not complete within its interval"

Which don't seem to be there when i just use exec for all of them.

@danielnelson danielnelson added this to the 1.12.6 milestone Nov 16, 2019
@danielnelson danielnelson added the bug unexpected problem or unintended behavior label Nov 16, 2019
@Marctraider
Copy link
Author

Marctraider commented Nov 20, 2019

This still isn't working for me.

2019-11-20T00:36:14Z W! [agent] [inputs.ping] did not complete within its interval
2019-11-20T00:36:15Z W! [agent] [inputs.ping] did not complete within its interval
2019-11-20T00:36:16Z W! [agent] [inputs.ping] did not complete within its interval
2019-11-20T00:36:17Z W! [agent] [inputs.ping] did not complete within its interval
2019-11-20T00:36:18Z W! [agent] [inputs.ping] did not complete within its interval
2019-11-20T00:36:19Z W! [agent] [inputs.ping] did not complete within its interval
2019-11-20T00:36:20Z W! [agent] [inputs.ping] did not complete within its interval

Already applied set cap_net_raw in systemctl and on binary itself. No icmp activity when looking at tcpdump.

[[inputs.ping]]
  ## Hosts to send ping packets to.
  #name_suffix = "_eth1"
  urls = ["1.1.1.1"]
  method = "native"
  count = 1
  ping_interval = 1.0
  timeout = 1.0
  interface = "eth1"
  #binary = "ping"
  #arguments = ["-i", "0.25", "-c", "4", "-I", "eth1"]

@danielnelson
Copy link
Contributor

Looking into this closer and it seems there is a difference in the regular ping command between giving the -I option an interface name and a ip address:

$ sudo strace ping -I bond0 1.1.1.1 2>&1 | grep 'bind\|connect\|socket'
socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP) = -1 EACCES (Permission denied)
socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) = 3
socket(AF_INET6, SOCK_DGRAM, IPPROTO_ICMPV6) = -1 EAFNOSUPPORT (Address family not supported by protocol)
socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(1025), sin_addr=inet_addr("1.1.1.1")}, 16) = 0
socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE) = 5
bind(5, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 0
^C
$ sudo strace ping -I 10.13.49.148 1.1.1.1 2>&1 | grep 'bind\|connect\|socket'
socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP) = -1 EACCES (Permission denied)
socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) = 3
socket(AF_INET6, SOCK_DGRAM, IPPROTO_ICMPV6) = -1 EAFNOSUPPORT (Address family not supported by protocol)
bind(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("10.13.49.148")}, 16) = 0

What we are doing now in 1.12.6 is the later with the IP address and it's not immediately clear to me how we can duplicate the interface name behavior with the golang.org/x/net/icmp package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
2 participants