mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
78b7043411
Change the monitor event in 40.vsftpd so it only fails if there are 2 successive failures connecting to port 21. This reduces the likelihood of unhealthy nodes due to vsftpd being restarted for reconfiguration due to node failover or system reconfiguration. New eventscript functions ctdb_counter_init, ctdb_counter_incr, ctdb_counter_limit. These are used to count arbitrary things in eventscripts, depending on the eventscript name and a tag that is passed, and determine if a specified limit has been hit. They're good for counting failures! These functions are used in 40.vsftpd and also in 01.reclock - the latter used to do the counting without these functions. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit cfe63636a163730ae9ad3554b78519b3c07d8896)
70 lines
1.5 KiB
Bash
Executable File
70 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# event strict to manage vsftpd in a cluster environment
|
|
|
|
. $CTDB_BASE/functions
|
|
loadconfig ctdb
|
|
loadconfig vsftpd
|
|
|
|
[ "$CTDB_MANAGES_VSFTPD" = "yes" ] || exit 0
|
|
|
|
cmd="$1"
|
|
shift
|
|
|
|
# Count the number of monitor failures. The cluster only becomes
|
|
# unhealthy after 2 failures.
|
|
VSFTPD_FAILS="fail-count"
|
|
VSFTPD_LIMIT=2
|
|
|
|
case $cmd in
|
|
startup)
|
|
/bin/mkdir -p $CTDB_BASE/state/vsftpd
|
|
|
|
# make sure the service is stopped first
|
|
service vsftpd stop > /dev/null 2>&1
|
|
service vsftpd start
|
|
|
|
ctdb_counter_init "$VSFTPD_FAILS"
|
|
;;
|
|
|
|
shutdown)
|
|
service vsftpd stop
|
|
;;
|
|
|
|
takeip)
|
|
echo "restart" > $CTDB_BASE/state/vsftpd/restart
|
|
;;
|
|
|
|
releaseip)
|
|
echo "restart" > $CTDB_BASE/state/vsftpd/restart
|
|
;;
|
|
|
|
recovered)
|
|
# if we have taken or released any ips we must
|
|
# restart vsftpd to ensure that all tcp connections are reset
|
|
[ -f $CTDB_BASE/state/vsftpd/restart ] && {
|
|
service vsftpd stop > /dev/null 2>&1
|
|
service vsftpd start
|
|
} >/dev/null 2>&1
|
|
|
|
/bin/rm -f $CTDB_BASE/state/vsftpd/restart 2>/dev/null
|
|
;;
|
|
|
|
monitor)
|
|
# Subshell catches the "exit 1"
|
|
if (ctdb_check_tcp_ports "ftp" 21) ; then
|
|
ctdb_counter_init "$VSFTPD_FAILS"
|
|
else
|
|
ctdb_counter_incr "$VSFTPD_FAILS"
|
|
if ctdb_counter_limit "$VSFTPD_FAILS" $VSFTPD_LIMIT ; then
|
|
echo "ERROR: more than $VSFTPD_LIMIT consecutive failures, marking cluster unhealthy"
|
|
exit 1
|
|
else
|
|
echo "WARNING: less than $VSFTPD_LIMIT consecutive failures, not unhealthy yet"
|
|
fi
|
|
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
exit 0
|