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