Device Ping does not work when using BusyBox ping binary

Hello together,

after switching to another base image for our GenieACS Docker image, we noticed that the ping functionality does not work anymore because the ping API (e.g. /api/ping/ doesn’t return all values:

    "packetsTransmitted": 3,
    "packetsReceived": 3,
    "packetLoss": 0,
    "min": null,
    "avg": null,
    "max": null,
    "mdev": null

After some testing and looking at the relevant source code ( and testing at the CLI I noticed that the ping util from the busybox binary has other output than the standard iputils-ping linux util:

Busybox (v1.36.1):

/ # ping -w 1 -i 0.2 -c 3
PING ( 56 data bytes
64 bytes from seq=0 ttl=63 time=14.593 ms
64 bytes from seq=1 ttl=63 time=15.441 ms
64 bytes from seq=2 ttl=63 time=15.628 ms

--- ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 14.593/15.220/15.628 ms

iputils-ping (iputils 20221126):

/ # ping -w 1 -i 0.2 -c 3
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=63 time=14.6 ms
64 bytes from icmp_seq=2 ttl=63 time=13.6 ms
64 bytes from icmp_seq=3 ttl=63 time=14.5 ms

--- ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 401ms
rtt min/avg/max/mdev = 13.623/14.232/14.616/0.435 ms

Problem seems to be the last line where rtt is replaced by round-trip(?) and the mdev parameter missing This causes the RegEx to fail and therefore the output of the API call to be incomplete.

I could provide a pull request to include RegEx support for the busybox output but then the mdev parameter would still be unpopulated. Another option would be to advise users to install iputils-ping when using minimal distros or base images like alpine. Tested with node:18-alpine3.18.

Any suggestions?

I’ve looked at this a bit, and the issue is actually not round-trip vs rtt. mdev not being in the BB version is the issue.

If I modify parseRegExp1 for platform linux to add a single ? it works. Here is the updated regex:

/(\d+) packets transmitted, (\d+) .*received, ([\d.]+)% .*loss[^]*= ([\d.]+)\/([\d.]+)\/([\d.]+)\/?([\d.]+)/