Mini Ping Watchdog

Want to share your OpenWrt / Gargoyle knowledge? Implemented a new feature? Let us know here.

Moderator: Moderators

Zander
Posts: 4
Joined: Sun Oct 16, 2016 8:52 am

Mini Ping Watchdog

Post by Zander »

Hi,

I've just been looking for something to regularly 'ping' from my TP-Link WR841N v11 to try and keep my TP-Link AV500 PowerLines from going sleep at night, losing connection, and not waking up again.

Ping Watchdog sounded great, but seems my TP-Link doesn't have enough space to install it :( I'm a bit surprised a little ping module comes to 11MB?

Anyway, for a bit of fun I created a quick 'mini' Ping Watchdog script and log the results. In case its of use to anyone, I thought to copy it here, might save someone a few minutes :) The slightly strange logfile truncation is just to keep tail -f working most of the time.

Log output just looks like

Code: Select all

root@TP-LINK:~# tail -f /var/log/192.168.0.1.pings
2017-01-16 15:46:00 OK 12.995
2017-01-16 15:47:00 OK 13.718
2017-01-16 15:48:01 OK 9.242
2017-01-16 15:49:01 OK 9.842
2017-01-16 15:50:01 OK 3.914
If anyone has any suggestions on where to look at Ping Watchdog, I may see if I can make it suitable for smaller devices.

Cheers,

Alex


Install with crontab -e

Code: Select all

* * * * * /root/ping.sh
Edit /root/ping.sh

Code: Select all

#!/bin/sh

IP=192.168.0.1    # address to ping
LOGFILE=/var/log/$IP.pings

LOGLENMAX=10000  # Maximim number of lines in logfile
LOGLENTRIM=9000  # Size to trim logfile back down to when max length reached

/bin/ping -W 1 -c 1 $IP | awk '
  BEGIN {
    FS = "[ \t/]+"; logdate = strftime("%Y-%m-%d %H:%M:%S");
  }

  /packets/ {
    if ($4==1) { result = "OK" } else { result = "FAIL" }
  }

  /round-trip/ { roundtrip=$6 }

  END { print logdate " " result " " roundtrip }
' >> $LOGFILE

LOGLEN=`wc -l $LOGFILE | cut -d ' ' -f 1`

if [ $LOGLEN -gt $LOGLENMAX ]
then
  tail -$LOGLENTRIM $LOGFILE >> $LOGFILE.new
  mv $LOGFILE.new $LOGFILE
fi
Last edited by Zander on Tue Jan 17, 2017 9:01 am, edited 1 time in total.

ispyisail
Moderator
Posts: 5180
Joined: Mon Apr 06, 2009 3:15 am
Location: New Zealand

Re: Mini Ping Watchdog

Post by ispyisail »

Thanks

Lantis
Moderator
Posts: 6735
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: Mini Ping Watchdog

Post by Lantis »

Ping watchdog is already small.
Installing plugins is disabled on your device because of small flash size. Adding 10.99MB to the plugin size is because of a missing library I think
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

Zander
Posts: 4
Joined: Sun Oct 16, 2016 8:52 am

Re: Mini Ping Watchdog

Post by Zander »

Hi guys,

Thanks for your replies. I have had a bit of a look into Ping Watchdog's source, and it does indeed look elegantly small.

https://github.com/ericpaulbishop/gargo ... g-watchdog

My Gargoyle interface suggests I can install some of the smaller, 'theme' plugins, though I've not tried yet to see if they're 'disabled' somehow.

Looking at the Watchdog code, I can't see anything else that would be needed to install as a dependency - it all looks pretty much like the rest of Gargoyle. So I wonder if something is a little misconfigured somewhere regarding dependencies?

e.g. this all looks reasonable, just depending on gargoyle and libc, with install size of 3242 bytes.

Code: Select all

