• R/O
  • SSH

pm_diskd: Commit

※ リポジトリは、pm-diskd ブランチが https://github.com/linux-ha-japan/pm_diskd-1.0 へ、pm-diskd-2.0ブランチが https://github.com/linux-ha-japan/pm_diskd へ移行しました。

Pacemaker 対応ディスク故障監視機能。

Pacemaker-1.0公式リポジトリのクローンに対し、パッチ作成用のブランチを作成して管理する。
ブランチ名: pm-diskd

初回 hg clone 実行後は、hg update -r pm-diskd を実行すること。

Heartbeat-2.1.4 用 hb-diskd(*) のPacemaker対応版
(*) http://sourceforge.jp/projects/linux-ha/releases/?package_id=10555


Commit MetaInfo

Revisionffe13175a52b3cb40de10eecdb86b535031a732f (tree)
Time2013-02-20 15:31:32
AuthorYuusuke Iida <iidayuus@inte...>
CommiterYuusuke Iida

Log Message

corrected so that the installation place of diskd daemon performed out of an resource-agent might suit the actual condition.

Change Summary

Incremental Difference

diff -r 510ff3f9d7a9 -r ffe13175a52b configure.ac
--- a/configure.ac Tue Feb 19 08:52:08 2013 +0900
+++ b/configure.ac Wed Feb 20 15:31:32 2013 +0900
@@ -97,6 +97,7 @@
9797 dnl The Makefiles and shell scripts we output
9898 AC_CONFIG_FILES(Makefile \
9999 resources/Makefile \
100+ resources/diskd \
100101 tools/Makefile \
101102 pm_diskd.spec
102103 )
diff -r 510ff3f9d7a9 -r ffe13175a52b resources/diskd
--- a/resources/diskd Tue Feb 19 08:52:08 2013 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,288 +0,0 @@
1-#!/bin/sh
2-#
3-#
4-# diskd OCF Resource Agent
5-#
6-# This program is free software; you can redistribute it and/or modify
7-# it under the terms of version 2 of the GNU General Public License as
8-# published by the Free Software Foundation.
9-#
10-# This program is distributed in the hope that it would be useful, but
11-# WITHOUT ANY WARRANTY; without even the implied warranty of
12-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13-#
14-# Further, this software is distributed without any warranty that it is
15-# free of the rightful claim of any third person regarding infringement
16-# or the like. Any license provided herein, whether implied or
17-# otherwise, applies only to this software file. Patent licenses, if
18-# any, provided herein do not apply to combinations of this program with
19-# other software, or any other product whatsoever.
20-#
21-# You should have received a copy of the GNU General Public License
22-# along with this program; if not, write the Free Software Foundation,
23-# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
24-#
25-#######################################################################
26-# Initialization:
27-
28-. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
29-
30-#######################################################################
31-
32-meta_data() {
33- cat <<END
34-<?xml version="1.0"?>
35-<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
36-<resource-agent name="diskd">
37-<version>1.0</version>
38-
39-<longdesc lang="en">
40-This is a diskd Resource Agent.
41-</longdesc>
42-<shortdesc lang="en">diskd resource agent</shortdesc>
43-
44-<parameters>
45-
46-<parameter name="pidfile" unique="0">
47-<longdesc lang="en">PID file</longdesc>
48-<shortdesc lang="en">PID file</shortdesc>
49-<content type="string" default="$HA_VARRUN/diskd-${OCF_RESOURCE_INSTANCE}" />
50-</parameter>
51-
52-<parameter name="name" unique="0">
53-<longdesc lang="en">
54-The name of the attributes to set. This is the name to be used in the constraints.
55-</longdesc>
56-<shortdesc lang="en">Attribute name</shortdesc>
57-<content type="string" default="${OCF_RESOURCE_INSTANCE}"/>
58-</parameter>
59-
60-<parameter name="device" unique="0">
61-<longdesc lang="en">
62-The name of device to check.
63-</longdesc>
64-<shortdesc lang="en">Device name</shortdesc>
65-<content type="string" default=""/>
66-</parameter>
67-
68-<parameter name="write_dir" unique="0">
69-<longdesc lang="en">
70-The name of directory name to write.
71-</longdesc>
72-<shortdesc lang="en">Directory name</shortdesc>
73-<content type="string" default=""/>
74-</parameter>
75-
76-<parameter name="oneshot" unique="0">
77-<longdesc lang="en">
78-Disk check only one time
79-</longdesc>
80-<shortdesc lang="en">oneshot</shortdesc>
81-<content type="string" default=""/>
82-</parameter>
83-
84-<parameter name="interval" unique="0">
85-<longdesc lang="en">
86-Disk status check interval time.
87-</longdesc>
88-<shortdesc lang="en">check interval</shortdesc>
89-<content type="integer" default="30"/>
90-</parameter>
91-
92-<parameter name="options" unique="0">
93-<longdesc lang="en">
94-A catch all for any other options that need to be passed to diskd.
95-</longdesc>
96-<shortdesc lang="en">Extra Options</shortdesc>
97-<content type="string" default=""/>
98-</parameter>
99-
100-</parameters>
101-
102-<actions>
103-<action name="start" timeout="60" />
104-<action name="stop" timeout="60" />
105-<action name="monitor" depth="0" timeout="60" interval="10" start-delay="1m" />
106-<action name="meta-data" timeout="5" />
107-<action name="validate-all" timeout="30" />
108-</actions>
109-</resource-agent>
110-END
111-}
112-
113-#######################################################################
114-
115-del_attr_exit() {
116- typeset status=$1
117- attrd_updater -D -n $OCF_RESKEY_name -q
118- exit $status
119-}
120-
121-diskd_usage() {
122- cat <<END
123-usage: $0 {start|stop|monitor|validate-all|meta-data}
124-
125-Expects to have a fully populated OCF RA-compliant environment set.
126-END
127-}
128-
129-diskd_start() {
130- if [ ! -z "$OCF_RESKEY_oneshot" ]; then
131- touch ${OCF_RESKEY_state}
132- return $OCF_SUCCESS
133- fi
134-
135- extras=""
136- if [ ! -z "$OCF_RESKEY_device" ]; then
137- extras="$extras -N $OCF_RESKEY_device"
138- fi
139- if [ ! -z "$OCF_RESKEY_write_dir" ]; then # write-dir
140- extras="$extras -w -d $OCF_RESKEY_write_dir"
141- fi
142-
143- diskd_cmd="${HA_BIN}/diskd -D -p $OCF_RESKEY_pidfile -a $OCF_RESKEY_name -i $OCF_RESKEY_interval $extras $OCF_RESKEY_options"
144-
145- $diskd_cmd
146- rc=$?
147- if [ $rc = 0 ]; then
148- while ! diskd_monitor; do
149- ocf_log info "diskd still hasn't started yet. Waiting..."
150- sleep 1
151- done
152- exit $OCF_SUCCESS
153- fi
154-
155- ocf_log err "Could not run $diskd_cmd : rc=$rc"
156- exit $OCF_ERR_GENERIC
157-}
158-
159-diskd_stop() {
160- if [ ! -z "$OCF_RESKEY_oneshot" ]; then
161- if [ -f ${OCF_RESKEY_state} ]; then
162- rm ${OCF_RESKEY_state}
163- fi
164- return $OCF_SUCCESS
165- fi
166-
167- if [ -f $OCF_RESKEY_pidfile ]; then
168- pid=`cat $OCF_RESKEY_pidfile`
169- fi
170- if [ ! -z $pid ]; then
171- kill -TERM $pid
172- rc=$?
173-
174- if [ $rc = 0 -o $rc = 1 ]; then
175- rm $OCF_RESKEY_pidfile
176- del_attr_exit $OCF_SUCCESS
177- fi
178-
179- ocf_log err "Unexpected result from kill -TERM $pid: $rc"
180- del_attr_exit $OCF_ERR_GENERIC
181- fi
182- del_attr_exit $OCF_SUCCESS
183-}
184-
185-diskd_monitor() {
186- if [ ! -z "$OCF_RESKEY_oneshot" ]; then
187- if [ ! -f ${OCF_RESKEY_state} ]; then
188- return $OCF_NOT_RUNNING
189- fi
190- extras=""
191- if [ ! -z "$OCF_RESKEY_device" ]; then
192- extras="$extras -N $OCF_RESKEY_device"
193- fi
194- if [ ! -z "$OCF_RESKEY_write_dir" ]; then # write-dir
195- extras="$extras -w -d $OCF_RESKEY_write_dir"
196- fi
197- diskd_cmd="${HA_BIN}/diskd -o $extras $OCF_RESKEY_options"
198- echo $diskd_cmd
199- $diskd_cmd
200- rc=$?
201- if [ $rc = 0 ]; then
202- return $OCF_SUCCESS
203- fi
204- ocf_log err "Could not run $diskd_cmd : rc=$rc"
205- return $OCF_ERR_GENERIC
206- fi
207-
208- ## daemon
209- if [ -f $OCF_RESKEY_pidfile ]; then
210- pid=`cat $OCF_RESKEY_pidfile`
211- fi
212- if [ ! -z $pid ]; then
213- kill -0 $pid
214- if [ $? = 0 ]; then
215- return $OCF_SUCCESS
216- fi
217- fi
218- return $OCF_NOT_RUNNING
219-}
220-
221-diskd_validate() {
222-# Pidfile better be an absolute path
223- case $OCF_RESKEY_pidfile in
224- /*) ;;
225- *) ocf_log warn "You should have pidfile($OCF_RESKEY_pidfile) of absolute path!" ;;
226- esac
227-
228-# Check the interval
229- if ocf_is_decimal "$OCF_RESKEY_interval" && [ $OCF_RESKEY_interval -gt 0 ]; then
230- :
231- else
232- ocf_log err "Invalid interval $OCF_RESKEY_interval. It should be positive integer!"
233- exit $OCF_ERR_ARGS
234- fi
235-
236- echo "Validate OK"
237- return $OCF_SUCCESS
238-}
239-
240-if [ $# -ne 1 ]; then
241- diskd_usage
242- exit $OCF_ERR_ARGS
243-fi
244-
245-: ${OCF_RESKEY_options:=""}
246-: ${OCF_RESKEY_interval:="30"}
247-: ${OCF_RESKEY_name:="diskd"}
248-: ${OCF_RESKEY_CRM_meta_interval:=0}
249-: ${OCF_RESKEY_CRM_meta_globally_unique:="true"}
250-
251-if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then
252- : ${OCF_RESKEY_pidfile:="$HA_VARRUN/diskd-${OCF_RESKEY_name}"}
253-else
254- : ${OCF_RESKEY_pidfile:="$HA_VARRUN/diskd-${OCF_RESOURCE_INSTANCE}"}
255-fi
256-
257-if [ "x$OCF_RESKEY_state" = "x" ]; then
258- if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then
259- state="${HA_VARRUN}/diskd-${OCF_RESOURCE_INSTANCE}.state"
260-
261- # Strip off the trailing clone marker
262- OCF_RESKEY_state=`echo $state | sed s/:[0-9][0-9]*\.state/.state/`
263- else
264- OCF_RESKEY_state="${HA_VARRUN}/diskd-${OCF_RESOURCE_INSTANCE}.state"
265- fi
266-fi
267-
268-case $__OCF_ACTION in
269-meta-data) meta_data
270- exit $OCF_SUCCESS
271- ;;
272-start) diskd_start
273- ;;
274-stop) diskd_stop
275- ;;
276-monitor) diskd_monitor
277- ;;
278-validate-all) diskd_validate
279- ;;
280-usage|help) diskd_usage
281- exit $OCF_SUCCESS
282- ;;
283-*) diskd_usage
284- exit $OCF_ERR_UNIMPLEMENTED
285- ;;
286-esac
287-
288-exit $?
diff -r 510ff3f9d7a9 -r ffe13175a52b resources/diskd.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/resources/diskd.in Wed Feb 20 15:31:32 2013 +0900
@@ -0,0 +1,289 @@
1+#!/bin/sh
2+#
3+#
4+# diskd OCF Resource Agent
5+#
6+# This program is free software; you can redistribute it and/or modify
7+# it under the terms of version 2 of the GNU General Public License as
8+# published by the Free Software Foundation.
9+#
10+# This program is distributed in the hope that it would be useful, but
11+# WITHOUT ANY WARRANTY; without even the implied warranty of
12+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+#
14+# Further, this software is distributed without any warranty that it is
15+# free of the rightful claim of any third person regarding infringement
16+# or the like. Any license provided herein, whether implied or
17+# otherwise, applies only to this software file. Patent licenses, if
18+# any, provided herein do not apply to combinations of this program with
19+# other software, or any other product whatsoever.
20+#
21+# You should have received a copy of the GNU General Public License
22+# along with this program; if not, write the Free Software Foundation,
23+# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
24+#
25+#######################################################################
26+# Initialization:
27+
28+. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
29+: ${DISKD_DAEMON_DIR:=@CRM_DAEMON_DIR@}
30+
31+#######################################################################
32+
33+meta_data() {
34+ cat <<END
35+<?xml version="1.0"?>
36+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
37+<resource-agent name="diskd">
38+<version>1.0</version>
39+
40+<longdesc lang="en">
41+This is a diskd Resource Agent.
42+</longdesc>
43+<shortdesc lang="en">diskd resource agent</shortdesc>
44+
45+<parameters>
46+
47+<parameter name="pidfile" unique="0">
48+<longdesc lang="en">PID file</longdesc>
49+<shortdesc lang="en">PID file</shortdesc>
50+<content type="string" default="$HA_VARRUN/diskd-${OCF_RESOURCE_INSTANCE}" />
51+</parameter>
52+
53+<parameter name="name" unique="0">
54+<longdesc lang="en">
55+The name of the attributes to set. This is the name to be used in the constraints.
56+</longdesc>
57+<shortdesc lang="en">Attribute name</shortdesc>
58+<content type="string" default="${OCF_RESOURCE_INSTANCE}"/>
59+</parameter>
60+
61+<parameter name="device" unique="0">
62+<longdesc lang="en">
63+The name of device to check.
64+</longdesc>
65+<shortdesc lang="en">Device name</shortdesc>
66+<content type="string" default=""/>
67+</parameter>
68+
69+<parameter name="write_dir" unique="0">
70+<longdesc lang="en">
71+The name of directory name to write.
72+</longdesc>
73+<shortdesc lang="en">Directory name</shortdesc>
74+<content type="string" default=""/>
75+</parameter>
76+
77+<parameter name="oneshot" unique="0">
78+<longdesc lang="en">
79+Disk check only one time
80+</longdesc>
81+<shortdesc lang="en">oneshot</shortdesc>
82+<content type="string" default=""/>
83+</parameter>
84+
85+<parameter name="interval" unique="0">
86+<longdesc lang="en">
87+Disk status check interval time.
88+</longdesc>
89+<shortdesc lang="en">check interval</shortdesc>
90+<content type="integer" default="30"/>
91+</parameter>
92+
93+<parameter name="options" unique="0">
94+<longdesc lang="en">
95+A catch all for any other options that need to be passed to diskd.
96+</longdesc>
97+<shortdesc lang="en">Extra Options</shortdesc>
98+<content type="string" default=""/>
99+</parameter>
100+
101+</parameters>
102+
103+<actions>
104+<action name="start" timeout="60" />
105+<action name="stop" timeout="60" />
106+<action name="monitor" depth="0" timeout="60" interval="10" start-delay="1m" />
107+<action name="meta-data" timeout="5" />
108+<action name="validate-all" timeout="30" />
109+</actions>
110+</resource-agent>
111+END
112+}
113+
114+#######################################################################
115+
116+del_attr_exit() {
117+ typeset status=$1
118+ attrd_updater -D -n $OCF_RESKEY_name -q
119+ exit $status
120+}
121+
122+diskd_usage() {
123+ cat <<END
124+usage: $0 {start|stop|monitor|validate-all|meta-data}
125+
126+Expects to have a fully populated OCF RA-compliant environment set.
127+END
128+}
129+
130+diskd_start() {
131+ if [ ! -z "$OCF_RESKEY_oneshot" ]; then
132+ touch ${OCF_RESKEY_state}
133+ return $OCF_SUCCESS
134+ fi
135+
136+ extras=""
137+ if [ ! -z "$OCF_RESKEY_device" ]; then
138+ extras="$extras -N $OCF_RESKEY_device"
139+ fi
140+ if [ ! -z "$OCF_RESKEY_write_dir" ]; then # write-dir
141+ extras="$extras -w -d $OCF_RESKEY_write_dir"
142+ fi
143+
144+ diskd_cmd="${DISKD_DAEMON_DIR}/diskd -D -p $OCF_RESKEY_pidfile -a $OCF_RESKEY_name -i $OCF_RESKEY_interval $extras $OCF_RESKEY_options"
145+
146+ $diskd_cmd
147+ rc=$?
148+ if [ $rc = 0 ]; then
149+ while ! diskd_monitor; do
150+ ocf_log info "diskd still hasn't started yet. Waiting..."
151+ sleep 1
152+ done
153+ exit $OCF_SUCCESS
154+ fi
155+
156+ ocf_log err "Could not run $diskd_cmd : rc=$rc"
157+ exit $OCF_ERR_GENERIC
158+}
159+
160+diskd_stop() {
161+ if [ ! -z "$OCF_RESKEY_oneshot" ]; then
162+ if [ -f ${OCF_RESKEY_state} ]; then
163+ rm ${OCF_RESKEY_state}
164+ fi
165+ return $OCF_SUCCESS
166+ fi
167+
168+ if [ -f $OCF_RESKEY_pidfile ]; then
169+ pid=`cat $OCF_RESKEY_pidfile`
170+ fi
171+ if [ ! -z $pid ]; then
172+ kill -TERM $pid
173+ rc=$?
174+
175+ if [ $rc = 0 -o $rc = 1 ]; then
176+ rm $OCF_RESKEY_pidfile
177+ del_attr_exit $OCF_SUCCESS
178+ fi
179+
180+ ocf_log err "Unexpected result from kill -TERM $pid: $rc"
181+ del_attr_exit $OCF_ERR_GENERIC
182+ fi
183+ del_attr_exit $OCF_SUCCESS
184+}
185+
186+diskd_monitor() {
187+ if [ ! -z "$OCF_RESKEY_oneshot" ]; then
188+ if [ ! -f ${OCF_RESKEY_state} ]; then
189+ return $OCF_NOT_RUNNING
190+ fi
191+ extras=""
192+ if [ ! -z "$OCF_RESKEY_device" ]; then
193+ extras="$extras -N $OCF_RESKEY_device"
194+ fi
195+ if [ ! -z "$OCF_RESKEY_write_dir" ]; then # write-dir
196+ extras="$extras -w -d $OCF_RESKEY_write_dir"
197+ fi
198+ diskd_cmd="${DISKD_DAEMON_DIR}/diskd -o $extras $OCF_RESKEY_options"
199+ echo $diskd_cmd
200+ $diskd_cmd
201+ rc=$?
202+ if [ $rc = 0 ]; then
203+ return $OCF_SUCCESS
204+ fi
205+ ocf_log err "Could not run $diskd_cmd : rc=$rc"
206+ return $OCF_ERR_GENERIC
207+ fi
208+
209+ ## daemon
210+ if [ -f $OCF_RESKEY_pidfile ]; then
211+ pid=`cat $OCF_RESKEY_pidfile`
212+ fi
213+ if [ ! -z $pid ]; then
214+ kill -0 $pid
215+ if [ $? = 0 ]; then
216+ return $OCF_SUCCESS
217+ fi
218+ fi
219+ return $OCF_NOT_RUNNING
220+}
221+
222+diskd_validate() {
223+# Pidfile better be an absolute path
224+ case $OCF_RESKEY_pidfile in
225+ /*) ;;
226+ *) ocf_log warn "You should have pidfile($OCF_RESKEY_pidfile) of absolute path!" ;;
227+ esac
228+
229+# Check the interval
230+ if ocf_is_decimal "$OCF_RESKEY_interval" && [ $OCF_RESKEY_interval -gt 0 ]; then
231+ :
232+ else
233+ ocf_log err "Invalid interval $OCF_RESKEY_interval. It should be positive integer!"
234+ exit $OCF_ERR_ARGS
235+ fi
236+
237+ echo "Validate OK"
238+ return $OCF_SUCCESS
239+}
240+
241+if [ $# -ne 1 ]; then
242+ diskd_usage
243+ exit $OCF_ERR_ARGS
244+fi
245+
246+: ${OCF_RESKEY_options:=""}
247+: ${OCF_RESKEY_interval:="30"}
248+: ${OCF_RESKEY_name:="diskd"}
249+: ${OCF_RESKEY_CRM_meta_interval:=0}
250+: ${OCF_RESKEY_CRM_meta_globally_unique:="true"}
251+
252+if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then
253+ : ${OCF_RESKEY_pidfile:="$HA_VARRUN/diskd-${OCF_RESKEY_name}"}
254+else
255+ : ${OCF_RESKEY_pidfile:="$HA_VARRUN/diskd-${OCF_RESOURCE_INSTANCE}"}
256+fi
257+
258+if [ "x$OCF_RESKEY_state" = "x" ]; then
259+ if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then
260+ state="${HA_VARRUN}/diskd-${OCF_RESOURCE_INSTANCE}.state"
261+
262+ # Strip off the trailing clone marker
263+ OCF_RESKEY_state=`echo $state | sed s/:[0-9][0-9]*\.state/.state/`
264+ else
265+ OCF_RESKEY_state="${HA_VARRUN}/diskd-${OCF_RESOURCE_INSTANCE}.state"
266+ fi
267+fi
268+
269+case $__OCF_ACTION in
270+meta-data) meta_data
271+ exit $OCF_SUCCESS
272+ ;;
273+start) diskd_start
274+ ;;
275+stop) diskd_stop
276+ ;;
277+monitor) diskd_monitor
278+ ;;
279+validate-all) diskd_validate
280+ ;;
281+usage|help) diskd_usage
282+ exit $OCF_SUCCESS
283+ ;;
284+*) diskd_usage
285+ exit $OCF_ERR_UNIMPLEMENTED
286+ ;;
287+esac
288+
289+exit $?
Show on old repository browser