Hi, Mikael,

I've added the simple toggles at the top of the script to control remediation 
actions.
The script will always notify, but the restart weewx and reboot host actions 
are completely optional and controlled simply by the variables at the top of 
the script.

If both restart weewx and reboot host actions are enabled, these become nested 
in that first the restart weewx will be tried one time and if after 
watchdogsecs the station is still not reporting, then the host reboot will 
occur.  You can enable one or the other or both.

I also added logic to check if the host was rebooted within 2x watchdog secs to 
avoid reboot loops.   I strongly recommend not lowering the watchdogsecs below 
600 (10 minutes).

It's important to note that my approach isn't actually checking whether the 
weewx process is running, rather, the loss of communications checking is based 
on whether weewx has written any records to the database lately. 

You'll find the update over here:

https://github.com/UberEclectic/weewx/tree/watchdog/examples/watchdog

BTW, if you use my script don't run another kind of weewx restarter script, or 
they will step on each other.  (Or at least be sure to disable the weewx 
restart toggle in mine).

Regards,
Leon
--
Leon Shaner :: Dearborn, Michigan (iPad Pro)

> On May 1, 2019, at 2:24 PM, pliggen...@gmail.com wrote:
> 
> Hi,
> 
> I now have this script running. 
> Indeed this shouldn't be necessary but I've had both issues (Weewx crash and 
> USB issue) so I think these scripts are nice to have in case something goes 
> wrong until these issue are ironed out. Of course we should provide TF with 
> logs from these events.
> 
> I still have commented out the settings that initiate a reboot, so I will 
> have to do that manually in that case, for now.
> So it's good to have those scripts sending email at errors.
> 
> Yes it would be great to have these functions in the same script, with 
> toggle's, so I would appreciate it. Lets see if there are someone else that 
> would like it. 
> 
> Well, thank you so far for all help! Learning all the time now :)
> 
> BR Mikael
> 
> 
> 
> 
> 
>> Den onsdag 1 maj 2019 kl. 16:26:33 UTC+2 skrev Leon Shaner:
>> Hi, Mikael,
>> 
>> My watchdog script could certainly be "complimentary" to Constantine's 
>> script, and with minor modifications could potentially replace it.   IIRC, 
>> isn't mine at least the third script recently mentioned on the alias to 
>> address nearly the same issues?
>> 
>> For sure these scripts shouldn't be necessary, but things happen, and bugs 
>> that can be fixed may eventually be fixed, but in the mean-time, I'd rather 
>> have a script notify / remediate / workaround issues than keep randomly 
>> discovering that my station isn't reporting only hours after it "went 
>> offline."   :-/
>> 
>> So, anyway, in my weewx_watchdog script I am merely sending an e-mail 
>> notification when the station hasn't reported, but there is an example 
>> included (commented out) that initiates a reboot, which is the only remedy I 
>> have found for when my WMR300 stops communicating on my RPI.
>> 
>> Instead of the "shutdown -r now" it would be very easy to instead use 
>> "systemctl status weewx" to check if the service is running and then 
>> "systemctl start weewx" to start it (or "systemctl restart weewx").
>> 
>> With a little more work, I could do a series of remediation steps, like 
>> first attempting to restart weewx, then IFF the station still is not 
>> reporting, do the reboot the next time.   I didn't bother, because never 
>> once ever did a simple restart of weewx fix the USB issues with my WMR300 on 
>> RPI.   Also, I didn't bother to check if weewx was running, because my weewx 
>> has never actually stopped running.  It's always the USB issue at fault in 
>> my case.  :-/
>> 
>> If there is interest I could add a weewx restart remediation and even put 
>> some simple toggle's at the top to control which remediation steps are 
>> desired, such as restart_weewx vs. reboot_host, and maybe even do the logic 
>> to first try one and then the other if both are enabled.   Could put a 
>> toggle for whether to do the wunderfixer steps, too.   I'm going to write a 
>> separate post about that in a minute.  ;-)
>> 
>> Incidentally, I had to move the script.  It's in its own branch now:
>> 
>> https://github.com/UberEclectic/weewx/tree/watchdog/examples/watchdog
>> 
>> Regards,
>> Leon
>> --
>> Leon Shaner :: Dearborn, Michigan (iPad Pro)
>> 
>>> On May 1, 2019, at 4:13 AM, plig...@gmail.com wrote:
>>> 
>>> Hi Leon,
>>> 
>>> could this be used as a complement to Constantine Samaklis script you 
>>> helped me with yesterday? 
>>> Sometimes the wh1080 freezes USB-connection to my raspberry pi but the 
>>> weewx service is still running so Constantines script wont have any effect 
>>> in this case?
>>> I think this issue with whxxxx is well known.
>>> 
>>> BR Mikael
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "weewx-user" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to weewx...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to weewx-user+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to