root@TP-LINK:/tmp/opkg-lists# gpkg info 'plugin-gargoyle-ping-watchdog'
Package: plugin-gargoyle-ping-watchdog
Version: 20131030
Install-Destination: Not Installed
SHA256sum: ffe0b8a11f7142ca1beb990d7bbab68f7101257f690007bb3e9c03b0a4135aff
Source: package/plugin-gargoyle-ping-watchdog
Size: 4191
Maintainer: Cezary Jackiewicz <cezary@eko.one.pl>
Installed-Size: 3242
MD5Sum: 07dab671459dfc9f0204c3a07f31122d
Description: Ping Watchdog
Architecture: all
Source-ID: gargoyle
Section: admin
Filename: plugin-gargoyle-ping-watchdog_20131030_all.ipk
Status: unknown ok not-installed
Depends: libc, gargoyle
But then running this implies the install may need a lot more for some reason? Perhaps more than really required?

Code: Select all

root@TP-LINK:/tmp/opkg-lists# gpkg info -v 'Required-Size,Required-Depends,Will-Fit' plugin-gargoyle-ping-watchdog
Package: plugin-gargoyle-ping-watchdog
Version: 20131030
Required-Depends: ip, tc, libjson-c, kmod-ipt-bandwidth, libxtables, uhttpd, gargoyle-firewall-util, kmod-ebtables, kmod-ipt-iprange, libpolarssl, kmod-ipt-webmon, ebtables, kmod-ipt-weburl, kmod-lib-crc-ccitt, kmod-ipt-nat-extra, iptables-mod-timerange, kmod-ipt-ipopt, kmod-lib-textsearch, kmod-sched-core, iptables-mod-filter, uci, wol, kmod-slhc, kmod-nf-ipt, ddns-gargoyle, kmod-nf-nat, libuci, kmod-bridge, libiptbwctl, iptables-mod-conntrack-extra, iptables-mod-imq, uhttpd-mod-tls, libblobmsg-json, gargoyle, iptables-mod-ipopt, iptables, kmod-nf-conntrack, qos-gargoyle, libnl-tiny, libip4tc, kmod-ipt-timerange, libip6tc, kmod-ipt-conntrack, kmod-nf-nathelper-extra, kmod-ipt-filter, kmod-pppox, kmod-ipt-extra, ewget, bwmon-gargoyle, kmod-pptp, kmod-ipt-core, libericstools, iptables-mod-bandwidth, libjson-script, webmon-gargoyle, iptables-mod-extra, iptables-mod-iprange, iptables-mod-webmon, kmod-iptunnel, iptables-mod-weburl, libc, libustream-polarssl, kmod-gre, iptables-mod-nat-extra, kmod-llc, kmod-ipt-imq, haserl-i18n, kmod-ppp, kmod-ipt-conntrack-extra, kmod-ipt-nat, kmod-stp, kmod-tun, libubox, libbbtargz, gpkg, kmod-sched, kernel (= 3.18.29-1-2cd8e0d6c90de5a5c905cc3193f1fc62), kmod-nf-nathelper
Will-Fit: false
Required-Size: 11862315
I've tried digging into the 'gpkg' code and a bit of hacking, but the data structure etc in load.c's load_package_data is a bit opaque to me without some debug tools etc.

In conclusion, I just wonder if Ping Watchdog's dependencies are a bit 'over the top' and that they might be reduced so as to be installable on smaller devices, and possibly even some other plugins might then work too?

Cheers!

Alex

Lantis
Moderator
Posts: 6735
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: Mini Ping Watchdog

Post by Lantis »

Probably not sorry.
This was done in a move to try and keep 4mb routers alive as long as possible.
Even now they are still unstable after a period of use (flash starts to fill).

You can manually install the plugin just by creating the files yourself
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

Zander
Posts: 4
Joined: Sun Oct 16, 2016 8:52 am

Re: Mini Ping Watchdog

Post by Zander »

Thanks for replying :) Yes, that might explain why its a little unstable sometimes .. though it was similarly unstable under TP-Links' firmware, which is why I changed to Gargoyle. Seems particularly the wifi will die on occasion.

Anyway, thanks again - and I'll try manually copying the ping watchdog files over.

