summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-cluster/pacemaker/files')
-rw-r--r--sys-cluster/pacemaker/files/1.0.12-BUILD_VERSION.patch43
-rw-r--r--sys-cluster/pacemaker/files/1.1.7-glibc2.16.patch13
-rw-r--r--sys-cluster/pacemaker/files/1.1.8-backwards_compatibility.patch36
-rw-r--r--sys-cluster/pacemaker/files/pacemaker-1.0.10-asneeded.patch22
-rw-r--r--sys-cluster/pacemaker/files/pacemaker-1.0.10-installpaths.patch9
-rw-r--r--sys-cluster/pacemaker/files/pacemaker-1.1.10-tinfo.patch21
-rw-r--r--sys-cluster/pacemaker/files/pacemaker-1.1.12-glib.patch47
-rw-r--r--sys-cluster/pacemaker/files/pacemaker-1.1.12-stonith.patch21
-rw-r--r--sys-cluster/pacemaker/files/pacemaker.initd42
-rw-r--r--sys-cluster/pacemaker/files/pacemaker.service5
-rw-r--r--sys-cluster/pacemaker/files/ping380
11 files changed, 639 insertions, 0 deletions
diff --git a/sys-cluster/pacemaker/files/1.0.12-BUILD_VERSION.patch b/sys-cluster/pacemaker/files/1.0.12-BUILD_VERSION.patch
new file mode 100644
index 000000000000..8e526644820a
--- /dev/null
+++ b/sys-cluster/pacemaker/files/1.0.12-BUILD_VERSION.patch
@@ -0,0 +1,43 @@
+# HG changeset patch
+# Parent d90c3d4786da4cfa7944c9009a0071e3ea6f8581
+
+diff -r d90c3d4786da configure.ac
+--- a/configure.ac Wed Jun 13 11:43:31 2012 +0900
++++ b/configure.ac Wed Jun 13 11:44:38 2012 +0900
+@@ -464,20 +464,26 @@
+ AC_DEFINE_UNQUOTED(STONITH_PLUGIN_DIR,"$STONITH_PLUGIN_DIR", Location for Stonith plugins)
+ AC_SUBST(STONITH_PLUGIN_DIR)
+
+-AC_PATH_PROGS(HG, hg false)
++AC_PATH_PROGS(GIT, git false)
+ AC_MSG_CHECKING(build version)
+-BUILD_VERSION=unknown
+-if test -f $srcdir/.hg_archival.txt; then
+- BUILD_VERSION=`cat $srcdir/.hg_archival.txt | awk '/node:/ { print $2 }'`
+-elif test -x $HG -a -d .hg; then
+- BUILD_VERSION=`$HG id -itb`
+- if test $? != 0; then
+- BUILD_VERSION=unknown
+- fi
++
++BUILD_VERSION=$Format:%H$
++if test $BUILD_VERSION != ":%H$"; then
++ AC_MSG_RESULT(archive hash: $BUILD_VERSION)
++
++elif test -x $GIT -a -d .git; then
++ BUILD_VERSION=`$GIT log --pretty="format:%h" -n 1`
++ AC_MSG_RESULT(git hash: $BUILD_VERSION)
++
++else
++ # The current directory name make a reasonable default
++ # Most generated archives will include the hash or tag
++ BASE=`basename $PWD`
++ BUILD_VERSION=`echo $BASE | sed s:.*[[Pp]]acemaker-::`
++ AC_MSG_RESULT(directory based hash: $BUILD_VERSION)
+ fi
+
+ AC_DEFINE_UNQUOTED(BUILD_VERSION, "$BUILD_VERSION", Build version)
+-AC_MSG_RESULT($BUILD_VERSION)
+ AC_SUBST(BUILD_VERSION)
+
+ dnl ===============================================
diff --git a/sys-cluster/pacemaker/files/1.1.7-glibc2.16.patch b/sys-cluster/pacemaker/files/1.1.7-glibc2.16.patch
new file mode 100644
index 000000000000..73ffd0614c69
--- /dev/null
+++ b/sys-cluster/pacemaker/files/1.1.7-glibc2.16.patch
@@ -0,0 +1,13 @@
+Fix building with glibc-2.16
+
+https://bugs.gentoo.org/show_bug.cgi?id=432012
+--- a/mcp/pacemaker.h
++++ b/mcp/pacemaker.h
+@@ -21,6 +21,7 @@
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
++#include <sys/resource.h>
+
+ #include <stdint.h>
+
diff --git a/sys-cluster/pacemaker/files/1.1.8-backwards_compatibility.patch b/sys-cluster/pacemaker/files/1.1.8-backwards_compatibility.patch
new file mode 100644
index 000000000000..d4a5780c0142
--- /dev/null
+++ b/sys-cluster/pacemaker/files/1.1.8-backwards_compatibility.patch
@@ -0,0 +1,36 @@
+--- a/lib/cluster/legacy.c 2012-11-08 11:55:09.297354491 +0100
++++ b/lib/cluster/legacy.c 2012-11-08 11:54:57.507587115 +0100
+@@ -1362,17 +1362,27 @@
+ /* If we can still talk to our peer process on that node,
+ * then its also part of the corosync membership
+ */
+- crm_trace("%s: processes=%.16x", node->uname, node->processes);
++ crm_trace("%s: processes=%.8x", node->uname, node->processes);
+ return TRUE;
+
+- } else if(is_classic_ais_cluster() && (node->processes & crm_proc_plugin) == 0) {
+- crm_trace("%s: processes=%.16x", node->uname, node->processes);
+- return FALSE;
++ } else if(is_classic_ais_cluster()) {
++ if(node->processes < crm_proc_none) {
++ crm_debug("%s: unknown process list, assuming active for now", node->uname);
++ return TRUE;
++
++ } else if(is_set(node->processes, crm_proc_none)) {
++ crm_debug("%s: all processes are inactive", node->uname);
++ return FALSE;
++
++ } else if(is_not_set(node->processes, crm_proc_plugin)) {
++ crm_trace("%s: processes=%.8x", node->uname, node->processes);
++ return FALSE;
++ }
+ }
+
+ proc = text2proc(crm_system_name);
+- if(proc != crm_proc_none && (node->processes & proc) == 0) {
+- crm_trace("%s: proc %.16x not in %.16x", node->uname, proc, node->processes);
++ if(proc > crm_proc_none && (node->processes & proc) == 0) {
++ crm_trace("%s: proc %.8x not in %.8x", node->uname, proc, node->processes);
+ return FALSE;
+ }
+
diff --git a/sys-cluster/pacemaker/files/pacemaker-1.0.10-asneeded.patch b/sys-cluster/pacemaker/files/pacemaker-1.0.10-asneeded.patch
new file mode 100644
index 000000000000..ac2655049380
--- /dev/null
+++ b/sys-cluster/pacemaker/files/pacemaker-1.0.10-asneeded.patch
@@ -0,0 +1,22 @@
+--- Makefile.am
++++ Makefile.am
+@@ -23,7 +23,7 @@
+ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure DRF/config-h.in \
+ DRF/stamp-h.in libtool.m4 ltdl.m4 libltdl.tar
+
+-SUBDIRS = debian $(LIBLTDL_DIR) replace include lib pengine cib crmd fencing tools shell xml cts extra doc
++SUBDIRS = $(LIBLTDL_DIR) replace include lib pengine cib crmd fencing tools shell xml cts extra doc
+
+ doc_DATA = AUTHORS COPYING COPYING.LIB
+
+--- lib/pengine/Makefile.am
++++ lib/pengine/Makefile.am
+@@ -34,7 +34,7 @@
+
+ libpe_status_la_LDFLAGS = -version-info 2:0:0
+ libpe_status_la_SOURCES = $(rule_files) $(status_files)
+-libpe_status_la_LIBADD = -llrm
++libpe_status_la_LIBADD = -llrm @CURSESLIBS@
+
+ clean-generic:
+ rm -f *.log *.debug *~
diff --git a/sys-cluster/pacemaker/files/pacemaker-1.0.10-installpaths.patch b/sys-cluster/pacemaker/files/pacemaker-1.0.10-installpaths.patch
new file mode 100644
index 000000000000..5187b7967ea9
--- /dev/null
+++ b/sys-cluster/pacemaker/files/pacemaker-1.0.10-installpaths.patch
@@ -0,0 +1,9 @@
+--- extra/Makefile.am
++++ extra/Makefile.am
+@@ -20,5 +20,5 @@
+
+ SUBDIRS = resources
+
+-mibdir = $(datadir)/snmp/mibs
++mibdir = $(datadir)/$(PACKAGE)/snmp/mibs
+ mib_DATA = PCMK-MIB.txt
diff --git a/sys-cluster/pacemaker/files/pacemaker-1.1.10-tinfo.patch b/sys-cluster/pacemaker/files/pacemaker-1.1.10-tinfo.patch
new file mode 100644
index 000000000000..1dba440c9e79
--- /dev/null
+++ b/sys-cluster/pacemaker/files/pacemaker-1.1.10-tinfo.patch
@@ -0,0 +1,21 @@
+--- a/configure.ac 2014-12-12 14:13:07.262413254 +0100
++++ b/configure.ac 2014-12-12 14:13:14.922480835 +0100
+@@ -885,14 +885,16 @@
+ CURSESLIBS=''
+ if test "$ac_cv_header_ncurses_h" = "yes"; then
+ AC_CHECK_LIB(ncurses, printw,
+- [CURSESLIBS='-lncurses'; AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)]
++ [AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)]
+ )
++ CURSESLIBS=`$PKGCONFIG --libs ncurses`;
+ fi
+
+ if test "$ac_cv_header_ncurses_ncurses_h" = "yes"; then
+ AC_CHECK_LIB(ncurses, printw,
+- [CURSESLIBS='-lncurses'; AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)]
++ [AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)]
+ )
++ CURSESLIBS=`$PKGCONFIG --libs ncurses`;
+ fi
+
+ dnl Only look for non-n-library if there was no n-library.
diff --git a/sys-cluster/pacemaker/files/pacemaker-1.1.12-glib.patch b/sys-cluster/pacemaker/files/pacemaker-1.1.12-glib.patch
new file mode 100644
index 000000000000..8233f98a17e8
--- /dev/null
+++ b/sys-cluster/pacemaker/files/pacemaker-1.1.12-glib.patch
@@ -0,0 +1,47 @@
+From 568e41db929a34106c8c2ff7c48716ab5c13ef49 Mon Sep 17 00:00:00 2001
+From: Andrew Beekhof <andrew@beekhof.net>
+Date: Mon, 13 Oct 2014 13:30:58 +1100
+Subject: [PATCH] Fix: lrmd: Prevent glib assert triggered by timers being
+ removed from mainloop more than once
+
+---
+ lib/services/services.c | 3 +++
+ lib/services/services_linux.c | 1 +
+ 2 files changed, 4 insertions(+)
+
+--- a/lib/services/services.c
++++ b/lib/services/services.c
+@@ -313,6 +313,7 @@ services_action_free(svc_action_t * op)
+
+ if (op->opaque->repeat_timer) {
+ g_source_remove(op->opaque->repeat_timer);
++ op->opaque->repeat_timer = 0;
+ }
+ if (op->opaque->stderr_gsource) {
+ mainloop_del_fd(op->opaque->stderr_gsource);
+@@ -425,6 +426,7 @@ services_action_kick(const char *name, c
+ } else {
+ if (op->opaque->repeat_timer) {
+ g_source_remove(op->opaque->repeat_timer);
++ op->opaque->repeat_timer = 0;
+ }
+ recurring_action_timer(op);
+ return TRUE;
+@@ -459,6 +461,7 @@ handle_duplicate_recurring(svc_action_t
+ if (dup->pid != 0) {
+ if (op->opaque->repeat_timer) {
+ g_source_remove(op->opaque->repeat_timer);
++ op->opaque->repeat_timer = 0;
+ }
+ recurring_action_timer(dup);
+ }
+--- a/lib/services/services_linux.c
++++ b/lib/services/services_linux.c
+@@ -226,6 +226,7 @@ recurring_action_timer(gpointer data)
+ op->stdout_data = NULL;
+ free(op->stderr_data);
+ op->stderr_data = NULL;
++ op->opaque->repeat_timer = 0;
+
+ services_action_async(op, NULL);
+ return FALSE;
diff --git a/sys-cluster/pacemaker/files/pacemaker-1.1.12-stonith.patch b/sys-cluster/pacemaker/files/pacemaker-1.1.12-stonith.patch
new file mode 100644
index 000000000000..31c729559f35
--- /dev/null
+++ b/sys-cluster/pacemaker/files/pacemaker-1.1.12-stonith.patch
@@ -0,0 +1,21 @@
+Description: Fix: stonith-ng: Reset mainloop source IDs after removing them
+
+Origin: upstream, commit: 0326f05c9e26f39a394fa30830e31a76306f49c7
+Author: Andrew Beekhof <andrew@beekhof.net>
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1412962
+Last-Update: 2015-01-20
+
+--- a/lib/fencing/st_client.c
++++ b/lib/fencing/st_client.c
+@@ -663,9 +663,11 @@ stonith_action_async_done(mainloop_child
+
+ if (action->timer_sigterm > 0) {
+ g_source_remove(action->timer_sigterm);
++ action->timer_sigterm = 0;
+ }
+ if (action->timer_sigkill > 0) {
+ g_source_remove(action->timer_sigkill);
++ action->timer_sigkill = 0;
+ }
+
+ if (action->last_timeout_signo) {
diff --git a/sys-cluster/pacemaker/files/pacemaker.initd b/sys-cluster/pacemaker/files/pacemaker.initd
new file mode 100644
index 000000000000..9adb92b28fa2
--- /dev/null
+++ b/sys-cluster/pacemaker/files/pacemaker.initd
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+PIDFILE=/var/run/pacemaker.pid
+
+depend() {
+ need net corosync
+ use syslog
+}
+
+start() {
+ nc=0
+ ebegin "Starting Pacemaker Cluster Manager"
+
+ checkpath -d -m 0750 -o hacluster:haclient /var/run/crm
+
+ einfon "Waiting for Corosync startup ."
+ while true; do
+ /usr/sbin/corosync-cfgtool -s &>/dev/null && break
+ nc=$(expr $nc + 1)
+ if [ $nc -gt 30 ]; then
+ echo
+ eend 1 "Failed to detect Corosync startup, is it really running ?"
+ exit 1
+ fi
+ sleep 1
+ echo -n "."
+ done
+ echo
+ start-stop-daemon --start -q --exec /usr/sbin/pacemakerd \
+ --pidfile "${PIDFILE}" --make-pidfile --background \
+ -- -f
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping Pacemaker Cluster Manager"
+ start-stop-daemon --stop -q --pidfile "${PIDFILE}"
+ eend $?
+}
diff --git a/sys-cluster/pacemaker/files/pacemaker.service b/sys-cluster/pacemaker/files/pacemaker.service
new file mode 100644
index 000000000000..6383499ba923
--- /dev/null
+++ b/sys-cluster/pacemaker/files/pacemaker.service
@@ -0,0 +1,5 @@
+service {
+ # Load the Pacemaker Cluster Resource Manager
+ name: pacemaker
+ ver: 1
+} \ No newline at end of file
diff --git a/sys-cluster/pacemaker/files/ping b/sys-cluster/pacemaker/files/ping
new file mode 100644
index 000000000000..52c4c3d4cad8
--- /dev/null
+++ b/sys-cluster/pacemaker/files/ping
@@ -0,0 +1,380 @@
+#!/bin/sh
+#
+#
+# Ping OCF RA that utilizes the system ping
+#
+# Copyright (c) 2009 Andrew Beekhof
+# All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Further, this software is distributed without any warranty that it is
+# free of the rightful claim of any third person regarding infringement
+# or the like. Any license provided herein, whether implied or
+# otherwise, applies only to this software file. Patent licenses, if
+# any, provided herein do not apply to combinations of this program with
+# other software, or any other product whatsoever.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+#
+
+#######################################################################
+# Initialization:
+
+: ${OCF_FUNCTIONS=${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs}
+. ${OCF_FUNCTIONS}
+: ${__OCF_ACTION=$1}
+
+#######################################################################
+
+meta_data() {
+ cat <<END
+<?xml version="1.0"?>
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
+<resource-agent name="ping">
+<version>1.0</version>
+
+<longdesc lang="en">
+Every time the monitor action is run, this resource agent records (in the CIB) the current number of ping nodes the host can connect to.
+It is essentially the same as pingd except that it uses the system ping tool to obtain the results.
+</longdesc>
+<shortdesc lang="en">node connectivity</shortdesc>
+
+<parameters>
+
+<parameter name="pidfile" unique="0">
+<longdesc lang="en">PID file</longdesc>
+<shortdesc lang="en">PID file</shortdesc>
+<content type="string" default="$HA_VARRUN/ping-${OCF_RESOURCE_INSTANCE}" />
+</parameter>
+
+<parameter name="dampen" unique="0">
+<longdesc lang="en">
+The time to wait (dampening) further changes occur
+</longdesc>
+<shortdesc lang="en">Dampening interval</shortdesc>
+<content type="integer" default="5s"/>
+</parameter>
+
+<parameter name="name" unique="0">
+<longdesc lang="en">
+The name of the attributes to set. This is the name to be used in the constraints.
+</longdesc>
+<shortdesc lang="en">Attribute name</shortdesc>
+<content type="string" default="pingd"/>
+</parameter>
+
+<parameter name="multiplier" unique="0">
+<longdesc lang="en">
+The number by which to multiply the number of connected ping nodes by
+</longdesc>
+<shortdesc lang="en">Value multiplier</shortdesc>
+<content type="integer" default=""/>
+</parameter>
+
+<parameter name="host_list" unique="0" required="1">
+<longdesc lang="en">
+The list of ping nodes to count.
+</longdesc>
+<shortdesc lang="en">Host list</shortdesc>
+<content type="string" default=""/>
+</parameter>
+
+<parameter name="attempts" unique="0">
+<longdesc lang="en">
+Number of ping attempts, per host, before declaring it dead
+</longdesc>
+<shortdesc lang="en">no. of ping attempts</shortdesc>
+<content type="integer" default="2"/>
+</parameter>
+
+<parameter name="timeout" unique="0">
+<longdesc lang="en">
+How long, in seconds, to wait before declaring a ping lost
+</longdesc>
+<shortdesc lang="en">ping timeout in seconds</shortdesc>
+<content type="integer" default="2"/>
+</parameter>
+
+<parameter name="options" unique="0">
+<longdesc lang="en">
+A catch all for any other options that need to be passed to ping.
+</longdesc>
+<shortdesc lang="en">Extra Options</shortdesc>
+<content type="string" default=""/>
+</parameter>
+
+<parameter name="failure_score" unique="0">
+<longdesc lang="en">
+Resource is failed if the score is less than failure_score.
+Default never fails.
+</longdesc>
+<shortdesc lang="en">failure_score</shortdesc>
+<content type="integer" default=""/>
+</parameter>
+
+<parameter name="debug" unique="0">
+<longdesc lang="en">
+Enables to use default attrd_updater verbose logging on every call.
+</longdesc>
+<shortdesc lang="en">Verbose logging</shortdesc>
+<content type="string" default="false"/>
+</parameter>
+
+</parameters>
+
+<actions>
+<action name="start" timeout="60" />
+<action name="stop" timeout="20" />
+<action name="reload" timeout="100" />
+<action name="monitor" depth="0" timeout="60" interval="10"/>
+<action name="meta-data" timeout="5" />
+<action name="validate-all" timeout="30" />
+</actions>
+</resource-agent>
+END
+}
+
+#######################################################################
+
+ping_conditional_log() {
+ level=$1; shift
+ if [ ${OCF_RESKEY_debug} = "true" ]; then
+ ocf_log $level "$*"
+ fi
+}
+
+ping_usage() {
+ cat <<END
+usage: $0 {start|stop|monitor|migrate_to|migrate_from|validate-all|meta-data}
+
+Expects to have a fully populated OCF RA-compliant environment set.
+END
+}
+
+ping_start() {
+ ping_monitor
+ if [ $? = $OCF_SUCCESS ]; then
+ return $OCF_SUCCESS
+ fi
+ touch ${OCF_RESKEY_pidfile}
+ ping_update
+}
+
+ping_stop() {
+
+ rm -f ${OCF_RESKEY_pidfile}
+
+ attrd_updater -D -n $OCF_RESKEY_name -d $OCF_RESKEY_dampen $attrd_options
+
+ return $OCF_SUCCESS
+}
+
+ping_monitor() {
+ if [ -f ${OCF_RESKEY_pidfile} ]; then
+ ping_update
+ if [ $? -eq 0 ]; then
+ return $OCF_SUCCESS
+ fi
+ return $OCF_ERR_GENERIC
+ fi
+ return $OCF_NOT_RUNNING
+}
+
+ping_validate() {
+ # Is the state directory writable?
+ state_dir=`dirname "$OCF_RESKEY_pidfile"`
+ touch "$state_dir/$$"
+ if [ $? != 0 ]; then
+ ocf_log err "Invalid location for 'state': $state_dir is not writable"
+ return $OCF_ERR_ARGS
+ fi
+ rm "$state_dir/$$"
+
+# Pidfile better be an absolute path
+ case $OCF_RESKEY_pidfile in
+ /*) ;;
+ *) ocf_log warn "You should use an absolute path for pidfile not: $OCF_RESKEY_pidfile" ;;
+ esac
+
+# 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_binary ping
+
+ return $OCF_SUCCESS
+}
+
+
+fping_check() {
+ active=0
+ f_out=`mktemp`
+ f_err=`mktemp`
+
+ n=$OCF_RESKEY_attempts
+ timeout=`expr $OCF_RESKEY_timeout \* 1000 / $OCF_RESKEY_attempts`
+
+ cmd="fping -r $OCF_RESKEY_attempts -t $timeout -B 1.0 $OCF_RESKEY_host_list"
+ $cmd>$f_out 2>$f_err; rc=$?
+ active=`grep alive $f_out|wc -l`
+
+ case $rc in
+ 0)
+ ;;
+ 1)
+ for h in `grep unreachable $f_out | awk '{print $1}'`; do
+ ping_conditional_log warn "$h is inactive"
+ done
+ ;;
+ *)
+ ocf_log err "Unexpected result for '$cmd' $rc: `tr '\n' ';' < $f_err`"
+ ;;
+ esac
+ rm -f $f_out $f_err
+
+ return $active
+}
+
+ping_check() {
+ active=0
+ for host in $OCF_RESKEY_host_list; do
+ p_exe=ping
+
+ 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";;
+ *) ocf_log err "Unknown host type: `uname`"; exit $OCF_ERR_INSTALLED;;
+ esac
+
+ case $host in
+ *:*) p_exe=ping6
+ esac
+
+ p_out=`$p_exe $p_args $OCF_RESKEY_options $host 2>&1`; rc=$?
+
+ case $rc in
+ 0) active=`expr $active + 1`;;
+ 1) ping_conditional_log warn "$host is inactive: $p_out";;
+ *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";;
+ esac
+ done
+ return $active
+}
+
+ping_update() {
+
+ if have_binary fping; then
+ fping_check
+ active=$?
+ else
+ ping_check
+ active=$?
+ fi
+
+ score=`expr $active \* $OCF_RESKEY_multiplier`
+ attrd_updater -n $OCF_RESKEY_name -v $score -d $OCF_RESKEY_dampen $attrd_options
+ rc=$?
+ case $rc in
+ 0) ping_conditional_log debug "Updated $OCF_RESKEY_name = $score" ;;
+ *) ocf_log warn "Could not update $OCF_RESKEY_name = $score: rc=$rc";;
+ esac
+ if [ $rc -ne 0 ]; then
+ return $rc
+ fi
+
+ if [ -n "$OCF_RESKEY_failure_score" -a "$score" -lt "$OCF_RESKEY_failure_score" ]; then
+ ocf_log warn "$OCF_RESKEY_name is less than failure_score($OCF_RESKEY_failure_score)"
+ return 1
+ fi
+ return 0
+}
+
+: ${OCF_RESKEY_name:="pingd"}
+: ${OCF_RESKEY_dampen:="5s"}
+: ${OCF_RESKEY_attempts:="3"}
+: ${OCF_RESKEY_multiplier:="1"}
+: ${OCF_RESKEY_debug:="false"}
+: ${OCF_RESKEY_failure_score:="0"}
+
+: ${OCF_RESKEY_CRM_meta_timeout:="20000"}
+: ${OCF_RESKEY_CRM_meta_globally_unique:="true"}
+
+integer=`echo ${OCF_RESKEY_timeout} | egrep -o '[0-9]*'`
+case ${OCF_RESKEY_timeout} in
+ *[0-9]ms|*[0-9]msec) OCF_RESKEY_timeout=`expr $integer / 1000`;;
+ *[0-9]m|*[0-9]min) OCF_RESKEY_timeout=`expr $integer \* 60`;;
+ *[0-9]h|*[0-9]hr) OCF_RESKEY_timeout=`expr $integer \* 60 \* 60`;;
+ *) OCF_RESKEY_timeout=$integer;;
+esac
+
+if [ -z ${OCF_RESKEY_timeout} ]; then
+ if [ x"$OCF_RESKEY_host_list" != x ]; then
+ host_count=`echo $OCF_RESKEY_host_list | awk '{print NF}'`
+ OCF_RESKEY_timeout=`expr $OCF_RESKEY_CRM_meta_timeout / $host_count / $OCF_RESKEY_attempts`
+ OCF_RESKEY_timeout=`expr $OCF_RESKEY_timeout / 1100` # Convert to seconds and finish 10% early
+ else
+ OCF_RESKEY_timeout=5
+ fi
+fi
+
+if [ ${OCF_RESKEY_timeout} -lt 1 ]; then
+ OCF_RESKEY_timeout=5
+elif [ ${OCF_RESKEY_timeout} -gt 1000 ]; then
+ # ping actually complains if this value is too high, 5 minutes is plenty
+ OCF_RESKEY_timeout=300
+fi
+
+if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then
+ : ${OCF_RESKEY_pidfile:="$HA_VARRUN/ping-${OCF_RESKEY_name}"}
+else
+ : ${OCF_RESKEY_pidfile:="$HA_VARRUN/ping-${OCF_RESOURCE_INSTANCE}"}
+fi
+
+case $__OCF_ACTION in
+ meta-data)
+ meta_data
+ exit $OCF_SUCCESS
+ ;;
+ usage|help)
+ ping_usage
+ exit $OCF_SUCCESS
+ ;;
+esac
+
+attrd_options='-q'
+if ocf_is_true ${OCF_RESKEY_debug} ; then
+ attrd_options=''
+fi
+
+# Check the debug option
+ case "${OCF_RESKEY_debug}" in
+ true|True|TRUE|1) OCF_RESKEY_debug=true;;
+ false|False|FALSE|0) OCF_RESKEY_debug=false;;
+ *)
+ ocf_log warn "Value for 'debug' is incorrect. Please specify 'true' or 'false' not: ${OCF_RESKEY_debug}"
+ OCF_RESKEY_debug=false
+ ;;
+ esac
+
+case $__OCF_ACTION in
+start) ping_start;;
+stop) ping_stop;;
+monitor) ping_monitor;;
+reload) ping_start;;
+validate-all) ping_validate;;
+*) ping_usage
+ exit $OCF_ERR_UNIMPLEMENTED
+ ;;
+esac
+exit $?