On 2008-10-24T13:46:49, Achim Stumpf <[EMAIL PROTECTED]> wrote:
> I have rewritten the pure-ftpd resurce agent to a proftpd resource agent. In
> my first tests it runs well. In one week the system will be productive, and
> if I find any bug until then, I will post the diffs here.
Hi Achim, thanks for the submission!
> Actually it does the same thing as the pure-ftpd script, except monitoring.
> It is possible to configure in cib.xml an OCF_CHECK_LEVEL greater zero. The
> script will not check anymore for the pid, but it will perform a login to the
> ftp server on localhost with curl.
Nice. Though I'd recommend to do both even for a value greater 0.
> So far as I can see the pure-ftpd script was published under the GPL, and I
> would like to contribute that script under the GPL as well. Could anyone
> commit that code, please?
Sure, just a few points:
> <actions>
> ...
> <action name="monitor" depth="10" timeout="20s" interval="60s"
> start-delay="1s" />
> ...
> </actions>
>
> What I have to write here? Any docs?
Well, what you want to write there depends on what you want to happen
;-) basically, you get to specify the timeout & interval for the monitor
ops, which serve as recommendation to the GUI/CLI when the admin
configures such resources.
"start_delay" should not be necessary, unless your start operation is
broken.
> if [ -f $OCF_RESKEY_pidfile ]
No "" around this one?
> then
> # Proftpd is probably running
> PID=`head -n 1 $OCF_RESKEY_pidfile`
> if [ ! -z $PID ] ; then
> isRunning "$PID" && [ `ps -p $PID | grep proftpd | wc
> -l` -eq 1 ]
> return $?
if ps -p $PID | grep proftpd ; then ... would already work, you don't
need the wc.
> proftpd_start()
> {
> #
> # make a few checks and start Proftpd
> #
> if ocf_is_root ; then : ; else
> ocf_log err "You must be root"
> exit $OCF_ERR_PERM
> fi
>
> # if Proftpd is running return success
>
> if proftpd_status ; then
> ocf_log info "Poftpd is running already"
> exit $OCF_SUCCESS
> fi
>
> # check that the Proftpd config file exist
> if [ ! -f "$OCF_RESKEY_conffile" ]; then
> ocf_log err "Proftpd config file '$OCF_RESKEY_conffile' does
> not exist"
> exit $OCF_ERR_GENERIC
> fi
This should be OCF_ERR_INSTALLED or _CONFIGURED.
> # starting Proftpd
> ${OCF_RESKEY_binary} --config ${OCF_RESKEY_conffile} 2>/dev/null
You also need to do a check_binary on the proftpd binary somewhere prior
to calling this command.
> proftpd_stop()
> {
> if proftpd_status ; then
> PID=`head -n 1 $OCF_RESKEY_pidfile`
> if [ ! -z $PID ] ; then
> kill $PID
> if [ $? -ne 0 ]; then
> ocf_log err "Proftpd couldn't be stopped"
> return $OCF_ERR_GENERIC
> fi
> fi
> fi
You need to check afterwards that the process is really gone. kill is
not sufficient; it might send the signal, but if the process is stuck on
IO, it might not stop. I'd also recommend kill -9.
> proftpd_monitor()
> {
> if [ $OCF_CHECK_LEVEL -eq 0 ]; then
> if proftpd_status ; then
> ocf_log debug "Proftpd monitor succeded"
> return $OCF_SUCCESS
> fi
"succeeded" ;-)
> else
> ${OCF_RESKEY_curl_binary} -sS --connect-timeout
> ${OCF_RESKEY_connect_timeout} --max-time ${OCF_RESKEY_max_time} -u
> "${OCF_RESKEY_test_user}:${OCF_RESKEY_test_pass}" ftp://localhost/ >
> /dev/null 2>&1
The curl_binary also needs to be "check_binary"ed somewhere.
And you might be managing several proftpd instances, none of which might
bind to "localhost"; I think the URL needs to be configurable.
Regards,
Lars
--
Teamlead Kernel, SuSE Labs, Research and Development
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
"Experience is the name everyone gives to their mistakes." -- Oscar Wilde
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/