OpenWrt Forum Archive

Topic: send notification when device is offline after specified time

The content of this topic has been archived on 3 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

This is more of a feature request check, hopefully in the right forum
Is there a way to install a package which notifies me via email if a device which should be always online, is offline after some defined time?
It would help me by not installing a distro on a pc and/or avoiding finding android apps

opkg update
opkg list | grep -i smtp

It's trivial to write a script to check for a condition of your choosing, and then to send an e-mail if that condition is met (or not met).

(Last edited by 600cc on 6 Apr 2018, 23:59)

if it is trivial, then I would complicate it a bit
I want to have a list of wi-fi devices, around 20, written in a file
the script should check every e.g. 20 seconds (via e.g. ping) if device is offline.
if a particular device is offline after given time (e.g. 8 hours, so after 3*60*8 failed attempts ) then send an email with device name
the condition with the email sending must be restarted only after 1st successful re-connection (e.g. via ping)

If anyone can implement/run/test such a script it would help me a lot
Any chance of requesting this feature somewhere?

(Last edited by purdelcristian1983 on 7 Apr 2018, 09:52)

Yes. On freelancer.com
For a fee.
I might bid :-)

(Last edited by augustus_meyer on 7 Apr 2018, 10:15)

It is rather simple, you can use conditional ping from my script:

#!/bin/sh
n=10
while sleep 50; do
        t=$(ping -c $n 8.8.8.8 | grep -o -E '\d+ packets r' | grep -o -E '\d+')
        if [ "$t" -eq 0 ]; then
                /etc/init.d/openvpn restart
        fi
done
augustus_meyer wrote:

Yes. On freelancer.com
For a fee.
I might bid :-)

Well everything has it's price but what I'm asking should be around 15 lines of codes
First of all this script is more of a redundancy and is not critical to have.
I asked here since openwrt should be open.
I need this for an instructable which is reusing android phone for running science by burning around 900kWh yearly which is not ... free on my end.
I could do it also in VBA or with automate, but I thought it might be possible directly with openwrt.
It should also take into account power outages or internet connection disruptions

purdelcristian1983 wrote:

Well everything has it's price but what I'm asking should be around 15 lines of codes

https://www.snopes.com/fact-check/know-where-man/



purdelcristian1983 wrote:

I asked here since openwrt should be open.

It is open, which means you can customise it as you see fit. It doesn't mean other people are obliged to do your work for you.

ulmwind has given you a script which you can adapt for your purposes. For free.

fair enough
I will do it myself then
P.S. Trotzdem, als ich habe gelernt, Deutschland ist eine Soziale Marktwirtschaft und nicht eine "Wilde" Marktwirtschaft smile

(Last edited by purdelcristian1983 on 7 Apr 2018, 17:00)

purdelcristian1983 wrote:

I will do it myself then

That's the spirit!

If you approach the forum with "I'm trying to do A, B, and C. I've tried X, Y, and Z, and this is the result. I wonder if D, E, or F might be causing the problem. Here are the relevant parts of the configuration and the relevant log files", then you'll get a much better response than if you start with "please do my thinking for me".

If you do get stuck, post your work and someone may be able to assist.

First of all, I was more interested if what I want was possible or not
Secondly, I was hoping if someone already did this and was "willing" to share it
Lastly, when I will have time, I will do it myself and post back the code smile

The discussion might have continued from here.