5
# Copyright (c) 2010 SUSE Linux Products GmbH, Lars Marowsky-Brée
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of version 2 of the GNU General Public License as
10
# published by the Free Software Foundation.
12
# This program is distributed in the hope that it would be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
# Further, this software is distributed without any warranty that it is
17
# free of the rightful claim of any third person regarding infringement
18
# or the like. Any license provided herein, whether implied or
19
# otherwise, applies only to this software file. Patent licenses, if
20
# any, provided herein do not apply to combinations of this program with
21
# other software, or any other product whatsoever.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write the Free Software Foundation,
25
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
28
#######################################################################
31
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
32
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
34
#######################################################################
39
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
40
<resource-agent name="fio" version="0.9">
41
<version>1.0</version>
44
fio is a generic I/O load generator. This RA allows start/stop of fio
45
instances to simulate load on a cluster without configuring complex
48
<shortdesc lang="en">fio IO load generator</shortdesc>
51
<parameter name="args">
53
Arguments to the fio client. Minimally, this should be a (list of) job
56
<shortdesc lang="en">fio arguments</shortdesc>
57
<content type="string" default="" />
63
<action name="start" timeout="60" />
64
<action name="stop" timeout="60" />
65
<action name="monitor" timeout="60" interval="10" />
66
<action name="meta-data" timeout="5" />
67
<action name="validate-all" timeout="20" />
73
#######################################################################
77
usage: $0 {start|stop|monitor|validate-all|meta-data}
83
if [ $rc = $OCF_SUCCESS ]; then
84
ocf_log "fio already running."
87
if [ $rc != $OCF_NOT_RUNNING ]; then
88
ocf_log info "fio apparently dead; cleaning up before restart"
91
fio $OCF_RESKEY_args >/dev/null 2>&1 </dev/null &
93
echo $fio_pid >${fio_state_file}
94
ocf_log info "fio started as pid=$fio_pid"
99
for sig in SIGINT SIGTERM SIGKILL ; do
103
ocf_log info "fio already stopped."
108
ocf_log "fio stopped and cleaned up."
112
if [ -n "$fio_pid" ]; then
113
ocf_log "Sending $sig to fio (pid=$fio_pid)"
118
ocf_log err "Internal logic failure in fio RA."
120
*) ocf_log err "Internal logic failure in fio RA."
124
ocf_log err "fio did not stop! Perhaps hung on IO?"
125
exit $OCF_ERR_GENERIC
129
fio_state_file="${HA_RSCTMP}/fio-${OCF_RESOURCE_INSTANCE}.state"
130
if [ ! -e $fio_state_file ]; then
131
return $OCF_NOT_RUNNING
133
fio_pid=`cat $fio_state_file`
135
if [ -z "$fio_pid" ]; then
136
ocf_log err "State file found, but empty. Assuming stopped."
137
return $OCF_NOT_RUNNING
140
ps=`ps h -o comm $fio_pid 2>&1`
141
if [ "$ps" != "fio" ]; then
143
return $OCF_ERR_GENERIC
152
case $__OCF_ACTION in
156
validate-all) fio_validate;;
157
usage|help) fio_usage
162
ocf_is_probe || check_binary fio
164
case $__OCF_ACTION in
167
monitor) fio_monitor;;
169
exit $OCF_ERR_UNIMPLEMENTED