--- ping.old 2010-01-28 18:19:40.000000000 +0000 +++ ping.new 2010-01-28 18:26:13.000000000 +0000 @@ -62,14 +62,6 @@ - - -The name of the instance_attributes set to place the value in. Rarely needs to be specified. - -Set name - - - The name of the attributes to set. This is the name to be used in the constraints. @@ -78,14 +70,6 @@ - - -The section place the value in. Rarely needs to be specified. - -Section name - - - The number by which to multiply the number of connected ping nodes by @@ -126,6 +110,14 @@ + + +Enables to use default attrd_updater verbose logging on every call. + +Verbose logging + + + @@ -162,21 +154,28 @@ if [ $? = $OCF_SUCCESS ]; then return $OCF_SUCCESS fi - touch ${OCF_RESKEY_state} + touch ${OCF_RESKEY_pidfile} ping_update } ping_stop() { ping_monitor if [ $? = $OCF_SUCCESS ]; then - rm ${OCF_RESKEY_state} + rm ${OCF_RESKEY_pidfile} fi - attrd_updater -D -n $OCF_RESKEY_name -d $OCF_RESKEY_dampen + + local QUIET_OPTION='-q' + if ocf_is_true ${OCF_RESKEY_debug} ; then + QUIET_OPTION='' + fi + + attrd_updater -D -n $OCF_RESKEY_name -d $OCF_RESKEY_dampen $DEBUG_OPTION + return $OCF_SUCCESS } ping_monitor() { - if [ -f ${OCF_RESKEY_state} ]; then + if [ -f ${OCF_RESKEY_pidfile} ]; then ping_update return $OCF_SUCCESS fi @@ -186,10 +185,10 @@ ping_validate() { # Is the state directory writable? - state_dir=`dirname "$OCF_RESKEY_state"` + state_dir=`dirname "$OCF_RESKEY_pidfile"` touch "$state_dir/$$" if [ $? != 0 ]; then - ocf_log err "Invalid location for 'state': $OCF_RESKEY_state is not writable" + ocf_log err "Invalid location for 'state': $state_dir is not writable" return $OCF_ERR_ARGS fi rm "$state_dir/$$" @@ -197,22 +196,32 @@ # Pidfile better be an absolute path case $OCF_RESKEY_pidfile in /*) ;; - *) ocf_log warn "You should use an absoluet path for pidfile not: $OCF_RESKEY_pidfile" ;; + *) ocf_log warn "You should use an absolute path for pidfile not: $OCF_RESKEY_pidfile" ;; esac # Check the ping interval - if ocf_is_decimal "$OCF_RESKEY_interval" && [ $OCF_RESKEY_interval -gt 0 ]; then + if ocf_is_decimal "$OCF_RESKEY_CRM_meta_interval" && [ $OCF_RESKEY_CRM_meta_interval -gt 0 ]; then : else ocf_log err "Invalid ping interval $OCF_RESKEY_interval. It should be positive integer!" exit $OCF_ERR_CONFIGURED fi +# Check the host list if [ "x" = "x$OCF_RESKEY_host_list" ]; then ocf_log err "Empty host_list. Please specify some nodes to ping" exit $OCF_ERR_CONFIGURED fi +# Check the debug option + if [ "x" = "x${OCF_RESKEY_debug}" ]; then + ocf_log err "Debug option not specified. Please specify 'true' or 'false'" + exit $OCF_ERR_CONFIGURED + elif [ "${OCF_RESKEY_debug}" != "true" -a "${OCF_RESKEY_debug}" != "false" ]; then + ocf_log err "Debug option specified is not correct. Please specify 'true' or 'false'" + exit $OCF_ERR_CONFIGURED + fi + check_binary ping return $OCF_SUCCESS @@ -241,16 +250,23 @@ *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";; esac done - score=`expr $active * $OCF_RESKEY_multiplier` - attrd_updater -n $OCF_RESKEY_name -v $score -d $OCF_RESKEY_dampen + score=`expr $active \* $OCF_RESKEY_multiplier` + + local QUIET_OPTION='-q' + if ocf_is_true ${OCF_RESKEY_debug} ; then + QUIET_OPTION='' + fi + + attrd_updater -n $OCF_RESKEY_name -v $score -d $OCF_RESKEY_dampen $DEBUG_OPTION } : ${OCF_RESKEY_name:="pingd"} : ${OCF_RESKEY_dampen:="5s"} : ${OCF_RESKEY_attempts:="5"} : ${OCF_RESKEY_multiplier:="1"} -: ${OCF_RESKEY_CRM_meta_timeout=0} -: ${OCF_RESKEY_CRM_meta_interval=0} +: ${OCF_RESKEY_debug:="false"} +: ${OCF_RESKEY_CRM_meta_timeout=20} +: ${OCF_RESKEY_CRM_meta_interval=10} : ${OCF_RESKEY_CRM_meta_globally_unique:="true"} if [ -z ${OCF_RESKEY_timeout} ]; then