-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix ping crash on Enimga2 linux distribution (mipsle) #3877
Conversation
@@ -171,14 +171,24 @@ func (p *Ping) args(url string) []string { | |||
// Build the ping command args based on toml config | |||
args := []string{"-c", strconv.Itoa(p.Count), "-n", "-s", "16"} | |||
if p.PingInterval > 0 { | |||
args = append(args, "-i", strconv.FormatFloat(p.PingInterval, 'f', 1, 64)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just change this to use the -1 precision:
args = append(args, "-i", strconv.FormatFloat(p.PingInterval, 'f', -1, 64))
It still will require users to specify an even value, but I think it is better than switching on arch.
plugins/inputs/ping/ping.go
Outdated
} | ||
if p.Timeout > 0 { | ||
switch runtime.GOOS { | ||
case "darwin": | ||
args = append(args, "-W", strconv.FormatFloat(p.Timeout*1000, 'f', 1, 64)) | ||
case "linux": | ||
args = append(args, "-W", strconv.FormatFloat(p.Timeout, 'f', 1, 64)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use -1 precision here too
plugins/inputs/ping/ping_test.go
Outdated
@@ -41,6 +41,18 @@ PING www.google.com (216.58.218.164) 56(84) bytes of data. | |||
rtt min/avg/max/mdev = 35.225/43.628/51.806/5.325 ms | |||
` | |||
|
|||
var enigma2PingOutput = ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment here with the output of ping -V
(or the equivalent version option).
Honestly it is a problem because of BusyBox and I don't think this is a right way of fixing it. I make a condition based on mipsle compilation (GOARCH) but I think it should be done different. |
This is how ping command look like on BusyBox BusyBox v1.24.1 (2017-02-28 03:28:13 CET) multi-call binary. Usage: ping [OPTIONS] HOST Send ICMP ECHO_REQUEST packets to network hosts
|
Maybe add new parameter, something like 'target= busybox' ? |
I like the idea to introduce a variable where you can pick a dialect, we did something similar for procstat plugin recently to support Windows. On ping, we also want to support a pure Go implementation in addition to the current method of exec'ing another command. I think all of that would be a moderate amount of work though, as it's probably best to just start from scratch on the implementation. |
plugins/inputs/ping/ping.go
Outdated
args = append(args, "-i", strconv.FormatFloat(p.PingInterval, 'f', 1, 64)) | ||
switch runtime.GOARCH { | ||
case "mipsle": | ||
// -i argument not supported in busybox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not add anything for this then, if the ping_interval is set to "0s" it will not add this option.
Can you take a look at the failed testcase? |
Ping is already fixed but tests crash somewhere on statsd |
plugins/inputs/ping/ping.go
Outdated
@@ -268,7 +271,7 @@ func init() { | |||
inputs.Add("ping", func() telegraf.Input { | |||
return &Ping{ | |||
pingHost: hostPinger, | |||
PingInterval: 1.0, | |||
PingInterval: 0.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the delay merging, should/can we change this back to 1.0?
Required for all PRs:
Ping command crash on enimga2 stb ( linux mipsle ).