44 hours ago
Low: RA: iSCSITarget, iSCSILogicalUnit: remove useless "return" after check_binary
Minor cleanup for the iSCSITarget and iSCSILogicalUnit RAs:
check_binary exits with $OCF_ERR_INSTALLED if the requested binary is
not found. Thus the useless return statements after check_binary in
validate-all can be removed.
1 #!/bin/sh
2 #
3 #
4 # ids
5 #
6 # Description:
7 #
8 # OCF resource agent that manages an
9 # IBM Informix Dynamic Server (IDS) instance
10 # as an High-Availability resource.
11 ####
12 #
13 # Author: Lars D. Forseth, <lars.forseth@de.ibm.com> or <lars@forseth.de>
14 # Created: May 25th 2007
15 # Last Modified: July 30th 2007
16 # Support: linux-ha@lists.linux-ha.org
17 # License: GNU General Public License (GPL), Version 2 or later
18 # Copyright: (c) 2002 - 2007 International Business Machines, Inc.
19 #
20 # This code is inspired by the db2 OCF resource agent
21 # written by Alan Robertson, <alanr@unix.sh>
22 ####
23 #
24 # This program is free software; you can redistribute it and/or modify
25 # it under the terms of the GNU General Public License as published by
26 # the Free Software Foundation; either version 2 of the License, or
27 # (at your option) any later version.
29 #
30 # This program is distributed in the hope that it would be useful, but
31 # WITHOUT ANY WARRANTY; without even the implied warranty of
32 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
33 #
34 # Further, this software is distributed without any warranty that it is
35 # free of the rightful claim of any third person regarding infringement
36 # or the like. Any license provided herein, whether implied or
37 # otherwise, applies only to this software file. Patent licenses, if
38 # any, provided herein do not apply to combinations of this program with
39 # other software, or any other product whatsoever.
40 #
41 # You should have received a copy of the GNU General Public License
42 # along with this program; if not, write the Free Software Foundation,
43 # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
44 ####
45 #
46 # Example usage as it would appear in /etc/ha.d/haresources:
47 # node1 192.168.0.1 ids::/informix::ids1::onconfig.ids1
48 #
49 #
50 # --> Note that passing dbname and sqltestquery in heartbeat version 1 style is not supported!
51 #
52 # See usage() function below for more details...
53 ####
54 #
55 # OCF instance parameters:
56 # OCF_RESKEY_informixdir
57 # OCF_RESKEY_informixserver
58 # OCF_RESKEY_onconfig
59 # OCF_RESKEY_dbname
60 # OCF_RESKEY_sqltestquery
61 ####
64 #
65 # Include general OCF functions and variables (such as OCF return codes).
66 #
67 . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
70 #
71 # Function that displays the usage of this script.
72 #
73 ids_usage() {
74 methods=`ids_methods`
75 methods=`echo $methods | tr ' ' '|'`
77 echo "
78 usage: $0 ($methods)
80 $0 manages an IBM Informix Dynamic Server (IDS) instance as an High-Availability resource.
82 The 'start' operation starts the database.
83 The 'stop' operation stops the database.
84 The 'status' operation reports whether the database is running
85 The 'monitor' operation reports whether the database seems to be working
86 The 'validate-all' operation reports whether the parameters are valid
87 The 'methods' operation lists the methods $0 supports
88 The 'usage' operation displays this text
89 The 'meta-data' operation returns the meta-data (in XML) of this resource script
90 "
91 }
94 #
95 # Function that displays the possible methods this script supports.
96 #
97 ids_methods() {
98 echo "
99 start
100 stop
101 status
102 monitor
103 validate-all
104 methods
105 usage
106 meta-data
107 "
108 }
111 #
112 # Function that displays the meta-data of this OCF resource agent.
113 #
114 ids_meta_data() {
115 cat <<-!
116 <?xml version="1.0"?>
117 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
118 <resource-agent name="ids">
119 <version>1.0</version>
122 <longdesc lang="en">
123 OCF resource agent to manage an IBM Informix Dynamic Server (IDS) instance as an High-Availability resource.
124 </longdesc>
125 <shortdesc lang="en">OCF resource agent for the IBM's database server called Informix Dynamic Server (IDS)</shortdesc>
128 <parameters>
130 <parameter name="informixdir" required="0">
131 <longdesc lang="en">
132 The value the environment variable INFORMIXDIR has after a typical installation of IDS.
133 Or in other words: the path (without trailing '/') where IDS was installed to.
134 If this parameter is unspecified the script will try to get the value from the shell environment.
135 </longdesc>
136 <shortdesc lang="en">
137 INFORMIXDIR environment variable
138 </shortdesc>
139 <content type="string" default="" />
140 </parameter>
142 <parameter name="informixserver" required="0">
143 <longdesc lang="en">
144 The value the environment variable INFORMIXSERVER has after a typical installation of IDS.
145 Or in other words: the name of the IDS server instance to manage.
146 If this parameter is unspecified the script will try to get the value from the shell environment.
147 </longdesc>
148 <shortdesc lang="en">
149 INFORMIXSERVER environment variable
150 </shortdesc>
151 <content type="string" default="" />
152 </parameter>
154 <parameter name="onconfig" required="0">
155 <longdesc lang="en">
156 The value the environment variable ONCONFIG has after a typical installation of IDS.
157 Or in other words: the name of the configuration file for the IDS instance specified in INFORMIXSERVER.
158 The specified configuration file will be searched at '$INFORMIXDIR/etc/$ONCONFIG'.
159 If this parameter is unspecified the script will try to get the value from the shell environment.
160 </longdesc>
161 <shortdesc lang="en">
162 ONCONFIG environment variable
163 </shortdesc>
164 <content type="string" default="" />
165 </parameter>
167 <parameter name="dbname" required="0">
168 <longdesc lang="en">
169 This parameter defines which database to use in order to monitor the IDS instance.
170 If this parameter is unspecified the script will use the 'sysmaster' database as a default.
171 </longdesc>
172 <shortdesc lang="en">
173 database to use for monitoring, defaults to 'sysmaster'
174 </shortdesc>
175 <content type="string" default="sysmaster" />
176 </parameter>
178 <parameter name="sqltestquery" required="0">
179 <longdesc lang="en">
180 SQL test query to run on the database specified by the parameter 'dbname'
181 in order to monitor the IDS instance and determine if it's functional or not.
182 If this parameter is unspecified the script will use 'SELECT COUNT(*) FROM systables;' as a default.
183 </longdesc>
184 <shortdesc lang="en">
185 SQL test query to use for monitoring, defaults to 'SELECT COUNT(*) FROM systables;'
186 </shortdesc>
187 <content type="string" default="SELECT COUNT(*) FROM systables;" />
188 </parameter>
190 </parameters>
193 <actions>
194 <action name="start" timeout="120" />
195 <action name="stop" timeout="120" />
196 <action name="status" timeout="60" />
197 <action name="monitor" depth="0" timeout="30" interval="10" start-delay="0" />
198 <action name="validate-all" timeout="5" />
199 <action name="meta-data" timeout="5" />
200 <action name="methods" timeout="5" />
201 <action name="usage" timeout="5" />
202 </actions>
205 </resource-agent>
206 !
207 }
210 #
211 # Function that either forwards log messages to the ocf_log function
212 # provided by heartbeat or simply prints them to standard out via echo.
213 # This is determined by setting the variable "idslogger" to "echo" or "ocf".
214 # The default for "idslogger" is "ocf".
215 #
216 ids_log() {
218 # Where should the passed log messages be passed to,
219 # to the standard output via the echo command ("echo")
220 # or to the ocf_log function provided by heartbeat ("ocf") ?
221 # Default is "ocf".
222 idslogger="ocf"
224 # When the variable "idsdebug" is not set to "true"
225 # this function (ids_log) will not print any info message
226 # that has been forwarded to it!
227 # This is done in order to spare if-statements within the
228 # other functions in this script and to centralize the decision
229 # whether to have a chatty resource script or not... ;)
230 # Nevertheless, error messages will always be printed!
231 idsdebug=false
233 # Only continue if the two expected parameters
234 # are not empty and "idsdebug" is set to "true"
235 # or the message is of type "error".
236 if [ $# -eq 2 -a -n "$1" -a -n "$2" ]; then
237 if [ "$idsdebug" = "true" -o "$1" = "error" ]; then
238 case $idslogger in
239 # Print messages to stdout via echo command.
240 echo)
241 echo "`date +'%b %d %H:%M:%S'`: [$1] $2";;
242 # Pass messages to ocf_log function.
243 ocf|*)
244 ocf_log "$1" "$2";;
245 esac
246 fi
247 fi
248 }
251 #
252 # Function that prints the current values of important environment variables
253 # needed by the script and the IDS instance itself. The just mentioned variables are:
254 # - INFORMIXDIR
255 # - INFORMIXSERVER
256 # - ONCONFIG
257 # - PATH
258 # - LD_LIBRARY_PATH
259 #
260 ids_debug() {
261 ids_log info "called ids_debug"
263 ids_log info "INFORMIXDIR=$INFORMIXDIR"
264 ids_log info "OCF_RESKEY_informixdir=$OCF_RESKEY_informixdir"
266 ids_log info "INFORMIXSERVER=$INFORMIXSERVER"
267 ids_log info "OCF_RESKEY_informixserver=$OCF_RESKEY_informixserver"
269 ids_log info "ONCONFIG=$ONCONFIG"
270 ids_log info "OCF_RESKEY_onconfig=$OCF_RESKEY_onconfig"
272 ids_log info "PATH=$PATH"
273 ids_log info "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
275 ids_log info "dbname=$OCF_RESKEY_dbname"
276 ids_log info "sqltestquery=$OCF_RESKEY_sqltestquery"
278 ids_log info "this script is run as user: `id`"
279 ids_log info "...in the current working directory: `pwd`"
280 }
283 #
284 # Function that validates if the passed parameters are valid and sets them if valid.
285 # If the first three parameters have not been passed,
286 # this function checks whether they have been already set in the parent's shell environment.
287 # The variables that are checked and set (only the capitalized ones are set) are:
288 # - INFORMIXDIR
289 # - INFORMIXSERVER
290 # - ONCONFIG
291 # - PATH
292 # - LD_LIBRARY_PATH
293 # - dbname
294 # - sqltestquery
295 #
296 ids_validate() {
298 ids_log info "called ids_validate"
299 rc=$OCF_SUCCESS
301 # Check if INFORMIX, INFORMIXSERVER and ONCONFIG
302 # have been passed or set and validate them.
304 # OCF vars not passed, vars empty - set and export them to the shell environment.
305 if [ -n "$OCF_RESKEY_informixdir" -a -n "$OCF_RESKEY_informixserver" -a -n "$OCF_RESKEY_onconfig" ]; then
306 ids_log info "ids_validate: passed vars not empty"
308 INFORMIXDIR=$OCF_RESKEY_informixdir
309 export INFORMIXDIR
311 INFORMIXSERVER=$OCF_RESKEY_informixserver
312 export INFORMIXSERVER
314 ONCONFIG=$OCF_RESKEY_onconfig
315 export ONCONFIG
316 fi
318 # Check if INFORMIXDIR is non-empty and a directory (and if there was an error so far).
319 if [ $rc -eq $OCF_SUCCESS -a -n "$INFORMIXDIR" -a -d "$INFORMIXDIR" ]; then
320 ids_log info "ids_validate: INFORMIXDIR is valid: $INFORMIXDIR"
321 rc=$OCF_SUCCESS
322 else
323 ids_log error "ids_validate: INFORMIXDIR is invalid: $INFORMIXDIR"
324 rc=$OCF_ERR_ARGS
325 fi
327 # Check if INFORMIXSERVER is non-empty (and if there was an error so far).
328 if [ $rc -eq $OCF_SUCCESS -a -n "$INFORMIXSERVER" ]; then
329 ids_log info "ids_validate: INFORMIXSERVER is valid: $INFORMIXSERVER"
330 rc=$OCF_SUCCESS
331 else
332 ids_log error "ids_validate: INFORMIXSERVER is invalid: $INFORMIXSERVER"
333 rc=$OCF_ERR_ARGS
334 fi
336 # Check if ONCONFIG is non-empty and a non-empty file (and if there was an error so far).
337 if [ $rc -eq $OCF_SUCCESS -a -n "$ONCONFIG" -a -s "$INFORMIXDIR/etc/$ONCONFIG" ]; then
338 ids_log info "ids_validate: ONCONFIG is a non-empty file in: \$INFORMIXDIR/etc/\$ONCONFIG where ONCONFIG=$ONCONFIG"
339 rc=$OCF_SUCCESS
340 else
341 if [ -z "$ONCONFIG" -a -s "$INFORMIXDIR/etc/onconfig" ]; then
342 ONCONFIG="onconfig"
343 export ONCONFIG
344 ids_log info "ids_validate: ONCONFIG is a non-empty file in: \$INFORMIXDIR/etc/\$ONCONFIG where ONCONFIG=$ONCONFIG"
345 rc=$OCF_SUCCESS
346 else
347 if [ -z "$ONCONFIG" -a -s "$INFORMIXDIR/etc/onconfig.std" ]; then
348 ONCONFIG="onconfig.std"
349 export ONCONFIG
350 ids_log info "ids_validate: ONCONFIG is a non-empty file in: \$INFORMIXDIR/etc/\$ONCONFIG where ONCONFIG=$ONCONFIG"
351 rc=$OCF_SUCCESS
352 else
353 ids_log error "ids_validate: ONCONFIG is invalid, searched for it in: \$INFORMIXDIR/etc/\$ONCONFIG where ONCONFIG=$ONCONFIG"
354 rc=$OCF_ERR_ARGS
355 fi
356 fi
357 fi
359 # Check if the commands oninit, onstat, onmode and dbaccess exist in INFORMIXDIR/bin/
360 # and whether they are executable (do this only if there wasn't an error so far).
361 if [ $rc -eq $OCF_SUCCESS -a -x "$INFORMIXDIR/bin/oninit" -a -x "$INFORMIXDIR/bin/onstat" -a -x "$INFORMIXDIR/bin/onmode" -a -x "$INFORMIXDIR/bin/dbaccess" ]; then
362 ids_log info "ids_validate: oninit, onstat and dbaccess exist and are executable in: \$INFORMIXDIR/bin/"
363 rc=$OCF_SUCCESS
364 else
365 ids_log error "ids_validate: oninit, onstat or dbacces don't exist or they are not executable in: \$INFORMIXDIR/bin/"
366 rc=$OCF_ERR_PERM
367 fi
369 # Extend PATH and LD_LIBRARY_PATH as needed for the IDS instance to run properly
370 # BUT: only do this if it hasn't been done before! Otherwise PATH and LD_LIBRARY_PATH will
371 # keep on growing every time heartbeat calls the IDS resource agent script! ;)
372 echo $PATH | grep $INFORMIXDIR > /dev/null 2>&1
373 inpath=$?
375 if [ $rc -eq $OCF_SUCCESS -a $inpath -ne 0 ]; then
376 PATH="${INFORMIXDIR}/bin":${PATH}
377 export PATH
378 ids_log info "ids_validate: PATH did not contain INFORMIXDIR, added \$INFORMIXDIR/bin"
379 else
380 ids_log info "ids_validate: INFORMIXDIR already in PATH, where PATH=$PATH"
381 fi
383 echo $LD_LIBRARY_PATH | grep $INFORMIXDIR > /dev/null 2>&1
384 inldlibpath=$?
386 if [ $rc -eq $OCF_SUCCESS -a $inldlibpath -ne 0 ]; then
387 LD_LIBRARY_PATH="${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql"
388 export LD_LIBRARY_PATH
389 ids_log info "ids_validate: LD_LIBRARY_PATH did not contain INFORMIXDIR, added \$INFORMIXDIR/lib and \$INFORMIXDIR/lib/esql, added them"
390 else
391 ids_log info "ids_validate: INFORMIXDIR already in LD_LIBRARY_PATH, where LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
392 fi
394 # Check if dbname is empty (and if there was an error so far)
395 # if it is empty, assign default.
396 if [ $rc -eq $OCF_SUCCESS -a -n "$OCF_RESKEY_dbname" ]; then
397 ids_log info "ids_validate: dbname is valid: $OCF_RESKEY_dbname"
398 rc=$OCF_SUCCESS
399 else
400 ids_log info "ids_validate: dbname is invalid: $OCF_RESKEY_dbname"
401 ids_log info "ids_validate: using 'sysmaster' as default..."
402 OCF_RESKEY_dbname="sysmaster"
403 export OCF_RESKEY_dbname
404 rc=$OCF_SUCCESS
405 fi
407 # Check if sqltestquery is empty (and if there was an error so far)
408 # if it is empty, assign default.
409 if [ $rc -eq $OCF_SUCCESS -a -n "$OCF_RESKEY_sqltestquery" ]; then
410 ids_log info "ids_validate: sqltestquery is valid: $OCF_RESKEY_sqltestquery"
411 rc=$OCF_SUCCESS
412 else
413 ids_log info "ids_validate: sqltestquery is invalid: $OCF_RESKEY_sqltestquery"
414 ids_log info "ids_validate: using 'SELECT COUNT(*) FROM systables;' as default..."
415 OCF_RESKEY_sqltestquery="SELECT COUNT(*) FROM systables;"
416 export OCF_RESKEY_sqltestquery
417 rc=$OCF_SUCCESS
418 fi
420 # Return exit status code.
421 return $rc
422 }
425 #
426 # Function that start the IDS instance and reports any error that
427 # may occur while starting.
428 #
429 ids_start() {
431 ids_log info "called ids_start"
433 # Get current status of IDS instance.
434 ids_status
435 stat=$?
437 case $stat in
439 # IDS instance already running - exit with success.
440 $OCF_SUCCESS)
441 ids_log info "ids_start: IDS instance already running: $stat"
442 rc=$OCF_SUCCESS;;
444 # IDS instance in undefined state - exit with error.
445 $OCF_ERR_GENERIC)
446 ids_log error "ids_start: IDS instance in undefined state: $stat"
447 ids_debug
448 rc=$OCF_ERR_GENERIC;;
450 # IDS instance not running - try to start it.
451 $OCF_NOT_RUNNING)
452 ids_log info "ids_start: executing 'oninit' now..."
453 oninit
454 stat=$?
455 ids_log info "ids_start: done executing 'oninit': $stat"
457 # The oninit command terminated successfully - check new state of IDS instance.
458 if [ $stat -eq 0 ]; then
459 # Initialize stat with failure exit status code.
460 stat=$OCF_ERR_GENERIC
461 # Endless loop that waits until IDS is completely online.
462 # If IDS takes too long to achieve this or even hangs,
463 # the timeout settings of heartbeat will cancel the starting
464 # of the IDS resource and therefore terminate the loop.
465 while [ $stat -ne $OCF_SUCCESS ]; do
466 ids_status
467 stat=$?
468 done
469 # IDS is running now - success.
470 ids_log info "ids_start: IDS instance successfully started: $stat"
471 rc=$OCF_SUCCESS
472 # The oninit command terminated with an error - starting the IDS resource failed!
473 else
474 ids_log error "ids_start: starting IDS instance failed: $stat"
475 ids_debug
476 rc=$OCF_ERR_GENERIC
477 fi
478 ;;
480 # Unexpected state - return OCF_ERR_UNIMPLEMENTED error.
481 *)
482 ids_log error "ids_start: unexpected state returned from ids_status: $stat"
483 ids_debug
484 rc=$OCF_ERR_UNIMPLEMENTED;;
486 esac
488 # Return exit status code.
489 return $rc
490 }
493 #
494 # Function that stops the IDS instance and reports any error that
495 # may occur while stopping.
496 #
497 ids_stop() {
499 ids_log info "caled ids_stop"
501 ids_status
502 stat=$?
504 case $stat in
506 # IDS instance is not running - success stopping it.
507 $OCF_NOT_RUNNING)
508 ids_log info "ids_stop: IDS instance is not running: $stat"
509 rc=$OCF_SUCCESS;;
511 # IDS instance is in an undefined state - exit with error.
512 $OCF_ERR_GENERIC)
513 ids_log error "ids_stop: IDS instance in undefined state: $stat"
514 ids_debug
515 rc=$OCF_ERR_GENERIC;;
517 # IDS instance is running - try to stop it.
518 $OCF_SUCCESS)
519 ids_log info "ids_stop: running 'onmode -kuy' now..."
520 onmode -kuy
521 stat=$?
522 ids_log info "ids_stop: done running 'onmode -kuy' now: $stat"
524 # The onmode command terminated successfully - check new state of the IDS instance.
525 if [ $stat -eq 0 ]; then
526 ids_status
527 stat=$?
528 # New state is: not running - success.
529 if [ $stat -eq $OCF_NOT_RUNNING ]; then
530 ids_log info "ids_stop: IDS instance successfully stopped: $stat"
531 rc=$OCF_SUCCESS
532 # New state is: running or even undefined - failure!
533 else
534 ids_log error "ids_stop: stopping IDS instance failed: $stat"
535 ids_debug
536 rc=$OCF_ERR_GENERIC
537 fi
539 # The onmode command terminated with an error - stopping the IDS resource failed!
540 else
541 ids_log error "ids_stop: stopping IDS instance (by executing 'onmode -kuy') failed: $stat"
542 ids_debug
543 rc=$OCF_ERR_GENERIC
544 fi
545 ;;
547 # Unexpected state - return OCF_ERR_UNIMPLEMENTED error.
548 *)
549 ids_log error "ids_stop: unexpected state returned from ids_status: $stat"
550 ids_debug
551 rc=$OCF_ERR_UNIMPLEMENTED;;
553 esac
555 # Return exit status code indicating whether IDS was successfully stopped or not.
556 return $rc
557 }
560 #
561 # Function that determines the current status/state of the IDS instance,
562 # meaning whether it is running (the case when output of "onstat -" contains "On-Line"),
563 # not running (the case when output of "onstat -" contains "shared memory not initialized")
564 # or in an undefined state (the case output of "onstat -" contains "Quiescent", "Single-User", or other).
565 # If the IDS instance is declared running the exit status code will indicate succes, otherwise failure of course.
566 #
567 ids_status() {
569 ids_log info "called ids_status"
571 # Get current status from the onstat tool and store it.
572 stat=`onstat -`
574 case $stat in
576 # IDS instance is running.
577 *"On-Line"*)
578 ids_log info "ids_status: IDS instance running: $stat"
579 rc=$OCF_SUCCESS;;
581 # IDS instance is not running.
582 *"shared memory not initialized"*)
583 ids_log info "ids_status: IDS instance not running: $stat"
584 rc=$OCF_NOT_RUNNING;;
586 # IDS instance is in an undefined state!
587 *)
588 ids_log error "ids_status: IDS instance status undefined: $stat"
589 rc=$OCF_ERR_GENERIC;;
590 esac
592 # Return exit status code (ergo current status of the IDS instance) to caller
593 return $rc
594 }
597 #
598 # Function that monitors the current status _and_ funtionality of the IDS instance.
599 # First the state of the instance is determined. If it is running, a sql test query is
600 # executed on the database. If the sql test query executes sucessfully, the instance's
601 # status is rechecked and if it is still running, the script terminates with an exit
602 # status code indicating success. If any of the above described steps fails,
603 # the script terminates with an error.
604 #
605 ids_monitor() {
607 ids_log info "called ids_monitor"
609 ids_status
610 stat=$?
612 case $stat in
614 # IDS instance is not running - monitoring failed.
615 $OCF_NOT_RUNNING)
616 ids_log info "ids_monitor: IDS instance is not running: $stat"
617 rc=$OCF_NOT_RUNNING;;
619 # IDS instance in an undefined state - exit with error.
620 $OCF_ERR_GENERIC)
621 ids_log error "ids_monitor: IDS instance in undefined state: $stat"
622 ids_debug
623 rc=$OCF_ERR_GENERIC;;
625 # IDS instance is running - try to execute the sql test query and recheck state.
626 $OCF_SUCCESS)
627 ids_log info "ids_monitor: IDS instance is running (before executing sql test query)"
628 ids_log info "ids_monitor: running sql test query now..."
629 echo $OCF_RESKEY_sqltestquery | dbaccess $OCF_RESKEY_dbname - > /dev/null 2>&1
630 stat=$?
631 ids_log info "ids_monitor: done running sql test query now: $stat"
633 # The sql test query terminated successfully - check the new state of the IDS instance.
634 if [ $stat -eq 0 ]; then
635 ids_status
636 stat=$?
637 # New state is: running - success.
638 if [ $stat -eq $OCF_SUCCESS ]; then
639 ids_log info "ids_monitor: successfully ran sql test query on IDS instance: $stat"
640 rc=$OCF_SUCCESS
641 # New state is: not running or even undefined - failure!
642 else
643 ids_log error "ids_monitor: running sql test query on IDS instance failed: $stat"
644 ids_debug
645 rc=$OCF_ERR_GENERIC
646 fi
648 # The sql test query terminated with an error - exit with error!
649 else
650 ids_log error "ids_monitor: running sql test query on IDS instance failed: $stat"
651 ids_debug
652 rc=$OCF_ERR_GENERIC
653 fi
654 ;;
656 # Unexpected state - return OCF_ERR_UNIMPLEMENTED error!
657 *)
658 ids_log error "ids_monitor: unexpected state returned from ids_status: $stat"
659 ids_debug
660 rc=$OCF_ERR_UNIMPLEMENTED;;
662 esac
664 # Return exit status code indicating whether IDS is running and functional or not.
665 return $rc
666 }
671 ###
672 #
673 # M A I N S E C T I O N
674 #
675 ###
677 case "$1" in
678 usage)
679 ids_usage
680 exit $?;;
681 meta-data)
682 ids_meta_data
683 exit $?;;
684 esac
686 # Validate configuration (parameters and such)
687 # passed to this script and only process the method parameter
688 # if the configuration is valid! Otherwise exit with OCF_ERR_ARGS error code.
690 # Only check configuration when given method is not "validate-all",
691 # as in case of "validate-all" the configuration will be checked anyway! ;)
692 if [ "$1" != "validate-all" ]; then
693 ids_validate
694 valid=$?
695 ids_log info "main section: validated ids RA configuration, result: $valid"
697 # Configuration invalid - terminate with error message.
698 if [ $valid -ne $OCF_SUCCESS ]; then
699 ids_log error "main section: terminating script due to invalid configuration"
700 ids_debug
701 exit $OCF_ERR_ARGS
702 fi
703 fi
705 # Configuration valid or method equals to "validate-all" - react depending on called method.
706 case "$1" in
708 start)
709 ids_start
710 exit $?;;
712 stop)
713 ids_stop
714 exit $?;;
716 status)
717 ids_status
718 exit $?;;
720 monitor)
721 ids_monitor
722 exit $?;;
724 validate-all)
725 ids_validate
726 exit $?;;
728 methods)
729 ids_methods
730 exit $?;;
732 *)
733 ids_log error "mainsection: no or invalid command supplied: $1"
734 exit $OCF_ERR_UNIMPLEMENTED;;
736 esac
737 ###############################################################################