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
27 #. /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs
29 #######################################################################
34 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
35 <resource-agent name="L7vsd" version="1.0">
36 <version>1.0</version>
39 This is a L7vsd Resource Agent.
41 <shortdesc lang="en">L7vsd resource agent</shortdesc>
47 <action name="start" timeout="60" />
48 <action name="stop" timeout="60" />
49 <action name="monitor" timeout="60" interval="10" depth="0" start-delay="0" />
50 <action name="meta-data" timeout="5" />
56 #######################################################################
60 usage: $0 {start|stop|monitor|meta-data}
65 ###############################
66 # Resource start Method
67 ###############################
69 ocf_log info "l7vsd is starting ..."
72 if [ $RET -eq $OCF_SUCCESS ]; then
73 ocf_log info "l7vsd is already running."
75 elif [ $RET -eq $OCF_NOT_RUNNING ]; then
76 /etc/init.d/l7vsd start > /dev/null 2>&1
78 if [ $RET -ne 0 ]; then
79 MSG="l7vsd start error!"
80 outputLog err ${OCF_ERR_GENERIC} $MSG
81 return $OCF_ERR_GENERIC
84 if [ $? -eq $OCF_SUCCESS ]; then
86 ocf_log info "l7vsd starts."
90 MSG="l7vsd does not work. (ps=$RET) "
91 outputLog err ${OCF_ERR_GENERIC} ${MSG}
92 return $OCF_ERR_GENERIC
95 ###############################
96 # Resource stop Method
97 ###############################
99 ocf_log info "l7vsd stopping ..."
102 if [ $RET -eq 0 ]; then
103 ocf_log info "l7vsd stopped."
106 /etc/init.d/l7vsd stop > /dev/null 2>&1
108 while [ $count -le 10 ]
112 if [ $RET -eq 0 ]; then
113 ocf_log info "l7vsd stopped."
116 count=`expr $count + 1`
124 ###############################
126 ###############################
132 ocf_log $MODE "[$0 ${__OCF_ACTION}] OK;return=$RET" "$@";;
134 ocf_log $MODE "[$0 ${__OCF_ACTION}] NG;return=$RET" "$@";;
138 ###############################
140 ###############################
142 pkill -9 -f "/usr/sbin/l7vsd"
143 ocf_log info "kill l7vsd process!"
149 if [ $RET -eq 0 ]; then
151 ocf_log info "l7vsd process stopped!"
157 ###############################
158 # Resource Running Check Method
159 ###############################
162 RET=`ps -ef | grep /usr/sbin/l7vsd | grep -v grep | wc -l`
166 ###############################
167 # Get Resource Status Method
168 ###############################
170 /etc/init.d/l7vsd status > /dev/null 2>&1
172 if [ $RET -eq 0 ]; then
175 MSG="l7vsd status ERROR!: $RET"
176 outputLog err ${OCF_ERR_GENERIC} ${MSG}
177 return $OCF_ERR_GENERIC
181 ###############################
182 # Get Resource Monitor Method
183 ###############################
187 if [ $RET -eq 1 ]; then
190 if [ $? -eq $OCF_SUCCESS ]; then
196 elif [ $RET -eq 0 ]; then
197 MSG="l7vsd is not running."
198 outputLog err ${OCF_NOT_RUNNING} ${MSG}
199 return $OCF_NOT_RUNNING
201 MSG="l7vsd does not work. (ps=$RET) "
202 outputLog err ${OCF_ERR_GENERIC} ${MSG}
203 return $OCF_ERR_GENERIC
206 case $__OCF_ACTION in
211 monitor) l7vsd_monitor;;
212 usage|help) l7vsd_usage
216 exit $OCF_ERR_UNIMPLEMENTED
221 ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"