Mysticle31 Posted June 7, 2019 Share Posted June 7, 2019 (edited) 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 June 7, 2019 by Mysticle31 Quote Link to comment
testdasi Posted June 7, 2019 Share Posted June 7, 2019 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. Quote Link to comment
Mysticle31 Posted June 8, 2019 Author Share Posted June 8, 2019 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. Quote Link to comment
itimpi Posted June 8, 2019 Share Posted June 8, 2019 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. Quote Link to comment
mikeydk Posted June 9, 2019 Share Posted June 9, 2019 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.