[Weather] owwnogui on an nslug problems
Steinar Midtskogen
steinar at latinitas.org
Tue Oct 3 12:53:37 EDT 2006
[Ted Frohling]
> Would you mind sending me your restart script?
It's not big, so I'll post it here. If you want to use it, you need
to change it as this is specialised for my setup. I have two instances
of owwnogui running, one logs to /home/logs/c/log.c and the other logs
to /home/logs/b/log.b.
The script does a few things: First, it checks whether the last log
entry ($1 is the timestamp) of log.c is older than 21 minutes. Then
it checks whether the pressure ($3 in log.b) is below 900 hPa or above
1100 hPa, and finally whether the three last pressure entries (hPa
with three decimal places) are all equal. If any of these are true,
it will restart by running /etc/init.d/oww restart (which will restart
both instances of owwnogui).
log.c contains the log of my outdoor sensors, which sometimes fail due
to moisture. log.b is the log of my indoor sensors, which never fail
except for the pressure sensor.
I run this script as a cron job every 11th minute.
It assumes that /bin/sh is bash.
#!/bin/sh
if [ $1 ]; then
log=$1
else
log=c/log.c
fi
log2=b/log.b
cd /home/logs
TS=$(tail -n 1 $log | awk '{print $1}')
ok=$(tail -n 4 $log2 | awk '{print $3}' | xargs echo | awk '{if ($4 < 900 || $4
> 1100 || ($4 == $3 && $4 == $2 && $4 == $1)) print 0; else print 1;}')
ok2=$(echo $TS | TZ=UTC awk '{if ($1 < strftime("%Y%m%d%H%M%S", systime() - 21*
60)) print 0; else print 1}')
echo TS=$TS ok=$ok ok2=$ok2 > /tmp/test
if [ $ok -eq 0 ]; then
tail -n 4 $log | awk '{print $3}' | xargs echo
/etc/init.d/oww restart
elif [ $ok2 -eq 0 ]; then
tail -n 1 $log
/etc/init.d/oww restart
fi
--
Steinar
More information about the Weather
mailing list