4
# pingd OCF Resource Agent
5
# Records (in the CIB) the current number of ping nodes a
6
# cluster node can connect to.
8
# Copyright (c) 2006 Andrew Beekhof
11
# This program is free software; you can redistribute it and/or modify
12
# it under the terms of version 2 of the GNU General Public License as
13
# published by the Free Software Foundation.
15
# This program is distributed in the hope that it would be useful, but
16
# WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
# Further, this software is distributed without any warranty that it is
20
# free of the rightful claim of any third person regarding infringement
21
# or the like. Any license provided herein, whether implied or
22
# otherwise, applies only to this software file. Patent licenses, if
23
# any, provided herein do not apply to combinations of this program with
24
# other software, or any other product whatsoever.
26
# You should have received a copy of the GNU General Public License
27
# along with this program; if not, write the Free Software Foundation,
28
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
30
#######################################################################
33
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
34
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
36
#######################################################################
41
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
42
<resource-agent name="pingd">
43
<version>1.0</version>
46
Deprecation warning: This agent is deprecated and may be removed from
47
a future release. See the ocf:pacemaker:pingd resource agent for a
48
supported alternative. --
49
This is a pingd Resource Agent.
50
It records (in the CIB) the current number of ping nodes a node can connect to.
52
<shortdesc lang="en">Monitors connectivity to specific hosts or
53
IP addresses ("ping nodes") (deprecated)</shortdesc>
57
<parameter name="pidfile" unique="0">
58
<longdesc lang="en">PID file</longdesc>
59
<shortdesc lang="en">PID file</shortdesc>
60
<content type="string" default="$HA_RSCTMP/pingd-${OCF_RESOURCE_INSTANCE}" />
64
<parameter name="user" unique="0">
66
The user we want to run pingd as
68
<shortdesc lang="en">The user we want to run pingd as</shortdesc>
69
<content type="string" default="root" />
72
<parameter name="dampen" unique="0">
74
The time to wait (dampening) further changes occur
76
<shortdesc lang="en">Dampening interval</shortdesc>
77
<content type="integer" default="1s"/>
80
<parameter name="set" unique="0">
82
The name of the instance_attributes set to place the value in. Rarely needs to be specified.
84
<shortdesc lang="en">Set name</shortdesc>
85
<content type="integer" default=""/>
88
<parameter name="name" unique="0">
90
The name of the attributes to set. This is the name to be used in the constraints.
92
<shortdesc lang="en">Attribute name</shortdesc>
93
<content type="integer" default="${OCF_RESOURCE_INSTANCE}"/>
96
<parameter name="section" unique="0">
98
The section place the value in. Rarely needs to be specified.
100
<shortdesc lang="en">Section name</shortdesc>
101
<content type="integer" default=""/>
104
<parameter name="multiplier" unique="0">
106
The number by which to multiply the number of connected ping nodes by
108
<shortdesc lang="en">Value multiplier</shortdesc>
109
<content type="integer" default=""/>
112
<parameter name="host_list" unique="0">
114
The list of ping nodes to count. Defaults to all configured ping nodes. Rarely needs to be specified.
116
<shortdesc lang="en">Host list</shortdesc>
117
<content type="integer" default=""/>
120
<parameter name="ignore_deprecation">
122
If set to true, suppresses the deprecation warning for this agent.
124
<shortdesc lang="en">Suppress deprecation warning</shortdesc>
125
<content type="boolean" default="false" />
131
<action name="start" timeout="20s" />
132
<action name="stop" timeout="20s" />
133
<action name="monitor" depth="0" timeout="20s" interval="10" />
134
<action name="meta-data" timeout="5" />
135
<action name="validate-all" timeout="20s" />
141
#######################################################################
145
usage: $0 {start|stop|monitor|validate-all|meta-data}
147
Expects to have a fully populated OCF RA-compliant environment set.
153
if [ ! -z "$OCF_RESKEY_multiplier" ]; then
154
extras="$extras -m $OCF_RESKEY_multiplier"
156
if [ ! -z "$OCF_RESKEY_set" ]; then
157
extras="$extras -s $OCF_RESKEY_set"
159
if [ ! -z "$OCF_RESKEY_section" ]; then
160
extras="$extras -S $OCF_RESKEY_section"
162
for a_host in $OCF_RESKEY_host_list; do
163
extras="$extras -h $a_host"
165
pingd_cmd="${HA_BIN}/pingd -D -p $OCF_RESKEY_pidfile -a $OCF_RESKEY_name -d $OCF_RESKEY_dampen $extras"
167
if [ ! -z $OCF_RESKEY_user ]; then
168
sudo -u $OCF_RESKEY_user $pingd_cmd
178
ocf_log err "Could not run $pingd_cmd : rc=$rc"
179
exit $OCF_ERR_GENERIC
183
if [ -f $OCF_RESKEY_pidfile ]; then
184
pid=`cat $OCF_RESKEY_pidfile`
186
if [ ! -z $pid ]; then
190
if [ $rc = 0 -o $rc = 1 ]; then
191
rm $OCF_RESKEY_pidfile
195
ocf_log err "Unexpected result from kill -9 $pid: $rc"
196
exit $OCF_ERR_GENERIC
202
if [ -f $OCF_RESKEY_pidfile ]; then
203
pid=`cat $OCF_RESKEY_pidfile`
205
if [ ! -z $pid ]; then
211
exit $OCF_NOT_RUNNING
215
# Existence of the user
216
if [ ! -z $OCF_RESKEY_user ]; then
217
getent passwd "$OCF_RESKEY_user" >/dev/null
218
if [ $? -eq 0 ]; then
219
: Yes, user exists. We can further check his permission on crm_mon if necessary
221
ocf_log err "The user $OCF_RESKEY_user does not exist!"
226
# Pidfile better be an absolute path
227
case $OCF_RESKEY_pidfile in
229
*) ocf_log warn "You should have pidfile($OCF_RESKEY_pidfile) of absolute path!" ;;
232
# Check the update interval
233
if ocf_is_decimal "$OCF_RESKEY_update" && [ $OCF_RESKEY_update -gt 0 ]; then
236
ocf_log err "Invalid update interval $OCF_RESKEY_update. It should be positive integer!"
244
if [ $# -ne 1 ]; then
249
: ${OCF_RESKEY_pidfile:="$HA_RSCTMP/pingd-${OCF_RESOURCE_INSTANCE}"}
250
: ${OCF_RESKEY_name:="pingd"}
251
: ${OCF_RESKEY_dampen:="1s"}
253
if [ "$__OCF_ACTION" = "meta-data" ]; then
258
# Be obnoxious, log deprecation warning on every invocation (unless
259
# suppressed by resource configuration).
262
case $__OCF_ACTION in
267
monitor) pingd_monitor
269
validate-all) pingd_validate
271
usage|help) pingd_usage
275
exit $OCF_ERR_UNIMPLEMENTED