Monitoring Client Connection

I've done some searching already and I'm not really coming up with anything. I would like to get an email notification when a specific client goes offline. It is connected through ethernet and ideally should always be online but for whatever reason goes offline every week or two.

I'm trying to diagnose and fix whatever is causing it to go offline but I think that starts with figuring out when it goes offline.


Since the client is connected via Ethernet, you need to be more specific about what you mean by "offline".

If the outage is between the router and the client, you could use the watchcat package.
The newer version has an option to run a script if a ping to a specific host fails.

If the client only loses access to the Internet for some reason, it would be more complicated.


Since you need to investigate the system journal on the client anyway, it is logical to create a scheduled task checking connectivity and logging its status directly on the client.


The client is actually connected directly to a switch, then to eth1 on the router (rpi4). Does that affect my ability to monitor that client?

Again, where exactly is the problem?
Between the client and the router or the client and the Internet?
When the client goes "offline" can you ping it from the router?
How exactly do you restore the connectivity - restarting the client, the switch or the router?
If it's all about finding out when this happens, follow the vgaetera's advice and


The client freezes and becomes unavailable. When I hook a monitor to it, the monitor doesn't show anything either. I cannot ping it from the router when the client goes offline. I restore connectivity by doing a hard restart of the client. Client is basically a bitcoin node running on raspberry pi 4. The problem isn't with the switch, the router or the modem.

I need an alert when the client goes offline or becomes unavailable so I know there is a problem. I don't realize there is a problem until days or maybe a week after the problem started. I'm sure there is information in the logs about when things started having problems, but if the client freezes or becomes unstable, logging may not work either.

Install the msmtp package and create a google app password in order to use gmail as a relay host .

opkg update; opkg install msmtp


# Gmail
account        gmail
port           465
auth           on
tls            on
tls_starttls   off
from           <user>
user           <username>
password       <16char_app_pass>

account default : gmail

syslog LOG_MAIL

Modify the script variables and execution period according to your needs.

cat << "EOF" > /etc/

IP=  # Host IP address
email_addr="" # email address to send the notification to

if ! ping -c 5 -W 1 $IP >/dev/null; then
    [ -f "$FAILURE" ] && exit 0
    msg="Host does not respond to ping on $(date)"
    echo -e "To:$email_addr \nSubject:Notification\n\n$msg" | msmtp "$email_addr"
    touch "$FAILURE"
    [ -f "$FAILURE" ] || exit 0
    rm -f "$FAILURE"

exit 0

chmod 755 /etc/

cat << "EOF" >> /etc/crontabs/root
*/5 * * * * /etc/
uci set system.@system[0].cronloglevel="9"
uci commit system
/etc/init.d/cron restart

wow, that's very thorough. Thank you so much. I will get at it this afternoon. That's awesome, I really appreciate it.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.