ctdb_setup_state_dir "service" "$service_name"
+port_21="vsftpd listening on TCP port 21"
+
case "$1" in
startup)
service "$service_name" stop > /dev/null 2>&1
service "$service_name" start
- ctdb_counter_init
+ failcount_init "$port_21"
;;
shutdown)
monitor)
if ctdb_check_tcp_ports 21 ; then
- ctdb_counter_init
+ failcount_reset "$port_21"
else
- ctdb_counter_incr
- num_fails=$(ctdb_counter_get)
- if [ "$num_fails" -ge 2 ] ; then
- die "ERROR: ${num_fails} consecutive failures for vsftpd, marking node unhealthy"
- elif [ "$num_fails" -eq 1 ] ; then
- echo "WARNING: vsftpd not listening but less than 2 consecutive failures, not unhealthy yet"
- fi
+ # Set defaults, if unset
+ : "${CTDB_VSFTPD_MONITOR_THRESHOLDS:=1:2}"
+
+ failcount_incr "$port_21" "$CTDB_VSFTPD_MONITOR_THRESHOLDS"
fi
;;
esac
</refsect2>
+ <refsect2>
+ <title>40.vsftpd</title>
+
+ <para>
+ Provides CTDB's vsftpd service management.
+ </para>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ CTDB_VSFTPD_MONITOR_THRESHOLDS=<parameter>THRESHOLDS</parameter>
+ </term>
+ <listitem>
+ <para>
+ THRESHOLDS indicates how many consecutive monitoring
+ attempts need to report that vsftpd is not listening on
+ TCP port 21 before a warning is logged and before
+ monitoring fails. See the <citetitle>Monitoring
+ Thresholds</citetitle> for a description of how
+ monitoring thresholds work.
+ </para>
+ <para>
+ Default is 1:2.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+
+ </refsect2>
+
<refsect2>
<title>48.netbios</title>
. "${TEST_SCRIPTS_DIR}/unit.sh"
-define_test "managed, down - once, twice"
+define_test "up once, down with recovery"
+
+setup "up"
+
+ok_null
+simple_test
setup "down"
ok <<EOF
vsftpd not listening on TCP port 21
-WARNING: vsftpd not listening but less than 2 consecutive failures, not unhealthy yet
+WARNING: vsftpd listening on TCP port 21: fail count 1 >= threshold 1
+EOF
+simple_test
+
+setup "up"
+
+ok <<EOF
+NOTICE: vsftpd listening on TCP port 21: no longer failing
+EOF
+simple_test
+
+setup "down"
+
+ok <<EOF
+vsftpd not listening on TCP port 21
+WARNING: vsftpd listening on TCP port 21: fail count 1 >= threshold 1
+EOF
+simple_test
+
+required_result 1 <<EOF
+vsftpd not listening on TCP port 21
+ERROR: vsftpd listening on TCP port 21: fail count 2 >= threshold 2
EOF
simple_test
required_result 1 <<EOF
vsftpd not listening on TCP port 21
-ERROR: 2 consecutive failures for vsftpd, marking node unhealthy
+ERROR: vsftpd listening on TCP port 21: fail count 3 >= threshold 2
+EOF
+simple_test
+
+setup "up"
+
+ok <<EOF
+NOTICE: vsftpd listening on TCP port 21: no longer failing
EOF
simple_test
if [ "$1" != "down" ]; then
service "$_service_name" start
+ setup_tcp_listen 21
else
service "$_service_name" force-stopped
+ setup_tcp_listen ""
fi
}