I know this threads a little old, but thanks for the script. I just implemented it now.
It appears that after it detects WeeWx is down, it restarts it, but then leaves the weewxNotRunning.txt file out there with the number of retries in it. So, say it has to restart WeeWx, successfully does so, and a week later does it again, etc. After the 3rd week, because it counts as a "retry" and the file's left out there, it will stop. So, in other words, you have to know, if you get the email, make sure you go out there and delete the weewxNotRunning.txt manually to reset the counter, or it'll stop working after the 3rd time it happens. I'm not missing anything, right? On Friday, September 13, 2013 at 7:44:28 PM UTC-4, Constantine Samaklis wrote: > > I thought I would give something back to the group since I have gotten > good help to my questions. I have created a Python utility script that can > be ran periodically (cron?) to check if weewx is running and if it is not, > it will send out an email with a number of lines from the end of the log > (/var/log/messages, or whatever log you want) that would show the error > that weewx encountered. The script will try to restart weex a number of pre > configurable times, in case the error was a fluke rather than a fatal one. > > The script will stop trying to send messages after it has reached the > indicated *restarts* times in the configuration times, and you will need > to delete the *flagFile* that has been created. (or write a 0 in it). The > script has a configurable log rotation, where you can indicate the log > rotation interval (in days) and the days of logs to keep. > > *logOutput* is the temporary tail of the messages log (or could be the > syslog or whatever you specify) that will be emailed as an attachment if > weewx is found not to be running. > > I hope everyone finds this somewhat useful. If you are somewhat paranoid > about your weather station being up 24/7 like me then you probably will. :-) > > Questions and comments are welcome. > > > #configuration file for checking routine > [mail] > [email protected] <javascript:> > [email protected] <javascript:> > msgSubj=weewx process is not running > body=weewx process is not running. Please check the attached log and > address the issue > [email protected] <javascript:> > password=yourPwd > smtpServer=smtp.gmail.com:587 > > [logging] > logDir=/home/user/scripts > logFile=checkWeewx.log > logOutput=tail.log > linesToTail=200 > logToTail=/var/log/messages > logRotationDayInterval=1 > logDaysToKeep=5 > > [weewx] > #how many times to try and restart the weewx process > restarts=3 > flagLogDir=/home/user/scripts > flagFile=weewxNotRunning.txt > startCommand=sudo /etc/init.d/weewx start > > You can launch the script by typing: Python ./checkWeewx.py > /pathToConfigFile/checkWeewx.config > > The configuration format: > > #configuration file for checking routine > [mail] > [email protected] <javascript:> > [email protected] <javascript:> > msgSubj=weewx process is not running > body=weewx process is not running. Please check the attached log and > address the issue > [email protected] <javascript:> > password=yourPwd > smtpServer=smtp.gmail.com:587 > > [logging] > logDir=/home/user/scripts > logFile=checkWeewx.log > logOutput=tail.log > linesToTail=200 > logToTail=/var/log/messages > logRotationDayInterval=1 > logDaysToKeep=5 > > [weewx] > #how many times to try and restart the weewx process > restarts=3 > flagLogDir=/home/user/scripts > flagFile=weewxNotRunning.txt > startCommand=sudo /etc/init.d/weewx start > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/3e10898a-5ec9-4ee1-b4ea-aceb85e8602ao%40googlegroups.com.
