Friday, April 20, 2007
Zope monitor script
I manage a box with multiple Zope installations. It’s been running low on memory lately, causing one of the older Zope installations to freeze every couple of days. I put together this simple script to monitor Zope’s status, as a standby until a proper solution is found. It’s a simplified version of a script originally written in 2000, when Zope was unstable enough to need it.
#!/bin/sh cd `dirname $0` SCRIPTHOME=`pwd` if (wget http://localhost:8080/ --delete-after -t 1 -T 120 >& /dev/null) ; then # Zope is alive if [ -f $SCRIPTHOME/zope-status.down ] ; then rm -f $SCRIPTHOME/zope-status.down touch $SCRIPTHOME/zope-status.up fi else # Zope is dead if [ -f $SCRIPTHOME/zope-status.up ] ; then rm -f $SCRIPTHOME/zope-status.up touch $SCRIPTHOME/zope-status.down $SCRIPTHOME/zopectl restart fi fi
To use, dump this in your Zope’s bin folder, change the 8080 to whatever port your server is running, set the initial status flag …
$ touch zope-status.up
… and setup a cron job for the user account:
*/5 * * * * ~/zinstance2.7/bin/zopecheck.sh