Sdiff functions.ksh


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 "@(#)functions.ksh 1.4 08/04/29 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 }
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" \
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} 2> /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.
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
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 # In order to ensure that the SMF service is really online, we need 663 # to check getstate() and check_ids(). However, we need to enforce 664 # an SMF_EXIT_ERR_CONFIG if we are just about to timeout. If we do not 665 # do this, then svc.startd will try to restart the SMF service three 666 # times. Essentially we need Sun Cluster to do that. 667 668 MAX_START_TIMEOUT=`/usr/bin/expr ${START_TIMEOUT} \* 95 \/ 100` 669 SECONDS=0 670 671 while [ "${SECONDS}" -lt "${MAX_START_TIMEOUT}" ] 672 do 673 get_state 674 check_ids 675 rc=$? 676 677 # Check_ids will return 0 if 678 # - The Informix Server is running 679 # - No blocked on "MEDIA FAILURE" or "HANG_SYSTEM" exists 680 681 if [ "${rc}" -eq 0 ] 682 then 683 SECONDS=${MAX_START_TIMEOUT} 684 else 685 rc=${SMF_EXIT_ERR_CONFIG} 686 sleep 2 687 fi 688 done 689 690 debug_message "Function: smf_wait_for_online - End" 691 return ${rc} 692 } 693 694 cleanup_ipc() 695 { 696 debug_message "Function: cleanup_ipc - Begin" 697 ${SET_DEBUG} 698 699 # Cleanup any IPC shared memory segments however only if 700 # 701 # - The shared memory segment(s) are owned by 702 # OWNER=root and GROUP=informix 703 # - The shared memory has no attached processes 704 # - The CPID and LPID processes are not running 705 706 flag= 707 708 if [ "${DEBUG}" = "${RESOURCE}" -o "${DEBUG}" = "ALL" ] 709 then 710 debug_message "IPC Status BEFORE removal of non-attached segments created by group informix" 711 /usr/bin/ipcs -mcopbZ | /usr/bin/grep " ${ZONENAME}$" > ${LOGFILE} 712 log_message debug ipcs 713 fi 714 715 /usr/bin/ipcs -mcopbZ | /usr/bin/grep " ${ZONENAME}$" | /usr/bin/awk ' \ 716 {if (NF == 13 && $5 == "root" && $6 == "informix" && $9 == 0 ) print $2,$11,$12; else \ 717 if (NF == 12 && $4 == "root" && $5 == "informix" && $8 == 0 ) print $1,$10,$11 }' | \ 718 while read SHMID CPID LPID 719 do 720 if /usr/bin/ps -p ${LPID} -o zone | /usr/bin/grep " ${ZONENAME}$" > /dev/null 721 then 722 debug_message "Informix SHMID: ${SHMID} - LPID ${LPID} is running" 723 else 724 if /usr/bin/ps -p ${CPID} -o zone | /usr/bin/grep " ${ZONENAME}$" > /dev/null 725 then 726 debug_message "Informix SHMID: ${SHMID} - CPID ${CPID} is running" 727 else 728 SHMID=`/usr/bin/echo ${SHMID} | /usr/xpg4/bin/tr 'm' ' '` 729 730 # As the initial ipcs -mcopbZ is only a snapshot in time, Informix 731 # may have already cleaned up. Therefore the following attempt to remove a 732 # shared memory segment may fail with "not found". To prevent misleading 733 # console messages stdout/stderr is redirected to /dev/null. 734 735 /usr/bin/ipcrm -z ${ZONENAME} -m ${SHMID} > /dev/null 2>&1 736 737 debug_message "Informix SHMID: ${SHMID} - removed" 738 739 flag=deleted 740 fi 741 fi 742 done 743 744 if [ -n "${flag}" ] 745 then 746 # SCMSGS 747 # @explanation 748 # All the Informix shared memory segments that were not being


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 "@(#)functions.ksh 1.5 08/05/27 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 }
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" \
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} 2> /dev/null 346 347 get_state 348 check_ids debug 349 rc=$? 350 351 # Check_ids will return 0 if 352 # - The Informix Server is running 353 # - No blocked on "MEDIA FAILURE" or "HANG_SYSTEM" exists 354 355 if [ "${rc}" -eq 0 ] 356 then 357 # Turn off PMF restart if ${INFORMIXSERVER} has been manually started 358 /usr/bin/sleep ${START_TIMEOUT} & 359 /usr/cluster/bin/pmfadm -s ${RESOURCEGROUP},${RESOURCE},0.svc 360 361 # SCMSGS 362 # @explanation 363 # The specified Informix Server has been manually started. 364 # @user_action 365 # None required. Informational message. 366 scds_syslog -p daemon.notice -t $(syslog_tag) -m \ 367 "start_ids - Informix Server (%s) was manually started" \ 368 "${INFORMIXSERVER}" 369 370 return 0 371 fi 372 373 /usr/bin/su ${USERID} -c "${TASK_COMMAND} /usr/bin/env INFORMIXDIR=${INFORMIXDIR} INFORMIXSERVER=${INFORMIXSERVER} INFORMIXSQLHOSTS=${INFORMIXSQLHOSTS} ONCONFIG=${ONCONFIG} ${INFORMIXDIR}/bin/oninit -y ${OUTPUT} &" > /dev/null 374 375 rc=$? 376 377 if [ "${rc}" -eq 0 ] 378 then 379 # SCMSGS 380 # @explanation 381 # The specified Informix Server was started successfully. 382 # @user_action 383 # None required. Informational message. 384 scds_syslog -p daemon.info -t $(syslog_tag) -m \ 385 "start_ids - Informix Server (%s) started rc(%s)" \ 386 "${INFORMIXSERVER}" "${rc}" 387 else 388 # SCMSGS 389 # @explanation 390 # The specified Informix Server failed to start. 391 # @user_action 392 # Check the syslog for further messages. If possible the 393 # Solaris Cluster will attempt to restart the Informix 394 # Server. 395 scds_syslog -p daemon.error -t $(syslog_tag) -m \ 396 "start_ids - Informix Server (%s) failed to start rc(%s)" \ 397 "${INFORMIXSERVER}" "${rc}" 398 399 log_message error "start_ids rc(${rc})" 400 fi 401 402 debug_message "Function: start_ids - End" 403 return ${rc} 404 } 405 406 check_start() 407 { 408 debug_message "Function: check_start - Begin" 409 ${SET_DEBUG} 410 411 if [ -x /sbin/zonename ] 412 then 413 /usr/bin/pgrep -z ${ZONENAME} -f "$1 .*-R ${RESOURCE} " >/dev/null 2>&1 414 else 415 /usr/bin/pgrep -u root -f "$1 .*-R ${RESOURCE} " >/dev/null 2>&1 416 fi 417 418 rc=$? 419 420 debug_message "Function: check_start - End" 421 return ${rc} 422 } 423 424 get_state() 425 { 426 debug_message "Function: get_state - Begin" 427 ${SET_DEBUG} 428 429 # The Informix Dynamic Server has an operating mode which can be obtained 430 # by using the "onstat -" utility that prints the output header of the 431 # onstat utility. The format of the output header is as follows, 432 # 433 # Version--Mode (Type)--(Checkpnt)--Up Uptime--Sh_mem Kbytes 434 # 435 # "Version" will contain the product name and version number. 436 # "Mode" will contain the currrent operating mode.
438 # In addition to the operating mode, the database maybe blocked from 439 # performing any work. If the database is blocked, the blocked reason 440 # is also displayed in the onstat output header. 441 # 442 # Of interest to us is "Version", "Mode" and any blocked reason. 443 # 444 # Under normal operation the product name within "Version" will contain 445 # "IBM Informix Dynamic Server", after which "Mode" will reflect an 446 # appropriate operating mode. Blocked states only appear once a "Mode" 447 # is reached. 448 # 449 # The following shows two sample "onstat -" outputs, 450 # Before IDS is started. 451 # 452 # shared memory not initialized for INFORMIXSERVER 'demo_on' 453 # 454 # After IDS is started. 455 # 456 # IBM Informix Dynamic Server Version 11.10.FC1 -- On-Line -- Up 01:47:59 -- 29696 Kbytes 457 458 onstat_header=$(/usr/bin/su ${USERID} -c "${TASK_COMMAND} /usr/bin/env INFORMIXDIR=${INFORMIXDIR} INFORMIXSERVER=${INFORMIXSERVER} INFORMIXSQLHOSTS=${INFORMIXSQLHOSTS} ONCONFIG=${ONCONFIG} ${INFORMIXDIR}/bin/onstat - | /usr/bin/grep .") 459 460 if echo ${onstat_header} | /usr/xpg4/bin/grep -q "Informix Dynamic Server" 461 then 462 onstat_mode=$(echo ${onstat_header} | /usr/bin/sed -e 's/ -- Up.*$//' -e 's/^.*-- //') 463 464 if echo ${onstat_header} | /usr/xpg4/bin/grep -q "Blocked:" 465 then 466 onstat_blocked=$(echo ${onstat_header} | /usr/bin/sed -e 's/^.*Blocked://') 467 else 468 onstat_blocked="" 469 fi 470 fi 471 472 debug_message "Function: get_state - End" 473 } 474 475 check_ids() 476 { 477 debug_message "Function: check_ids - Begin" 478 ${SET_DEBUG} 479 480 LEVEL=error 481 [ "$1" = "debug" ] && LEVEL=debug 482 483 # Check if IDS is starting up. 484 if echo ${onstat_header} | /usr/xpg4/bin/grep -q "Changing data structure" 485 then 486 # SCMSGS
540 541 rc=100 542 ;; 543 544 # The following IDS server modes are acceptable normal operation modes. 545 546 "On-Line"|"Read-only") # Normal operation modes 547 548 rc=0 549 ;; 550 551 # Any other IDS server modes are treated as a complete failure. 552 553 *) # Unknown modes 554 rc=100 555 ;; 556 esac 557 558 debug_message "check_ids - ${onstat_header}" 559 560 if [ "${LEVEL}" != "debug" ] 561 then 562 # While we tolerate some blocked states we will output a status message 563 # to Solaris Cluster if one is found. Nevertheless the resource remains online. 564 565 saved_rc=${rc} 566 567 # Check if GDS is still starting the resource. If GDS start has finished we'll set 568 # the Solaris Cluster resource status with the appropriate Mode and any Blocked state. 569 570 if ! check_start gds_svc_start 571 then 572 MESSAGE= 573 [ -n "${onstat_mode}" ] && MESSAGE="Mode:${onstat_mode}" 574 [ -n "${onstat_blocked}" ] && MESSAGE="${MESSAGE} Blocked:${onstat_blocked}" 575 576 /usr/cluster/bin/scha_resource_setstatus -R ${RESOURCE} -G ${RESOURCEGROUP} -s OK -m "${MESSAGE}" 577 fi 578 579 rc=${saved_rc} 580 581 fi 582 583 debug_message "Function: check_ids - End" 584 return ${rc} 585 } 586 587 stop_ids() 588 { 589 debug_message "Function: stop_ids - Begin" 590 ${SET_DEBUG} 591 592 MAX_STOP_TIMEOUT=$(/usr/bin/expr ${STOP_TIMEOUT} \* 70 \/ 100) 593 SECONDS=0 594 595 /usr/bin/su ${USERID} -c "${TASK_COMMAND} /usr/bin/env INFORMIXDIR=${INFORMIXDIR} INFORMIXSERVER=${INFORMIXSERVER} INFORMIXSQLHOSTS=${INFORMIXSQLHOSTS} ONCONFIG=${ONCONFIG} ${INFORMIXDIR}/bin/onmode -uky ${OUTPUT} &" > /dev/null 596 597 while [ "${SECONDS}" -lt "${MAX_STOP_TIMEOUT}" ] 598 do 599 get_state 600 601 if echo ${onstat_header} | /usr/xpg4/bin/grep -q "shared memory not initialized" 602 then 603 SECONDS=${MAX_STOP_TIMEOUT} 604 else 605 sleep 5 606 fi 607 done 608 609 # Note that the shutdown will be run in the background. As such the contents 610 # of ${LOGFILE} is not of interest so we will clear that file. 611 612 cat /dev/null > ${LOGFILE} 613 614 get_state 615 616 if ! echo ${onstat_header} | /usr/xpg4/bin/grep -q "shared memory not initialized" 617 then 618 /usr/cluster/bin/pmfadm -s ${RESOURCEGROUP},${RESOURCE},0.svc KILL 2> /dev/null 619 fi 620 621 debug_message "Function: stop_ids - End" 622 return 0 623 } 624 625 cleanup_ipc() 626 { 627 debug_message "Function: cleanup_ipc - Begin" 628 ${SET_DEBUG} 629 630 # Cleanup any IPC shared memory segments however only if 631 # 632 # - The shared memory segment(s) are owned by 633 # OWNER=root and GROUP=informix 634 # - The shared memory has no attached processes 635 # - The CPID and LPID processes are not running 636 637 flag= 638 639 if [ "${DEBUG}" = "${RESOURCE}" -o "${DEBUG}" = "ALL" ] 640 then 641 debug_message "IPC Status BEFORE removal of non-attached segments created by group informix" 642 /usr/bin/ipcs -mcopbZ | /usr/bin/grep " ${ZONENAME}$" > ${LOGFILE} 643 log_message debug ipcs 644 fi 645 646 /usr/bin/ipcs -mcopbZ | /usr/bin/grep " ${ZONENAME}$" | /usr/bin/awk ' \ 647 {if (NF == 13 && $5 == "root" && $6 == "informix" && $9 == 0 ) print $2,$11,$12; else \ 648 if (NF == 12 && $4 == "root" && $5 == "informix" && $8 == 0 ) print $1,$10,$11 }' | \ 649 while read SHMID CPID LPID 650 do 651 if /usr/bin/ps -p ${LPID} -o zone | /usr/bin/grep " ${ZONENAME}$" > /dev/null 652 then 653 debug_message "Informix SHMID: ${SHMID} - LPID ${LPID} is running" 654 else 655 if /usr/bin/ps -p ${CPID} -o zone | /usr/bin/grep " ${ZONENAME}$" > /dev/null 656 then 657 debug_message "Informix SHMID: ${SHMID} - CPID ${CPID} is running" 658 else 659 SHMID=$(/usr/bin/echo ${SHMID} | /usr/xpg4/bin/tr 'm' ' ') 660 661 # As the initial ipcs -mcopbZ is only a snapshot in time, Informix 662 # may have already cleaned up. Therefore the following attempt to remove a 663 # shared memory segment may fail with "not found". To prevent misleading 664 # console messages stdout/stderr is redirected to /dev/null. 665 666 /usr/bin/ipcrm -z ${ZONENAME} -m ${SHMID} > /dev/null 2>&1 667 668 debug_message "Informix SHMID: ${SHMID} - removed" 669 670 flag=deleted 671 fi 672 fi 673 done 674 675 if [ -n "${flag}" ] 676 then 677 # SCMSGS 678 # @explanation 679 # All the Informix shared memory segments that were not being