Pacemaker - Logging the result of a ping check?

ug flag

I read this page and the next:

And it explains how to set up a ping that you can link to the allocation of a resource.

While this works, if I have more than 1 URL or more than 1 ping check, how can I know which one is failing?

It seems this isn't logged anywhere if it occurs. It just occurs and pacemaker makes a decision...

Reading this source code:

It seems a debug environment variable needs to be enabled. I'd rather not do this, assuming I have to restart pacemaker for it and thus messing up allocations, plus whatever amount of extra logs will now be taking up disk space.

Is there a way to just only log a single line if a ping failed, saying only that, and affecting nothing else?

nr flag

Looking at the resource agent's (RA) source, it looks like enabling the debug option by setting it to warn is what you'd want to do.

If for some reason that behavior isn't what you want, changing the 1) case statement in the ping_check() function as shown below (line 305 in the ping RA) might be what you're looking for:

ping_check() {
    for host in $OCF_RESKEY_host_list; do

        case $(uname) in
            Linux) p_args="-n -q -W $OCF_RESKEY_timeout -c $OCF_RESKEY_attempts";;
            Darwin) p_args="-n -q -t $OCF_RESKEY_timeout -c $OCF_RESKEY_attempts -o";;
            FreeBSD) p_args="-n -q -t $OCF_RESKEY_timeout -c $OCF_RESKEY_attempts -o";;
            *) ocf_log err "Unknown host type: $(uname)"; exit $OCF_ERR_INSTALLED;;

        case "$host" in
            *:*) p_exe=ping6

        ping_output=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1); rc=$?

        case $rc in
                active=$(expr $active + 1)
                if [ $OCF_RESKEY_debug -gt 1 ]; then
                    ping_conditional_log info "$ping_output"
            1) ocf_log warn "$host is inactive: $ping_output";;
            *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $ping_output";;

But that change looks like it will follow the same logic as setting the param debug=warn. I haven't tested this, just following the logic in the RA.

Also, if you do need to restart Pacemaker for some reason you can always put the cluster into maintenance-mode=true before doing so. If maintenance-mode=true is set Pacemaker will not start/stop/monitor services even while restarting. Just remember to set maintenance-mode=false when you're done.

ug flag
Both these options seem like they will generate a lot more logs, and also restarting pacemaker is not an option for me. Thanks for your thorough look at it.
ug flag

It turns out that the debug option isn't just an environment variable, it can be set on the ping resource itself, like this:

pcs resource update ping debug=1

The only downside is: the log doesn't appear in /var/log/pacemaker.log as expected but in /var/log/syslog.

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.