[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A kludged monit/pure-ftpd setup
From: |
Whit Blauvelt |
Subject: |
A kludged monit/pure-ftpd setup |
Date: |
Wed, 21 Jan 2004 16:41:23 -0500 |
User-agent: |
Mutt/1.5.4i |
Problem:
Pure-ftpd + pure-authd can sometimes (rarely) stop accepting logins
despite that they're both still running and look intact to basic monit
checks.
Solution:
Have monit run an expect sequence to check that the login is actually
working.
Problem:
Pure-ftpd pid files can sometimes (rarely) just vanish, despite that the
daemon with that pid is still running, which causes monit to think the
pure-ftpd daemon itself has failed (when it hasn't) and monit can't restart
it (because it's still bound to the port, and monit doesn't have the pid to
stop it first). This means the first problem is no longer solved, since
monit won't check further once the pid file is missing.
Rube Goldberg-type Partial Solution:
Have monit run an external start script that kills all pure-ftpd daemons.
(This is a bad solution when running multiple pure-ftpd daemons since if
this is attached to more than one of them through monit, they'll be killing
each other and getting really ugly. What this still needs is a check so this
does _not_ kill and pure-ftpd daemon that still has a good pid file - doable
but I haven't scripted that yet.)
Anyhow, in case this is useful to anyone else, here are the pieces so far:
In /etc/monitrc (the number of expect "220.*" lines needs to be adjusted for
the length of your fortune - or lack of one):
check process pure-ftpd with pidfile /var/run/pure-ftpd.pid
start program ="/path/to/pure-start.sh"
stop program ="/path/to/kill.sh"
if failed host 2xx.xxx.xxx.xxx port 21
expect "220.*"
expect "220.*"
expect "220.*"
expect "220.*"
expect "220.*"
expect "220.*"
expect "220.*"
expect "220.*"
expect "220.*"
expect "220.*"
expect "220.*"
send "USER someuser\n"
expect "331.*"
send "PASS somepass\n
expect "230.*"
expect "230.*"
send "QUIT\n"
expect "221.*"
then restart
if 5 restarts within 5 cycles then timeout
group pure
In /path/to/pure-start.sh:
#! /bin/sh
# for debugging through monit -Iv
set -vx
# kill any and all pure-ftpd daemons
getuids() {
ps -e | grep pure-ftpd | awk '/pure/ { print $1 }'
}
UIDs=`getuids`
for PUID in $UIDs; do
kill $PUID
done
# kill pure-authd just to be safe
kill `cat /var/run/pure-authd.pid`
# restart pure-ftpd
/usr/sbin/pure-ftpd [flags]
# restart pure-authd
/usr/sbin/pure-authd -s /var/run/ftpd.sock -r /path/to/ftpauthscript.php &
In /path/to/kill.sh:
#! /bin/sh
# for debugging through monit -Iv
set -vx
# kill the process with the id passed from monit
if [ "x$MONIT_PROCESS_PID" != "x" ]
then
kill $MONIT_PROCESS_PID
else
error
fi
- A kludged monit/pure-ftpd setup,
Whit Blauvelt <=