Incorrect usage of `-w` for ping
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
charm-magpie |
Fix Committed
|
Undecided
|
Samuel Walladge |
Bug Description
In config.yaml:
ping_timeout:
default: 2
description: Timeout in seconds per ICMP request
type: int
It suggests the timeout is *per request*. However, if ping_tries is set like 10 for example, the actual command will be executed is `ping -c 10 -w 2`. And it fails always because ping will exit before sending 10 packets because of `-w` as documented:
> -w deadline
> Specify a timeout, in seconds, before ping exits regardless
> of how many packets have been sent or received.
$ ping -c 10 -w 2 192.168.1.1; echo "return value: $?"
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=5.48 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=4.35 ms
--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 4.353/4.
return value: 1
[src/lib/
ping_string = "ping -c {} -w {} {} {} > /dev/null 2>&1"\
I suppose the expected option here is `-W` (capital w).
> -W timeout
> Time to wait for a response, in seconds.
description: | updated |
> I suppose the expected option here is `-W` (capital w).
Either that, or the docs are incorrect? I guess it comes down to what behaviour do you want here?