Is there a way to tell ping to show its usual termination statistics without stopping the execution (without having to stop the program, thus losing the accumulated data.) In linux, pressing ctrl+|
works but it is not working in LEDE/OpenWRT. kill -SIGQUIT [ping pid]
also have no effect
you could try mtr:
opkg update : opkg install mtr
not exactly ping, but for many diagnostics even better. mtr will continuously update its output...
# while true ; do ping -c 5 example.com ; echo ; sleep 5 ; done
Thanks , I didn't know MTR existed.
I just tried it , a very useful tool.
Thank you mbo2o for the reply. I don't know why I haven't thought about that.lol. This is not perfect because the statistics is not cumulative but this is the closest possible solution without installing any package, I think. And I also didn't know that mtr existed for OpenWrt. Thanks moeller0.
I actually want to run ping continuously and monitor the link. My ISP doesn't approve any report other than the device which is directly connected to the ISP cable. So, I can't use ping monitoring software on my computer. I know that luci-statistics have ping mod but collectd puts some load on my router and it has low specification. Thus I am looking for an alternative. Till now, I am just running ping and storing the output with the date-time added in a file (usb flash). Any other alternative would be appreciated.
I need something that will store the statistics. ie; the time when ping timed out and the time when the connection restored.
If you've got an open USB port, the way that I'd approach it would be to add a drive there for your logs (you can redirect the kernel logs there too) that mounts at boot time. I'd run two processes supervised by procd
, one that writes the time to the ping log, the other that runs ping itself. Then use newsyslog
to rotate and compress the logs Something like:
Edit: Timestamp every minute, five minutes, whatever, from cron
would be easier than with procd
/bin/date +"%s %Y-%m-%d %H:%M:%S" >> /path/to/ping.log
Edit: Run ping
continuously, supervised by procd
/bin/ping target.example.com >> /path/to/ping.log
and then post-process using your choice of scripting languages or spreadsheet programs for either graphical or statistical output.
There's the odd chance that the two will "collide" when writing, but it's not something that I've run into when doing this kind of thing.
A more robust approach that would timestamp each line would be to run the output of ping
through xargs
and then logger
. xargs
can be pretty challenging to get it to do what you want, especially when you have a variable number of "words" in a line.
to install the real ping binary (opkg update ; opkg install iputils-ping) and use the -D option:
from man ping:
-D Print timestamp (unix time + microseconds as in gettimeofday) before each line.
I have a hunch though that this will not work for the OP as he seems tight on space...
Great insight in -D
for the iputils-ping
package on OpenWRT!
(On most of the systems I work with, that flag is "set do not fragment bit")
aahh...thanks. I didn't know about this full featured ping utility too. Now I don't have to manually prepend the time. bdw, I am not tight on storage. I have plenty of free storage but my device has only 64MB RAM and the CPU is also not powerful. I installed luci statistics and force removed all collectd mod (eg: network, iwinfo, interface, wireless, cpu, memory etc) except ping. Now it is not consuming too much memory/cpu.
Moreover, the iputils-ping supports ctrl+|
It prints statistics upto that time.
while date ; do ping -c 5 example.com | grep round-trip ; sleep 60 ; done
You can remove or modify the grep to your liking
If your just doing this for ISP reporting, not running it continuously shouldn't be an issue. A short ping test at regular intervals will discover any major problems.