So what does everyone do for a watchdog process? If I have an Open WRT process, or script, on the Vera and I want to routinely check its status and attempt a reload if its down, what does everyone use?
OK. So, I was able to use a USB stick to both log locally and perform local backups. Tweaked a bunch of the concepts in @rigpapa’s scripts to use DNS and NTP locally. Removed provisioning scripts and other rubbish like the network monitor. I dont want my Vera randomly rebooting and tearing down the Internet stack if there is a lapse in ISP connectivity — you still want to locally automate your home, right?
Everything completed, I had one issue where the ‘/etc/inid.d/cmh-ra’ startup script starts the ‘/bin/sh /usr/bin/cmh-ra-daemon.sh’ process, but with a prolonged network outage (just simulated by disconnecting the ethernet cable), the process would die with the message ‘ERROR: Failed to get cmh-ra port, reason: , MiOSRestApi exit code: 6’. Of course, it just wouldnt restart again unless the startup script was manually invoked. So, I created a watchdog script!
#!/bin/sh source /etc/init.d/cmh-ra init_script log "[WATCHDOG] Starting ..." cmh_ra_daemon_pids=$(get_cmh_ra_daemon_pids) ssh_pids=$(get_ssh_pids) if [ -z "$cmh_ra_daemon_pids" ] && [ -z "$ssh_pids" ]; then log_WARNING "[WATCHDOG] Process IDs for 'cmh_ra_daemon' and/or 'ssh' not found!" check_localnet log "[WATCHDOG] Restarting 'cmh-ra' process ..." restart sleep 40 cmh_ra_daemon_pids=$(get_cmh_ra_daemon_pids) ssh_pids=$(get_ssh_pids) if [ -z "$cmh_ra_daemon_pids" ] && [ -z "$ssh_pids" ]; then log_WARNING "[WATCHDOG] Restart of 'cmh-ra' unsuccessful, will try later." else log "[WATCHDOG] Restart of 'cmh-ra' successful, cmh_ra_daemon [$cmh_ra_daemon_pids] ssh [$ssh_pids]" fi else log "[WATCHDOG] cmh_ra_daemon [$cmh_ra_daemon_pids] ssh [$ssh_pids] are running!" fi log "[WATCHDOG] Ending ..."
Added the following to crontab to run every 5 minutes…
*/5 * * * * /usr/bin/cmh-ra_watchdog.sh
Works quite well
Hope someone else will find this useful perhaps.