Hi all,
We in the implementation of heartbeat with squid. we done the script for
starting squid during heartbeat takeover. But when the service (squid in
this case) is stopped, the heartbeat will not takeover. I saw that there
are some resource monitoring solutions are available, but i don't know
how to configure them. I have attached the sample configuration files
for your reference.
Please provide a solution for monitoring the service.
ha.cf file
---------
logfile /var/log/ha-log
logfacility local0
ucast eth0 192.168.1.45
auto_failback on
watchdog /dev/watchdog
node test1.mydomain.com
node test2.mydomain.com
haresources file
----------------
test1.mydomain.com 192.168.1.100 squid
authkeys file
------------
auth 2
2 sha1 HI!
Your help is very thankful,
Jayaprakash S
#!/bin/sh
#
VARRUN=/var/run
. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
SQLOC=/usr/local/squid26s14
PidFile=$SQLOC/var/log/squid.pid
silent_status() {
if
[ -f $PidFile ]
then
ProcessRunning `cat $PidFile`
else
: No pid file
false
fi
}
####################################.....Visolve....###########################
#SQLOC=/usr/local/squid26s14
# Source function library.
. /etc/rc.d/init.d/functions
PATH=${SQLOC}/sbin:/usr/bin:/sbin:/bin:/usr/sbin:$PATH
export PATH
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
# check if the squid conf file is present
[ -f ${SQLOC}/etc/squid.conf ] || exit 0
if [ -f /etc/sysconfig/squid ]; then
. /etc/sysconfig/squid
fi
# don't raise an error if the config file is incomplete
# set defaults instead:
SQUID_OPTS=${SQUID_OPTS:-"-D"}
SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
# determine the name of the squid binary
[ -f ${SQLOC}/sbin/squid ] && SQUID=squid
[ -z "$SQUID" ] && exit 0
prog="$SQUID"
# determine which one is the cache_swap directory
CACHE_SWAP=`sed -e 's/#.*//g' ${SQLOC}/etc/squid.conf | \
grep cache_dir | awk '{ print $3 }'`
[ -z "$CACHE_SWAP" ] && CACHE_SWAP=${SQLOC}/var/cache
RETVAL=0
start() {
for adir in $CACHE_SWAP; do
if [ ! -d $adir/00 ]; then
echo -n "init_cache_dir $adir... "
ocf_run $SQUID -z -F -D 2>/dev/null
echo $?
fi
done
echo -n $"Starting $prog: "
echo "32768" > /proc/sys/fs/file-max
ulimit -HSn 32768
#visolve
if
silent_status
then
ocf_log info "$CMD already running (pid $ApachePID)"
return $OCF_SUCCESS
fi
ocf_run $SQUID $SQUID_OPTS 2> /dev/null
#end
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
timeout=0;
while : ; do
[ ! -f ${SQLOC}/var/logs/squid.pid ] || break
if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then
RETVAL=1
break
fi
sleep 1 && echo -n "."
timeout=$((timeout+1))
done
fi
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SQUID
[ $RETVAL -eq 0 ] && echo_success
[ $RETVAL -ne 0 ] && echo_failure
echo
#return $ec
return $RETVAL
}
stop() {
#echo -n $"Stopping $prog: "
ocf_run $SQUID -k check >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
ocf_run $SQUID -k shutdown &
rm -f /var/lock/subsys/$SQUID
timeout=0
while : ; do
[ -f ${SQLOC}/var/logs/squid.pid ] || break
if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
#visolve
return 1
fi
sleep 2 && echo -n "."
timeout=$((timeout+2))
done
# echo echo_success
#else
# echo echo_failure
fi
return $RETVAL
}
reload() {
ocf_run $SQUID $SQUID_OPTS -k reconfigure
}
restart() {
stop
start
}
condrestart() {
[ -e /var/lock/subsys/squid ] && restart || :
}
rhstatus() {
status $SQUID
ocf_run $SQUID -k check
}
probe() {
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
condrestart)
condrestart
;;
status)
rhstatus
;;
probe)
exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
exit 1
esac
exit $?
#!/bin/sh
#
# $Id: apache.in,v 1.7 2006/08/14 09:37:21 andrew Exp $
#
# Description: wrapper of OCF RA apache, based on original heartbeat RA. See
# OCF RA apache for more information.
#
# Author: Xun Sun <[EMAIL PROTECTED]>
# Support: linux-ha@lists.linux-ha.org
# License: GNU General Public License (GPL)
# Copyright: (C) 2005 International Business Machines
#
# An example usage in /etc/ha.d/haresources:
# node1 10.0.0.170 apache::/opt/IBMHTTPServer/conf/httpd.conf
# node1 10.0.0.170 IBMhttpd
#
. /etc/ha.d/resource.d//hto-mapfuncs
#usage() {
# echo "usage: $0 [config-file-pathname] $LEGAL_ACTIONS"
# exit 1
#}
case $# in
1) op=$1
;;
2) OCF_RESKEY_configfile=$1; export OCF_RESKEY_configfile
op=$2
;;
*) usage
;;
esac
OCF_TYPE=squid
OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$OCF_RESKEY_configfile
export OCF_TYPE OCF_RESOURCE_INSTANCE
#export OCF_TYPE
ra_execocf $op
_______________________________________________
Linux-HA mailing list
Linux-HA@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems