1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the License).
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/CDDL.txt
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/CDDL.txt.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets [] replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  22 # Use is subject to license terms.
  23 #
  24 #ident   "%Z%%M% %I%     %E% SMI"
  25 #
  26 
  27 PKG=SUNWscids
  28 LOGFILE=/var/tmp/${RESOURCE}_logfile
  29 TASK_COMMAND=""
  30 RESOURCE_PROJECT_NAME=""
  31 SCLOGGER=/usr/cluster/lib/sc/scds_syslog
  32 LOGGER=/usr/bin/logger
  33 
  34 syslog_tag()
  35 {
  36         ${SET_DEBUG}
  37         print "SC[${PKG:-??}.${COMPONENT:-??}.${METHOD:-??}]:${RESOURCEGROUP:-??}:${RESOURCE:-??}"
  38 }
  39 
  40 scds_syslog()
  41 {
  42         if [ -f "${SCLOGGER}" ]
  43         then
  44            ${SCLOGGER} "$@" &
  45         else
  46            while getopts 'p:t:m' opt
  47            do
  48                 case "${opt}" in
  49                    t) TAG=${OPTARG};;
  50                    p) PRI=${OPTARG};;
  51                 esac
  52            done
  53         
  54            shift $((${OPTIND} - 1))
  55            LOG_STRING=`/usr/bin/printf "$@"`
  56            ${LOGGER} -p ${PRI} -t ${TAG} ${LOG_STRING}
  57         fi
  58 }
  59 
  60 debug_message()
  61 {
  62         if [ "${DEBUG}" = "${RESOURCE}" -o "${DEBUG}" = "ALL" ]
  63         then
  64            SET_DEBUG="set -x"
  65            DEBUG_TEXT=${1}
  66 
  67            scds_syslog -p daemon.debug -t $(syslog_tag) -m \
  68               "%s" "${DEBUG_TEXT}"
  69         else
  70            SET_DEBUG=
  71         fi
  72 }
  73 
  74 log_message()
  75 {
  76         debug_message "Function: log_message - Begin"
  77         {SET_DEBUG}
  78 
  79         if [ -s "${LOGFILE}" ]
  80         then
  81            PRIORITY=$1
  82            HEADER=$2
  83 
  84            strings ${LOGFILE} > ${LOGFILE}.copy
  85 
  86            while read MSG_TXT
  87            do
  88                 scds_syslog -p daemon.${PRIORITY} -t $(syslog_tag) -m \
  89                 "%s - %s" \
  90                 "${HEADER}" "${MSG_TXT}"
  91            done < ${LOGFILE}.copy
  92 
  93            cat /dev/null > ${LOGFILE}
  94         fi
  95 
  96         debug_message "Function: log_message - End"
  97 }
  98 
  99 set_redirection()
 100 {
 101         debug_message "Function: set_redirection - Begin"
 102         ${SET_DEBUG}
 103 
 104         if /usr/bin/getent passwd ${USERID} | /usr/bin/awk -F: '{print $7}' | /usr/bin/grep csh > /dev/null
 105         then
 106            OUTPUT=">& ${LOGFILE}"
 107         else
 108            OUTPUT="> ${LOGFILE} 2>&1"
 109         fi
 110 
 111         debug_message "Function: set_redirection - End"
 112 }
 113 
 114 validate()
 115 {
 116         debug_message "Function: validate - Begin"
 117         ${SET_DEBUG}
 118 
 119         rc=0
 120 
 121         # Note that group/user informix is an IDS requirement. Refer to 
 122         # http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp?topic
 123         # and in particular Installing IDS.
 124 
 125         if /usr/bin/getent passwd informix > /dev/null
 126         then
 127            debug_message "Validate - User informix exists"
 128         else
 129            # SCMSGS
 130            # @explanation
 131            # The userid informix does not exist.
 132            # @user_action
 133            # You must create the userid informix.
 134            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 135                 "Validate - User informix does not exist"
 136            rc=1
 137         fi
 138 
 139         if /usr/bin/getent group informix > /dev/null
 140         then
 141            debug_message "Validate - Group informix exists"
 142         else
 143            # SCMSGS
 144            # @explanation
 145            # The group informix does not exist.
 146            # @user_action
 147            # You must create the group informix.
 148            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 149                 "Validate - Group informix does not exist"
 150            rc=1
 151         fi
 152 
 153         if [ "${USERID}" = "informix" ]
 154         then
 155            debug_message "Validate - Userid is informix"
 156         else
 157            pgroup=`/usr/bin/getent passwd ${USERID} | /usr/bin/awk -F: '{print $4}'`
 158 
 159            if [ -n "${pgroup}" ]
 160            then
 161                 if /usr/bin/getent group ${pgroup} | /usr/bin/awk -F: '{ if ($1 == "informix") print $3}' | \
 162                    /usr/bin/grep "^${pgroup}$" > /dev/null
 163                 then
 164                    debug_message "Validate - Primary group for userid ${USERID} is informix"
 165                 else
 166                    if /usr/bin/getent group informix | /usr/bin/awk -F: '{print $4}' | \
 167                       /usr/bin/grep ${USERID} > /dev/null
 168                    then
 169                         debug_message "Validate - Secondary group for userid ${USERID} is informix"
 170                    else
 171                         # SCMSGS
 172                         # @explanation
 173                         # The user is not a member of the group informix.
 174                         # @user_action
 175                         # Ensure the user is a member of the group informix.
 176                         scds_syslog -p daemon.error -t $(syslog_tag) -m \
 177                            "Validate - Userid %s is not a member of group informix" \
 178                            "${USERID}"
 179                         rc=1
 180                    fi
 181                 fi
 182            else
 183                 # SCMSGS
 184                 # @explanation
 185                 # The user is not a valid userid.
 186                 # @user_action
 187                 # Ensure the user name is correct.
 188                 scds_syslog -p daemon.error -t $(syslog_tag) -m \
 189                    "Validate - User %s is not a valid userid" \
 190                    "${USERID}"
 191                 rc=1
 192            fi
 193         fi
 194 
 195         if [ -d "${INFORMIXDIR}" ]
 196         then
 197            debug_message "Validate - ${INFORMIXDIR} exists"
 198 
 199            if [ -x "${INFORMIXDIR}/bin/oninit" ]
 200            then
 201                 debug_message "Validate - ${INFORMIXDIR}/bin/oninit exists and is executable"
 202            else
 203                 # SCMSGS
 204                 # @explanation
 205                 # oninit was not found in ${INFORMIXDIR}/bin.
 206                 # @user_action
 207                 # Ensure that ${INFORMIXDIR} is the directory path
 208                 # where the Informix files are installed.
 209                 scds_syslog -p daemon.error -t $(syslog_tag) -m \
 210                    "Validate - %s/bin/oninit does not exist" \
 211                    "${INFORMIXDIR}"
 212                 rc=1
 213            fi
 214         else
 215            # SCMSGS
 216            # @explanation
 217            # ${INFORMIXDIR} does not exist or is not a directory.
 218            # @user_action
 219            # Ensure that ${INFORMIXDIR} is the directory path
 220            # where the Informix files are installed.
 221            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 222                 "Validate - %s does not exist or is not a directory" \
 223                 "${INFORMIXDIR}"
 224            rc=1
 225         fi
 226         
 227         # Here, we check that the ${ONCONFIG} file contains 
 228         # the ROOTNAME variable, below is snipped sample
 229         # ${ONCONFIG} file containing ROOTNAME.
 230         # 
 231         # ROOTNAME      rootdbs         # Root dbspace name
 232 
 233         if [ -f "${INFORMIXDIR}/etc/${ONCONFIG}" ]
 234         then
 235            debug_message "Validate - ${INFORMIXDIR}/etc/${ONCONFIG} exists"
 236 
 237            if /usr/xpg4/bin/grep -qw ROOTNAME ${INFORMIXDIR}/etc/${ONCONFIG}
 238            then
 239                 debug_message "Validate - ROOTNAME found in ${INFORMIXDIR}/etc/${ONCONFIG}"
 240            else
 241                 # SCMSGS
 242                 # @explanation
 243                 # ${INFORMIXDIR}/bin/${ONCONFIG} is not a valid onconfig file.
 244                 # @user_action
 245                 # Ensure that ${INFORMIXDIR}/etc/${ONCONFIG} is a valid onconfig file.
 246                 scds_syslog -p daemon.error -t $(syslog_tag) -m \
 247                    "Validate - %s/bin/%s is not a valid onconfig file" \
 248                    "${INFORMIXDIR}" "${ONCONFIG}"
 249                 rc=1
 250            fi
 251 
 252            # Here, we check that the ${ONCONFIG} file contains 
 253            # the ${INFORMIXSERVER} name, below is snipped sample
 254            # ${ONCONFIG} file containing ${INFORMIXSERVER}. 
 255            # 
 256            # DBSERVERNAME       demo_on         
 257            # 
 258            # Note that ${INFORMIXSERVER} is represented by "demo_on".
 259 
 260            if /usr/xpg4/bin/grep -qw ${INFORMIXSERVER} ${INFORMIXDIR}/etc/${ONCONFIG}
 261            then 
 262                 debug_message "Validate - ${INFORMIXSERVER} found in ${INFORMIXDIR}/etc/${ONCONFIG}"
 263            else
 264                 # SCMSGS
 265                 # @explanation
 266                 # ${INFORMIXDIR}/etc/${ONCONFIG} does not contain ${INFORMIXSERVER}.
 267                 # @user_action
 268                 # Ensure that ${INFORMIXDIR}/etc/${ONCONFIG} contains ${INFORMIXSERVER}.
 269                 scds_syslog -p daemon.error -t $(syslog_tag) -m \
 270                    "Validate - %s/etc/%s does not contain %s" \
 271                    "${INFORMIXDIR}" "${ONCONFIG}" "${INFORMIXSERVER}"
 272                 rc=1
 273            fi
 274         else
 275            # SCMSGS
 276            # @explanation
 277            # ${INFORMIXDIR}/etc/${ONCONFIG} does not exist.
 278            # @user_action
 279            # Ensure that ${INFORMIXDIR}/etc/${ONCONFIG} exists.
 280            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 281                 "Validate - %s/etc/%s does not exist" \
 282                 "${INFORMIXDIR}" "${ONCONFIG}"
 283            rc=1
 284         fi
 285 
 286         # Here, we check that the ${INFORMIXSQLHOSTS} file contains 
 287         # the ${INFORMIXSERVER} name, below is snipped sample
 288         # ${INFORMIXSQLHOSTS} file containing ${INFORMIXSERVER}. 
 289         # 
 290         # demo_on       ontlitcp        lzmutt1a        9088
 291         # 
 292         # Note that ${INFORMIXSERVER} is represented by "demo_on".
 293 
 294         if [ -f "${INFORMIXSQLHOSTS}" ]
 295         then
 296            debug_message "Validate - ${INFORMIXSQLHOSTS} exists"
 297 
 298            if /usr/xpg4/bin/grep -qw ${INFORMIXSERVER} ${INFORMIXSQLHOSTS}
 299            then 
 300                 debug_message "Validate - ${INFORMIXSERVER} found in ${INFORMIXSQLHOSTS}"
 301            else
 302                 # SCMSGS
 303                 # @explanation
 304                 # ${INFORMIXSQLHOSTS} does not contain ${INFORMIXSERVER}.
 305                 # @user_action
 306                 # Ensure that ${INFORMIXSQLHOSTS} is contains ${INFORMIXSERVER}.
 307                 scds_syslog -p daemon.error -t $(syslog_tag) -m \
 308                    "Validate - %s does not contain %s" \
 309                    "${INFORMIXSQLHOSTS}" "${INFORMIXSERVER}"
 310                 rc=1
 311            fi
 312         else
 313            # SCMSGS
 314            # @explanation
 315            # ${INFORMIXSQLHOSTS does not exist.
 316            # @user_action
 317            # Ensure that ${INFORMIXSQLHOSTS} exists.
 318            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 319                 "Validate - %s does not exist" \
 320                 "${INFORMIXSQLHOSTS}"
 321            rc=1
 322         fi
 323 
 324         if [ "${rc}" -eq 0 ]
 325         then
 326            # SCMSGS
 327            # @explanation
 328            # The Informix Server validation was successful.
 329            # @user_action
 330            # None required, informational message.
 331            scds_syslog -p daemon.info -t $(syslog_tag) -m \
 332                 "Validate - Informix Server (%s) validation was successful" \
 333                 "${INFORMIXSERVER}"
 334         fi
 335            
 336         debug_message "Function: validate - End"
 337         return ${rc}
 338 }
 339 
 340 start_ids()
 341 {
 342         debug_message "Function: start_ids - Begin"
 343         ${SET_DEBUG}
 344 
 345         /usr/bin/rm ${LOGFILE} > /dev/null
 346 
 347         if [ "${CALLER}" = "GDS" ]
 348         then
 349            get_state
 350            check_ids debug
 351            rc=$?
 352 
 353            # Check_ids will return 0 if
 354            # - The Informix Server is running
 355            # - No blocked on "MEDIA FAILURE" or "HANG_SYSTEM" exists
 356 
 357            if [ "${rc}" -eq 0 ]
 358            then
 359                 # Turn off PMF restart if ${INFORMIXSERVER} has been manually started
 360                 /usr/bin/sleep ${START_TIMEOUT} &
 361                 /usr/cluster/bin/pmfadm -s ${RESOURCEGROUP},${RESOURCE},0.svc
 362         
 363                 # SCMSGS
 364                 # @explanation
 365                 # The specified Informix Server has been manually started.
 366                 # @user_action
 367                 # None required. Informational message.
 368                 scds_syslog -p daemon.notice -t $(syslog_tag) -m \
 369                    "start_ids - Informix Server (%s) was manually started" \
 370                    "${INFORMIXSERVER}"
 371 
 372                 return 0
 373            fi
 374 
 375            /usr/bin/su ${USERID} -c "${TASK_COMMAND} env INFORMIXDIR=${INFORMIXDIR} INFORMIXSERVER=${INFORMIXSERVER} INFORMIXSQLHOSTS=${INFORMIXSQLHOSTS} ONCONFIG=${ONCONFIG} ${INFORMIXDIR}/bin/oninit -y ${OUTPUT} &" > /dev/null
 376 
 377         else
 378            env INFORMIXDIR=${INFORMIXDIR} INFORMIXSERVER=${INFORMIXSERVER} INFORMIXSQLHOSTS=${INFORMIXSQLHOSTS} ONCONFIG=${ONCONFIG} ${INFORMIXDIR}/bin/oninit -y > ${LOGFILE} 2>&1 &
 379 
 380         fi
 381 
 382         rc=$?
 383 
 384         if [ "${rc}" -eq 0 ]
 385         then
 386            # SCMSGS
 387            # @explanation
 388            # The specified Informix Server was started successfully.
 389            # @user_action
 390            # None required. Informational message.
 391            scds_syslog -p daemon.info -t $(syslog_tag) -m \
 392                 "start_ids - Informix Server (%s) started rc(%s)" \
 393                 "${INFORMIXSERVER}" "${rc}"
 394 
 395            # At present there is no equivalent "wait_for_online" within SMF
 396            # therefore we'll perform our own.
 397 
 398            if [ "${CALLER}" = "SMF" ]
 399            then
 400                 smf_wait_for_online
 401                 rc=?
 402            fi
 403         else
 404            # SCMSGS
 405            # @explanation
 406            # The specified Informix Server failed to start.
 407            # @user_action
 408            # Check the syslog for further messages. If possible the 
 409            # Solaris Cluster will attempt to restart the Informix
 410            # Server.
 411            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 412                 "start_ids - Informix Server (%s) failed to start rc(%s)" \
 413                 "${INFORMIXSERVER}" "${rc}"
 414 
 415            log_message error "start_ids rc(${rc})"
 416         fi
 417 
 418         debug_message "Function: start_ids - End"
 419         return ${rc}
 420 }
 421 
 422 check_start()
 423 {
 424         debug_message "Function: check_start - Begin"
 425         ${SET_DEBUG}
 426 
 427         if [ "${CALLER}" = "GDS" ]
 428         then
 429            if [ -x /sbin/zonename ]
 430            then
 431                 /usr/bin/pgrep -z ${ZONENAME} -f "$1 .*-R ${RESOURCE} " >/dev/null 2>&1
 432            else
 433                 /usr/bin/pgrep -u root -f "$1 .*-R ${RESOURCE} " >/dev/null 2>&1
 434            fi
 435         else
 436                 /usr/bin/pgrep -u ${USERID} -f "$1 ${RESOURCE} " >/dev/null 2>&1
 437         fi
 438 
 439         rc=$?
 440 
 441         debug_message "Function: check_start - End"
 442         return ${rc}
 443 }
 444 
 445 get_state()
 446 {
 447         debug_message "Function: get_state - Begin"
 448         ${SET_DEBUG}
 449 
 450         # The Informix Dynamic Server has an operating mode which can be obtained 
 451         # by using the "onstat -" utility that prints the output header of the
 452         # onstat utility. The format of the output header is as follows, 
 453         # 
 454         # Version--Mode (Type)--(Checkpnt)--Up Uptime--Sh_mem Kbytes
 455         # 
 456         # "Version" will contain the product name and version number.
 457         # "Mode" will contain the currrent operating mode.
 458         #
 459         # In addition to the operating mode, the database maybe blocked from
 460         # performing any work. If the database is blocked, the blocked reason
 461         # is also displayed in the onstat output header.
 462         # 
 463         # Of interest to us is "Version", "Mode" and any blocked reason. 
 464         # 
 465         # Under normal operation the product name within "Version" will contain 
 466         # "IBM Informix Dynamic Server", after which "Mode" will reflect an
 467         # appropriate operating mode. Blocked states only appear once a "Mode" 
 468         # is reached.
 469         #
 470         # The following shows two sample "onstat -" outputs,
 471         # Before IDS is started.
 472         #
 473         #  shared memory not initialized for INFORMIXSERVER 'demo_on'
 474         #
 475         # After IDS is started.
 476         #
 477         #  IBM Informix Dynamic Server Version 11.10.FC1       -- On-Line -- Up 01:47:59 -- 29696 Kbytes
 478 
 479         if [ "${CALLER}" = "GDS" ]
 480         then
 481            onstat_header=`/usr/bin/su ${USERID} -c "${TASK_COMMAND} env INFORMIXDIR=${INFORMIXDIR} INFORMIXSERVER=${INFORMIXSERVER} INFORMIXSQLHOSTS=${INFORMIXSQLHOSTS} ONCONFIG=${ONCONFIG} ${INFORMIXDIR}/bin/onstat - | /usr/bin/grep ."`
 482         else
 483            onstat_header=`env INFORMIXDIR=${INFORMIXDIR} INFORMIXSERVER=${INFORMIXSERVER} INFORMIXSQLHOSTS=${INFORMIXSQLHOSTS} ONCONFIG=${ONCONFIG} ${INFORMIXDIR}/bin/onstat - | /usr/bin/grep .`
 484         fi
 485 
 486         if echo ${onstat_header} | /usr/xpg4/bin/grep -q "Informix Dynamic Server"
 487         then
 488            onstat_mode=`echo ${onstat_header} | /usr/bin/sed -e 's/ -- Up.*$//' -e 's/^.*-- //'`
 489 
 490            if echo ${onstat_header} | /usr/xpg4/bin/grep -q "Blocked:"
 491            then
 492                 onstat_blocked=`echo ${onstat_header} | /usr/bin/sed -e 's/^.*Blocked://'`
 493            else
 494                 onstat_blocked=""
 495            fi
 496         fi
 497 
 498         debug_message "Function: get_state - End"
 499 }
 500 
 501 check_ids()
 502 {
 503         debug_message "Function: check_ids - Begin"
 504         ${SET_DEBUG}
 505 
 506         LEVEL=error
 507         [ "$1" = "debug" ] && LEVEL=debug
 508 
 509         # Check if IDS is starting up.
 510         if echo ${onstat_header} | /usr/xpg4/bin/grep -q "Changing data structure"
 511         then
 512            # SCMSGS
 513            # @explanation
 514            # The Informix Server database is starting up.
 515            # @user_action
 516            # None required. Solaris Cluster will restart the Informix Server 
 517            # so that it is managed by Solaris Cluster.
 518            scds_syslog -p daemon.${LEVEL} -t $(syslog_tag) -m \
 519                 "check_ids - Database Instance %s is restarting" \
 520                 "${INFORMIXSERVER}"
 521 
 522            return 100
 523         fi
 524 
 525         # Check if IDS is down.
 526         if echo ${onstat_header} | /usr/xpg4/bin/grep -q -E "shared memory not initialized|WARNING: IBM Informix Dynamic Server is no longer running"
 527         then
 528            # SCMSGS
 529            # @explanation
 530            # The Informix Server database is down.
 531            # @user_action
 532            # None required. Solaris Cluster will restart the Informix Server. 
 533            scds_syslog -p daemon.${LEVEL} -t $(syslog_tag) -m \
 534                 "check_ids - Database Instance %s is down" \
 535                 "${INFORMIXSERVER}"
 536 
 537            return 100
 538         fi
 539 
 540         # Check for any blocked states.
 541         # Regardless of the onstat_mode, if a blocked state of "MEDIA FAILURE" or
 542         # "HANG_SYSTEM" exists we will register a complete failure and indicate 
 543         # that the DBA needs to be involved.
 544 
 545         if [ -n "${onstat_blocked}" ]
 546         then
 547            if echo "${onstat_blocked}" | /usr/xpg4/bin/grep -q -E "MEDIA_FAILURE|HANG_SYSTEM"
 548            then
 549                 # SCMSGS
 550                 # @explanation
 551                 # The Informix Dynamic Server database has failed.
 552                 # @user_action
 553                 # Check the system log for error messages and contact your DBA.
 554                 # Solaris Cluster will restart the Informix Server.
 555                 scds_syslog -p daemon.${LEVEL} -t $(syslog_tag) -m \
 556                    "check_ids - Database Instance %s has failed mode(%s) blocked(%s), contact your DBA" \
 557                    "${INFORMIXSERVER}" "${onstat_mode}" "${onstat_blocked}"
 558 
 559                 return 100
 560            fi
 561         fi
 562 
 563         case "${onstat_mode}" in
 564                                                                         # Maintenance & Startup modes
 565                 "Quiescent"|"Administration"|"Single User"|"Initialization"|"Fast Recovery"|"Recovery")
 566 
 567                         rc=100
 568                         ;;
 569                            
 570                 # The following IDS server modes are acceptable normal operation modes.
 571 
 572                 "On-Line"|"Read-only")                                  # Normal operation modes
 573 
 574                         rc=0
 575                         ;;
 576 
 577                 # Any other IDS server modes are treated as a complete failure.
 578         
 579                 *)                                                      # Unknown modes
 580                         rc=100
 581                         ;;
 582         esac
 583 
 584         debug_message "check_ids - ${onstat_header}"
 585 
 586         if [ "${CALLER}" = "GDS" -a "${LEVEL}" != "debug" ]
 587         then
 588            # While we tolerate some blocked states we will output a status message
 589            # to Solaris Cluster if one is found. Nevertheless the resource remains online.
 590 
 591            saved_rc=${rc}
 592 
 593            # Check if GDS is still starting the resource. If GDS start has finished we'll set
 594            # the Solaris Cluster resource status with the appropriate Mode and any Blocked state.
 595 
 596            if ! check_start gds_svc_start
 597            then
 598                 MESSAGE=
 599                 [ -n "${onstat_mode}" ] && MESSAGE="Mode:${onstat_mode}"
 600                 [ -n "${onstat_blocked}" ] && MESSAGE="${MESSAGE} Blocked:${onstat_blocked}"
 601 
 602                 /usr/cluster/bin/scha_resource_setstatus -R ${RESOURCE} -G ${RESOURCEGROUP} -s OK -m "${MESSAGE}"
 603            fi
 604 
 605            rc=${saved_rc}
 606 
 607         fi
 608 
 609         debug_message "Function: check_ids - End"
 610         return ${rc}
 611 }
 612 
 613 stop_ids()
 614 {
 615         debug_message "Function: stop_ids - Begin"
 616         ${SET_DEBUG}
 617 
 618         MAX_STOP_TIMEOUT=`/usr/bin/expr ${STOP_TIMEOUT} \* 70 \/ 100`
 619         SECONDS=0
 620 
 621         if [ "${CALLER}" = "GDS" ]
 622         then
 623            /usr/bin/su ${USERID} -c "${TASK_COMMAND} env INFORMIXDIR=${INFORMIXDIR} INFORMIXSERVER=${INFORMIXSERVER} INFORMIXSQLHOSTS=${INFORMIXSQLHOSTS} ONCONFIG=${ONCONFIG} ${INFORMIXDIR}/bin/onmode -uky ${OUTPUT} &" > /dev/null
 624 
 625         else
 626            env INFORMIXDIR=${INFORMIXDIR} INFORMIXSERVER=${INFORMIXSERVER} INFORMIXSQLHOSTS=${INFORMIXSQLHOSTS} ONCONFIG=${ONCONFIG} ${INFORMIXDIR}/bin/onmode -uky  > ${LOGFILE} 2>&1 &
 627         fi
 628 
 629         while  [ "${SECONDS}" -lt "${MAX_STOP_TIMEOUT}" ]
 630         do
 631            get_state
 632 
 633            if echo ${onstat_header} | /usr/xpg4/bin/grep -q "shared memory not initialized"
 634            then
 635                 SECONDS=${MAX_STOP_TIMEOUT}
 636            else
 637                 sleep 5
 638            fi
 639         done
 640 
 641         # Note that the shutdown will be run in the background. As such the contents
 642         # of ${LOGFILE} is not of interest so we will clear that file.
 643 
 644         cat /dev/null > ${LOGFILE}
 645 
 646         get_state
 647 
 648         if ! echo ${onstat_header} | /usr/xpg4/bin/grep -q "shared memory not initialized"
 649         then
 650            /usr/cluster/bin/pmfadm -s ${RESOURCEGROUP},${RESOURCE},0.svc KILL 2> /dev/null
 651         fi
 652 
 653         debug_message "Function: stop_ids - End"
 654         return 0
 655 }
 656 
 657 smf_wait_for_online()
 658 {
 659         debug_message "Function: smf_wait_for_online - Begin"
 660         ${SET_DEBUG}
 661 
 662         MAX_START_TIMEOUT=`/usr/bin/expr ${START_TIMEOUT} \* 95 \/ 100`
 663         SECONDS=0
 664 
 665         while  [ "${SECONDS}" -lt "${MAX_START_TIMEOUT}" ]
 666         do
 667            get_state
 668            check_ids
 669            rc=$?
 670 
 671            # Check_ids will return 0 if
 672            # - The Informix Server is running
 673            # - No blocked on "MEDIA FAILURE" or "HANG_SYSTEM" exists
 674 
 675            if [ "${rc}" -eq 0 ]
 676            then
 677                 SECONDS=${MAX_START_TIMEOUT}
 678            else
 679                 sleep 5
 680            fi
 681         done
 682 
 683         debug_message "Function: smf_wait_for_online - End"
 684         return ${rc}
 685 }
 686 
 687 cleanup_ipc()
 688 {
 689         debug_message "Function: cleanup_ipc - Begin"
 690         ${SET_DEBUG}
 691 
 692         # Cleanup any IPC shared memory segments however only if
 693         #
 694         #       - The shared memory segment(s) are owned by
 695         #               OWNER=root and GROUP=informix
 696         #       - The shared memory has no attached processes
 697         #       - The CPID and LPID processes are not running
 698 
 699         flag=
 700 
 701         if [ "${DEBUG}" = "${RESOURCE}" -o "${DEBUG}" = "ALL" ]
 702         then
 703            debug_message "IPC Status BEFORE removal of non-attached segments created by group informix"
 704            /usr/bin/ipcs -mcopbZ | /usr/bin/grep " ${ZONENAME}$" > ${LOGFILE}
 705            log_message debug ipcs
 706         fi
 707 
 708         /usr/bin/ipcs -mcopbZ | /usr/bin/grep " ${ZONENAME}$" | /usr/bin/awk ' \
 709            {if (NF == 13 && $5 == "root" && $6 == "informix" && $9 == 0 ) print $2,$11,$12; else \
 710            if (NF == 12 && $4 == "root" && $5 == "informix" && $8 == 0 ) print $1,$10,$11 }' | \
 711            while read SHMID CPID LPID
 712            do
 713                 if /usr/bin/ps -p ${LPID} -o zone | /usr/bin/grep " ${ZONENAME}$" > /dev/null
 714                 then
 715                    debug_message "Informix SHMID: ${SHMID} - LPID ${LPID} is running"
 716                 else
 717                    if /usr/bin/ps -p ${CPID} -o zone | /usr/bin/grep " ${ZONENAME}$" > /dev/null
 718                    then
 719                         debug_message "Informix SHMID: ${SHMID} - CPID ${CPID} is running"
 720                    else
 721                         SHMID=`/usr/bin/echo ${SHMID} | /usr/xpg4/bin/tr 'm' ' '`
 722 
 723                         # As the initial ipcs -mcopbZ is only a snapshot in time, Informix
 724                         # may have already cleaned up. Therefore the following attempt to remove a 
 725                         # shared memory segment may fail with "not found". To prevent misleading 
 726                         # console messages stdout/stderr is redirected to ${LOGFILE}. 
 727 
 728                         /usr/bin/ipcrm -z ${ZONENAME} -m ${SHMID} > ${LOGFILE}
 729 
 730                         debug_message "Informix SHMID: ${SHMID} - removed"
 731 
 732                         flag=deleted
 733                    fi
 734                 fi
 735            done
 736 
 737         if [ -n "${flag}" ]
 738         then
 739            # SCMSGS
 740            # @explanation
 741            # All the Informix shared memory segments that were not being
 742            # used have been removed.
 743            # @user_action
 744            # None required. Informational message.
 745            scds_syslog -p daemon.notice -t $(syslog_tag) -m \
 746                 "All Informix non-attached IPC shared memory segments removed"
 747         fi
 748 
 749         debug_message "IPC Status AFTER removal of non-attached segments created by group informix"
 750 
 751         if [ "${DEBUG}" = "${RESOURCE}" -o "${DEBUG}" = "ALL" ]
 752         then
 753            /usr/bin/ipcs -mcopbZ | /usr/bin/grep " ${ZONENAME}$" > ${LOGFILE}
 754            log_message debug ipcs
 755         fi
 756 
 757         debug_message "Function: cleanup_ipc - End"
 758         return 0
 759 }