julianocs
Posts: 5
Joined: Wed Oct 01, 2014 6:18 am

Re: Mini Ping Watchdog

Post by julianocs »

Hello @Zander

I actually use this script to check if my network is up and restart if necessary.
My main router is 192.168.1.1 .
I have 9 other routers connected to him using Wireless WDS Bridge.

Code: Select all

#!/bin/sh

sleep 90

tries=0
while [[ $tries -lt 10 ]]
do
	if /bin/ping -c 1 192.168.1.1 >/dev/null
	then
		exit 0
	fi
	tries=$((tries+1))
done
wifi
sleep 60


tries=0
while [[ $tries -lt 10 ]]
do
	if /bin/ping -c 1 192.168.1.1 >/dev/null
	then
		exit 0
	fi
	tries=$((tries+1))
done
/etc/init.d/network restart
sleep 60


tries=0
while [[ $tries -lt 10 ]]
do
	if /bin/ping -c 1 192.168.1.1 >/dev/null
	then
		exit 0
	fi
	if /bin/ping -c 1 8.8.8.8 >/dev/null
	then
		exit 0
	fi	
	tries=$((tries+1))
done
reboot

Usage:

1)Create a text file , paste this code and save using .sh extension. Ex: lan_watchdog.sh
2)Upload into /root folder using WinSCP , right click , and set the file attribute do executable (+x).
3)Create a cronjob to run the file that you created as you want. Ex: */10 * * * * /root/lan-watchdog.sh (In this case, it runs every 10 minutes).

Hope this helps.
Sorry for bad english.
Juliano

User avatar
i3laze
Posts: 10
Joined: Mon Jun 26, 2017 3:41 pm
Location: Moscow

Re: Mini Ping Watchdog

Post by i3laze »

Lantis wrote:You can manually install the plugin just by creating the files yourself
In case you miss the original Ping Watchdog plugin on your 4MB router (as I do)..

I've modified http://www.gargoyle-router.com/packages ... 30_all.ipk (.tar.gz actually) and wiped all these fake dependencies from 'control' file.

You're free to install the package via SSH:
wget http://91.218.85.102/files/plugin-gargo ... 30_all.ipk
opkg install plugin-gargoyle-ping-watchdog_20131030_all.ipk
rm plugin-gargoyle-ping-watchdog_20131030_all.ipk

Unchained System Logs plugin too:
wget http://91.218.85.102/files/plugin-gargo ... -4_all.ipk
opkg install plugin-gargoyle-logread_20120724-4_all.ipk
rm plugin-gargoyle-logread_20120724-4_all.ipk


http://i64.tinypic.com/2vmgep1.png
Image

ciceropc
Posts: 3
Joined: Tue Jan 06, 2015 4:47 am

Re: Mini Ping Watchdog

Post by ciceropc »

i3laze wrote:
Lantis wrote:You can manually install the plugin just by creating the files yourself
In case you miss the original Ping Watchdog plugin on your 4MB router (as I do)..

I've modified http://www.gargoyle-router.com/packages ... 30_all.ipk (.tar.gz actually) and wiped all these fake dependencies from 'control' file.

You're free to install the package via SSH:
wget http://91.218.85.102/files/plugin-gargo ... 30_all.ipk
opkg install plugin-gargoyle-ping-watchdog_20131030_all.ipk
rm plugin-gargoyle-ping-watchdog_20131030_all.ipk

Unchained System Logs plugin too:
wget http://91.218.85.102/files/plugin-gargo ... -4_all.ipk
opkg install plugin-gargoyle-logread_20120724-4_all.ipk
rm plugin-gargoyle-logread_20120724-4_all.ipk


http://i64.tinypic.com/2vmgep1.png
Image

Hi! Could you please upload it again?

User avatar
i3laze
Posts: 10
Joined: Mon Jun 26, 2017 3:41 pm
Location: Moscow

Re: Mini Ping Watchdog

Post by i3laze »

Ok, will do tomorrow.

Actually you can fix a package by yourself.
Grab a 7z-archiver and remove a dependency.

Post Reply