natan wrote in
<[email protected]>:
|Hi
|I use keepalived and easy check like:
|
|vrrp_script chk_myscript {
| script "/usr/bin/postfix-check.sh"
| interval 4
| fall 2
| weight 10
| user root
|}
|
|...
|#!/bin/bash
|echo "ehlo localhost" | /bin/nc -w 1 "127.0.0.1" 25 |grep -q "250"
|...
|
|It's not very pretty but do you have any similar solutions?
|--
From localhost either
postfix_watchdog() {
postfix__init
${prog} status >/dev/null 2>&1
[ ${?} -ne 0 ] && postfix_start
}
or
postfix_status() {
# As postfix does not use stdout but console, no
# postfix__init
# ${prog} status 2>&1
name=postfix
eval $(postconf daemon_directory data_directory | tr -d '[ ]')
prog=${daemon_directory}/master
pid=${data_directory}/master.lock
daemons__stat_and_dog n
}
and
daemons__stat_and_dog() {
{
isdog=${1}
exe=${prog}
[ -n "${exe}" ] && exe=' --exec '${exe}
if [ -n "${DAEMONS_SSD_GRACEFUL}" ]; then
${ssd} --status --pidfile ${pid} ${exe}
e=${?}
else
# XXX busybox start-stop-daemon without --status
# XXX After checking "kill -0 $PID" we could "pgrep $exe" and ensure
# XXX $PID is found in output!
if [ -f ${pid} ]; then
i=$(cat ${pid})
if kill -0 ${i} >/dev/null 2>/dev/null; then
e=0
else
e=1
fi
else
e=3
fi
fi
if [ ${isdog} != y ]; then
case ${e} in
0) echo "${name} is running with pid $(cat ${pid})";;
1) echo "${name} is not running but the pid file ${pid} exists";;
3) echo ${name}' is not running';;
4) echo ${name}' is in unknown state';;
esac
elif [ ${e} -ne 0 ]; then
echo >&2 ${name}' watchdog forces start'
if [ ${e} -eq 1 ]; then
rm -f ${pid}
elif [ ${e} -eq 4 ]; then
( eval ${name}_stop ) 2>/dev/null
fi
eval ${name}_start
e=${?}
fi
} 2>&1
return ${e}
}
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
_______________________________________________
Postfix-users mailing list -- [email protected]
To unsubscribe send an email to [email protected]