Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script to Ping Device, and Restart WIFI plug if ping fails. Can this be in a docker?

Featured Replies

I have a perhaps unusual network typology, pictured.  https://imgur.com/RXVgMrF

 

What happens is Router B often randomly looses connection (especially after long periods of no-use [eg. overnight]).  

 

To solve this problem all I have to do is reboot Router B, wait 2-3 minutes, and Router C will be connected again.  Sometimes Router C stops trying to get an address on the WAN port and I have to log in and tell it to connect.  

 

What I'm after is a script where, from Unraid (or Router C) I ping Router A every minute.  This might in-and-of-itself keep the connection up.  If the ping fails, kill power to the WIFI switch that powers Router B (I can handle that part), then ssh into Router C and tell it to connect (I can handle that too).  

 

What I'm not sure how to do is trigger an if statement for if the ping fails.  I also dont know how to make the script run on Unraid at system boot in the background.  Can I put something like this in a simple docker that starts at startup?  That way I can switch it on and off easily.  Is there a basic lightweight docker with command line network utilities only?

 

How would I make this? Any examples?

Edited by Mysticle31

Install User Scripts plugin from Community Apps. It can schedule an sh script.

 

You can do it on a docker but it would be more complicated.

  • Author

Perfect!  User Scripts.  That opens the door for me to do all kinds of things.  Thanks!

 

Any idea what the best way is to write a script to monitor output from ping?  Whats the best/easiest way. 

 

Other than having one script run the ping command continuously, printing the output to a file.  Then another script to read the contents of the file and look for "bad" "disconnected" whatever terms ping uses.  Then another script to delete the file every month or so.... complicated. 

24 minutes ago, Mysticle31 said:

Perfect!  User Scripts.  That opens the door for me to do all kinds of things.  Thanks!

 

Any idea what the best way is to write a script to monitor output from ping?  Whats the best/easiest way. 

 

Other than having one script run the ping command continuously, printing the output to a file.  Then another script to read the contents of the file and look for "bad" "disconnected" whatever terms ping uses.  Then another script to delete the file every month or so.... complicated. 

Can’t you simply monitor the exit status of the ping command?    As I understand it 0 means success, anything else means failure.

I did something like this years ago, back then I had an unstable fiber modem, which just stopped passing anything through. To restart that, I wrote some code in arduino, and flashed it to a Sonoff. It would then try to access google.com, and if it had failed connecting for a few minutes, it would kill power to the modem, wait 15 seconds, then turn it back on. After that it would give it 5 minutes to start up and get connection, if it didnt, it would be power cycled again.

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.