[Piuparts-commits] rev 718 - in piatti/home: piupartsm/bin piupartss/bin
Holger Levsen
holger at alioth.debian.org
Wed Nov 10 17:26:50 UTC 2010
Author: holger
Date: 2010-11-10 17:26:41 +0000 (Wed, 10 Nov 2010)
New Revision: 718
Modified:
piatti/home/piupartsm/bin/detect_slave_problems
piatti/home/piupartss/bin/slave_run
Log:
refactor screenlog handling
Modified: piatti/home/piupartsm/bin/detect_slave_problems
===================================================================
--- piatti/home/piupartsm/bin/detect_slave_problems 2010-11-07 16:13:53 UTC (rev 717)
+++ piatti/home/piupartsm/bin/detect_slave_problems 2010-11-10 17:26:41 UTC (rev 718)
@@ -48,34 +48,27 @@
chown piupartsm.piuparts $MONITORDIR
chmod 775 $MONITORDIR
-# ~piupartss/bin/slave_run deletes screenlog* and touches screenlog.new for detecting piuparts-slave has just been started
-mv screenlog.new screenlog.old 2>/dev/null
-cp $SCREENLOG screenlog.new
+stamptime=$(/usr/bin/stat -c %Z $SCREENLOG)
+unixtime=$(date +%s)
+difference=$(( $unixtime - $stamptime ))
-# dont complain if just started
-if [ -f screenlog.old ] && [ -s screenlog.old ] ; then
- diff screenlog.old screenlog.new >/dev/null 2>&1 && {
- if [ ! -f $LOCKFILE ] ; then
- {
- echo "Either piuparts-slave hangs or is not running at all or wasn't started with ~piupartss/bin/slave_run - please investigate and take appropriate measures!"
- echo
- tail screenlog.new
- } | mail -s "problem with piuparts-slave detected" piupartsm
- touch $LOCKFILE
- chmod 660 $LOCKFILE
- fi
- }
+# dont complain, if already complained and screenlog is younger than 15 min (=900 sec)
+if [ ! -f $LOCKFILE ] || [ ${difference} -ge 900 ] ; then
+ {
+ echo "Either piuparts-slave hangs or is not running at all or wasn't started with ~piupartss/bin/slave_run - please investigate and take appropriate measures!"
+ echo
+ tail $SCREENLOG
+ } | mail -s "problem with piuparts-slave detected" piupartsm
+ touch $LOCKFILE
+ chmod 660 $LOCKFILE
fi
+
#
-# send screenlog daily no matter what, but only once a day :)
+# cleanup $LOCKFILE once a day to remind daily
#
-# disabled, report should be enough to confirm the slave is still running...
-exit 0
HOUR=`date +%H`
if [ "$HOUR" = "00" ] ; then
- touch screenlog.yesterday
- diff screenlog.yesterday screenlog.new | mail -s "piuparts-slave screenlog yesterday" piupartsm
- cp screenlog.new screenlog.yesterday
+ rm -f $LOCKFILE
fi
Modified: piatti/home/piupartss/bin/slave_run
===================================================================
--- piatti/home/piupartss/bin/slave_run 2010-11-07 16:13:53 UTC (rev 717)
+++ piatti/home/piupartss/bin/slave_run 2010-11-10 17:26:41 UTC (rev 718)
@@ -31,7 +31,4 @@
screen -L -d -m -S piuparts-slave-screen su - piupartss -c "cd /org/piuparts.debian.org/slave && python ../share/piuparts/piuparts-slave"
-rm -f $MONITORDIR/screenlog.new $MONITORDIR/screenlog.old
-touch $MONITORDIR/screenlog.new
-chmod 775 $MONITORDIR/screenlog.new
echo "piuparts-slave has been started."
More information about the Piuparts-commits
mailing list