3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of version 2 of the GNU General Public License as
5 # published by the Free Software Foundation.
7 # This program is distributed in the hope that it would be useful, but
8 # WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # Further, this software is distributed without any warranty that it is
12 # free of the rightful claim of any third person regarding infringement
13 # or the like. Any license provided herein, whether implied or
14 # otherwise, applies only to this software file. Patent licenses, if
15 # any, provided herein do not apply to combinations of this program with
16 # other software, or any other product whatsoever.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 #######################################################################
26 . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
28 L7SOCKFILE=${OCF_RESKEY_socket_default:-/var/run/l7vs/l7vs}
30 #######################################################################
35 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
36 <resource-agent name="L7vsd" version="1.0">
37 <version>1.0</version>
40 This is a L7vsd Resource Agent.
42 <shortdesc lang="en">L7vsd resource agent</shortdesc>
45 <parameter name="socket" unique="0" required="0">
47 The socket to be used for l7vsadm.
49 <shortdesc lang="en">l7vsadm socket</shortdesc>
50 <content type="string" default="${OCF_RESKEY_socket_default}"/>
55 <action name="start" timeout="60" />
56 <action name="stop" timeout="60" />
57 <action name="monitor" timeout="60" interval="10" depth="0" start-delay="0" />
58 <action name="meta-data" timeout="5" />
64 #######################################################################
68 usage: $0 {start|stop|monitor|meta-data}
73 ###############################
74 # Resource start Method
75 ###############################
77 ocf_log info "l7vsd is starting ..."
80 if [ $RET -eq $OCF_SUCCESS ]; then
81 ocf_log info "l7vsd is already running."
83 elif [ $RET -eq $OCF_NOT_RUNNING ]; then
84 L7SOCKDIR=`dirname L7SOCKFILE`
85 if [ ! -d $L7SOCKDIR ] ; then
86 ocf_log info "Creating l7vsadm socket dir: $L7SOCKDIR"
89 if [ -e $L7SOCKFILE ] ; then
90 ocf_log info "Delete l7vsadm socket filer: $L7SOCKFILE"
93 /usr/sbin/l7vsd > /dev/null 2>&1
95 if [ $RET -ne 0 ]; then
96 MSG="l7vsd start error!"
97 outputLog err ${OCF_ERR_GENERIC} $MSG
98 return $OCF_ERR_GENERIC
101 if [ $? -eq $OCF_SUCCESS ]; then
103 ocf_log info "l7vsd starts."
107 MSG="l7vsd does not work. (ps=$RET) "
108 outputLog err ${OCF_ERR_GENERIC} ${MSG}
109 return $OCF_ERR_GENERIC
112 ###############################
113 # Resource stop Method
114 ###############################
116 ocf_log info "l7vsd stopping ..."
119 if [ $RET -eq $OCF_NOT_RUNNING ]; then
120 ocf_log info "l7vsd stopped."
123 pkill -f "/usr/sbin/l7vsd"
125 while [ $count -le 10 ]
129 if [ $RET -eq $OCF_NOT_RUNNING ]; then
130 ocf_log info "l7vsd stopped."
133 count=`expr $count + 1`
142 ###############################
144 ###############################
150 ocf_log $MODE "[$0 ${__OCF_ACTION}] OK;return=$RET" "$@";;
152 ocf_log $MODE "[$0 ${__OCF_ACTION}] NG;return=$RET" "$@";;
156 ###############################
158 ###############################
160 pkill -9 -f "/usr/sbin/l7vsd"
161 ocf_log info "kill l7vsd process!"
167 if [ $RET -eq $OCF_NOT_RUNNING ]; then
169 ocf_log info "l7vsd process stopped!"
175 ###############################
176 # Get Resource Status Method
177 ###############################
180 RET=`pgrep -fox "/usr/sbin/l7vsd" | wc -l`
181 if [ $RET -eq 1 ]; then
183 elif [ $RET -eq 0 ]; then
184 MSG="l7vsd is not running."
185 outputLog $loglevel ${OCF_NOT_RUNNING} ${MSG}
186 return $OCF_NOT_RUNNING
188 MSG="l7vsd status ERROR!: (ps=$RET)"
189 outputLog err ${OCF_ERR_GENERIC} ${MSG}
190 return $OCF_ERR_GENERIC
194 ###############################
195 # Get Resource Monitor Method
196 ###############################
200 if ocf_is_probe; then
206 if [ $RET -eq $OCF_SUCCESS ]; then
209 elif [ $RET -eq $OCF_NOT_RUNNING ]; then
211 return $OCF_NOT_RUNNING
213 MSG="l7vsd duplicated. "
214 outputLog err ${OCF_ERR_GENERIC} ${MSG}
215 return $OCF_ERR_GENERIC
218 case $__OCF_ACTION in
223 monitor) l7vsd_monitor;;
224 usage|help) l7vsd_usage
228 exit $OCF_ERR_UNIMPLEMENTED
233 ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"