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