Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
5348 lines (4955 loc) · 206 KB

File metadata and controls

5348 lines (4955 loc) · 206 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/ksh
#prw.sh
VERSION=19.8.20.9.0
# Version format = latest_tested_db_version_major_release(#.#).year.month.revision#
#
# This script will find clusterware and/or Oracle Background processes and collect
# stack traces for debugging. It will write a file called procname_pid_date_hour.out
# for each process. If you are debugging clusterware then run this script as root.
# If you are only debugging Oracle background processes then you can run as
# root or oracle.
#
# Paramaters have been moved to the prwinit.ora file which is created in the Procwatcher directory
## 19.8.20.9.0 mpolaski: hostname special characters, process_memory on by default in Linux, permissions
## 12.2.17.4 mpolaski: TFA/root compatibility, don't remove proclist file for external table, security
## 12.2.15.2 mpolaski: server pool / policy managed support & clean option
## 12.1.14.12 mpolaski: prwinit.ora file
## 11.2.12.12 mpolaski: Warning e-mails, suspected final blocker
## 111212 mpolaski: Faster cycle time, sgamemwatch param, top cpu consumers on Linux
## 043012 mpolaski: Reduce SQL versions with procwatcher_pids table
## 022812 mpolaski: New PRWDIR parameter
## 062211 mpolaski: Format waitchains output and fix housekeeper retention issue
## 122010 mpolaski: Linux specific pgamemory collection added with process_memory=y
## 050710 mpolaski: Add custom SQL and handle instance startup/shutdown better
## 042110 mpolaski: Add RETENTION parameter, change start arguments
## 041210 mpolaski: Add heapdetails query, other minor fixes
## 040110 mpolaski: Add version check, smarter oratab search, dynamic stack count
## 030910 mpolaski: Don't fall back to OS debugger by default if short_stack fails per bug 6859515
## 031010 mpolaski: Add SQL control
## 030510 mpolaski: Added process memory collection
## 030410 mpolaski: Add pack option
## 030310 mpolaski: Add v$wait_chains for 11g
## 030110 mpolaski: Add 11g clusterware procs, add procstack, _go_faster=true
## 040209 mpolaski: fall back to v$ views if gv$ times out
## 101907 mpolaski: added sqltext functionality
## 092807 mpolaski: released
### PATH Check
PS=`which ps`
FIND=`which find`
if [ ! -f "$PS" ] || [ ! -f "$FIND" ]
then echo `date`: "ERROR: PATH is not set up correctly (need /bin and /usr/bin), Exiting"
exit 1;
fi
### Platform specific section...
platform=`uname`
osversion=$platform
case $platform in
Linux)
ECHO="echo -e"
# pstack is just a wrapper for gdb on linux anyways...
USE_PSTACK=false
USE_GDB=true
GDB=/usr/bin/gdb
process_memory=y
if [ -z "$PROCINTERVAL" ]
then PROCINTERVAL=1
fi
INSTLOC=/etc/oraInst.loc
;;
HP-UX)
export UNIX95=0
if [ -z "$USE_PSTACK" ]; then
USE_GDB=true
if [ -f /opt/langtools/bin/gdb64 ]
then GDB=/opt/langtools/bin/gdb64
elif [ -f /usr/ccs/bin/gdb64 ]
then GDB=/usr/ccs/bin/gdb64
fi
fi
if [ -z "$PROCINTERVAL" ]
then PROCINTERVAL=1
fi
INSTLOC=/var/opt/oracle/oraInst.loc
;;
SunOS)
osversion=`uname -r`
USE_PSTACK=true
PSTACK=/usr/bin/pstack
if [ -z "$PROCINTERVAL" ]
then PROCINTERVAL=1
fi
INSTLOC=/var/opt/oracle/oraInst.loc
;;
AIX)
if [ -z "$USE_PSTACK" ]; then
if [ -f /bin/procstack ]; then
USE_PROCSTACK=true
PROCSTACK=/bin/procstack
else
USE_DBX=true
DBX=/bin/dbx
fi
fi
if [ -z "$PROCINTERVAL" ]
then PROCINTERVAL=1
fi
INSTLOC=/etc/oraInst.loc
;;
OSF1)
if [ -z "$USE_PSTACK" ]; then
USE_LADEBUG=true
LADEBUG=/bin/ladebug
fi
if [ -z "$PROCINTERVAL" ]
then PROCINTERVAL=2
fi
INSTLOC=/var/opt/oracle/oraInst.loc
;;
*)
echo `date`: "ERROR: Unknown Operating System, Exiting..."
exit 1;
esac
### Stuff to Use Later...
banner="################################################################################"
preamble1="Thank you for using Procwatcher. :-)"
preamble2="Please add a comment to Oracle Support Note 459694.1"
preamble3="if you have any comments, suggestions, or issues with this tool."
findprocname='ps -e -o pid,args'
findprocnameuser='ps -e -o pid,user,args'
debugprocs="gdb |pstack |gdb64 |dbx |procstack |ladebug |shortstack start|prw.sh sqlstart|oradebug start"
badlist="grep|$debugprocs|init|COMM|WCHAN|su |ps |sh |strace|sed |crsctl stat res"
HOSTNAME=`hostname | cut -d '.' -f1 | tr "[A-Z]" "[a-z]"`
EXAMINE_CELL=false
EXEDIR="$( cd "$( dirname "$0" )" && pwd )"
SUPPORTEDVERSIONS="9.|10.|11.|12.|18.|19.|20."
### Clusterware Check
if [ `$findprocname | grep ocssd.bin | egrep -v "$badlist" | wc -l` -gt 0 ]; then
CLUSTERWARE=true
CRS_HOME_BIN=`$findprocname | grep ocssd.bin | egrep -v "$badlist" | awk '{print $2}' | sed "s@/ocssd.bin@@" | grep -v sed | cut -d ' ' -f1 | head -1`
CWLOGDIR=`$findprocname | grep ocssd.bin | egrep -v "$badlist" | awk '{print $2}' | sed "s@/bin/ocssd.bin@/log/procwatcher@" | cut -d ' ' -f1 | head -1`
GRIDLOGDIR=`echo $CWLOGDIR | sed "s@/procwatcher@@" | head -1`
CRSREGISTERED=false
if [ `$findprocname | grep "ohasd.b" | grep -v grep | wc -l` -gt 0 ]; then
if [ `$CRS_HOME_BIN/./crsctl stat res procwatcher | wc -l | tr -d ' '` -gt 2 ]; then
CRSREGISTERED=true
fi
fi
else
CLUSTERWARE=false
fi
### Set Procwatcher Directory
setprwdir()
{
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
set -x
fi
# defaults
if [ "$1" = 'deploy' ] && [ -n "$2" ]; then
PRWDIR=$2
fi
PRWPERM=764
PRWGROUP=oinstall
if [ -f $INSTLOC ]; then
if [ `grep inst_group $INSTLOC | wc -l | tr -d ' '` -gt 0 ]; then
PRWGROUP=`grep inst_group $INSTLOC | cut -d "=" -f2`
fi
fi
# if prw.sh is running, that is the PRWDIR
if [ `$findprocname | grep "prw.sh run" | grep -v grep | wc -l` -gt 0 ]; then
tPRWDIR=`$findprocname | grep "prw.sh run" | grep -v grep | awk '{print $3}' | sed "s@/prw.sh@?@" | cut -d '?' -f1 | head -1`
if [ "$tPRWDIR" = "-x" ]; then
tPRWDIR=`$findprocname | grep "prw.sh run" | grep -v grep | awk '{print $4}' | sed "s@/prw.sh@?@" | cut -d '?' -f1 | head -1`
fi
if [ "$tPRWDIR" != "$CWLOGDIR" ]; then
PRWDIR=$tPRWDIR
fi
fi
# create prw temp directory
makeprwtmpdir()
{
if [ ! -d $2 ]; then
mkdir $2
chown $1 $2
chmod $PRWPERM $2
chgrp $PRWGROUP $2
fi
}
# if prwinit.ora exists in executable dir, check it for PRWDIR param
if [ -z "$PRWDIR" ] && [ -f $EXEDIR/prwinit.ora ]; then
if [ `cat $EXEDIR/prwinit.ora | grep PRWDIR= | grep -v "#" | wc -l | tr -d ' '` = 1 ]; then
PRWDIR=`cat $EXEDIR/prwinit.ora | grep PRWDIR= | grep -v "#" | cut -d '=' -f2`
fi
if [ `cat $EXEDIR/prwinit.ora | grep PRWPERM= | grep -v "#" | wc -l | tr -d ' '` = 1 ]; then
PRWPERM=`cat $EXEDIR/prwinit.ora | grep PRWPERM= | grep -v "#" | cut -d '=' -f2`
fi
if [ `cat $EXEDIR/prwinit.ora | grep PRWGROUP= | grep -v "#" | wc -l | tr -d ' '` = 1 ]; then
PRWGROUP=`cat $EXEDIR/prwinit.ora | grep PRWGROUP= | grep -v "#" | cut -d '=' -f2`
fi
fi
# find a .prwinit file
if [ -r $EXEDIR/.prwinit.ora ]; then
HPRWINIT=$EXEDIR/.prwinit.ora
else
HPRWINIT=$HOME/.prwinit.ora
fi
# check for hidden file too in case PRWDIR is somewhere else
if [ -z "$PRWDIR" ] && [ -f $HPRWINIT ]; then
if [ `cat $HPRWINIT | grep PRWDIR= | grep -v "#" | wc -l | tr -d ' '` = 1 ]; then
PRWDIR=`cat $HPRWINIT | grep PRWDIR= | grep -v "#" | cut -d '=' -f2`
fi
if [ `cat $EXEDIR/.prwinit.ora | grep PRWPERM= | grep -v "#" | wc -l | tr -d ' '` = 1 ]; then
PRWPERM=`cat $EXEDIR/.prwinit.ora | grep PRWPERM= | grep -v "#" | cut -d '=' -f2`
fi
if [ `cat $EXEDIR/.prwinit.ora | grep PRWGROUP= | grep -v "#" | wc -l | tr -d ' '` = 1 ]; then
PRWGROUP=`cat $EXEDIR/.prwinit.ora | grep PRWGROUP= | grep -v "#" | cut -d '=' -f2`
fi
fi
# can't find PRWDIR in prwinit.ora so defaulting location
if [ -z "$PRWDIR" ]; then
if [ `$findprocname | grep "prw.sh r" | grep -v grep | wc -l | tr -d ' '` -gt 0 ]; then
if [ "$2" = 'debug' ] ||
[ `$findprocname | grep "prw.sh r" | grep "\-x" | grep -v grep | wc -l` -gt 0 ]; then
PRWDIR=`$findprocname | grep "prw.sh r" | grep -v grep | awk '{print $4}' | sed "s@/prw.sh@@"`
else
PRWDIR=`$findprocname | grep "prw.sh r" | grep -v grep | awk '{print $3}' | sed "s@/prw.sh@@"`
fi
else
if [ `$findprocname | grep tfa | grep jre | wc -l | tr -d ' '` -gt 0 ]; then
AHFDIR=`$findprocname | grep tfa | grep jre | awk '{print $2}' | cut -d "/" -f1-3`
PRWDIR=$AHFDIR/tfa/ext/prw
elif [ $CLUSTERWARE='true' ] && [ -w "$GRIDLOGDIR" ]; then
PRWDIR=$CWLOGDIR
else
PRWDIR=$EXEDIR
fi
fi
else
if [ ! -f $PRWDIR/PRW_SYS_$HOSTNAME/prwdir ]; then
if [ ! -d $PRWDIR/PRW_SYS_$HOSTNAME ]; then
mkdir -p $PRWDIR/PRW_SYS_$HOSTNAME
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME
fi
touch $PRWDIR/PRW_SYS_$HOSTNAME/prwdir
chmod $PRWPERM $PRWDIR/PRW_SYS_$HOSTNAME/prwdir
chgrp $PRWGROUP $PRWDIR/PRW_SYS_$HOSTNAME/prwdir
fi
fi
### Make sure there are no duplicates
PRWDIR=`echo $PRWDIR | cut -d ' ' -f1`
### Make Procwatcher Directory if it doesn't exist
if [ ! -d $PRWDIR ]; then
mkdir -p $PRWDIR
prwpermissions $PRWDIR
fi
if [ ! -f $PRWDIR/prw.sh ]; then
cp $EXEDIR/prw.sh $PRWDIR/prw.sh
prwpermissions $PRWDIR/prw.sh
chmod u+x $PRWDIR/prw.sh
fi
}
setprwdir
if [ ! -f $PRWDIR/PRW_SYS_$HOSTNAME/proclist ]; then
if [ ! -d $PRWDIR/PRW_SYS_$HOSTNAME ]; then
mkdir -p $PRWDIR/PRW_SYS_$HOSTNAME
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME
fi
touch $PRWDIR/PRW_SYS_$HOSTNAME/proclist
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME/proclist
fi
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ] && [ "$1" = 'run' ] ; then
set -x
fi
if [ ! -f $PRWDIR/prwinit.ora ] && [ ! -f $HOME/.prwrelocate ] && [ `$findprocname | grep "prw.sh init" | grep -v grep | wc -l | tr -d ' '` -eq 0 ]; then
if [ "$1" = 'deploy' ] && [ -n "$2" ]; then
ksh $EXEDIR/prw.sh init $2 2>&1 &
else
ksh $EXEDIR/prw.sh init 2>&1 &
fi
sleep 1
fi
### Set parameters
if [ $1 != init ]; then
for i in 1 2 3 4 5
do
if [ `$findprocname | grep "prw.sh init" | grep -v grep | wc -l | tr -d ' '` -gt 0 ]; then
sleep 1
fi
done
## Make variables case insenstive
typeset -l EXAMINE_CLUSTER
typeset -l EXAMINE_BG
typeset -l USE_SQL
# main parameters
# defaults
defEXAMINE_CLUSTER=false
defEXAMINE_BG=true
defPRWGROUP=oinstall
defRETENTION=7
defWARNINGEMAIL=
defINTERVAL=60
defTHROTTLE=5
defIDLECPU=3
defSIDLIST=
# end defaults
for param in EXAMINE_CLUSTER EXAMINE_BG PRWPERM PRWGROUP RETENTION WARNINGEMAIL INTERVAL THROTTLE IDLECPU SIDLIST
do
if [ `cat $PRWDIR/prwinit.ora | grep $param= | grep -v "#" | wc -l | tr -d ' '` = 1 ]; then
export $param=`cat $PRWDIR/prwinit.ora | grep $param= | grep -v "#" | cut -d '=' -f2`
else
eval $param=\$def$param
export $param
fi
done;
# advanced parameters
# defaults
defUSE_SQL=true
defsessionwait=y
deflock=y
deflatchholder=y
defgesenqueue=y
defwaitchains=y
defrmanclient=n
defsqltext=y
defash=y
deferrorstack=n
defsgamemwatch=off
defheapdump_level=0
deflib_cache_dump_level=0
defsuspectprocthreshold=2
defwarningprocthreshold=10
defhanganalyze_level=0
defsystemstate_level=0
defCLUSTERPROCS='"crsd.bin|evmd.bin|evmlogge|racgimon|racge|racgmain|racgons.b|ohasd.b|oraagent|oraroota|gipcd.b|mdnsd.b|gpnpd.b|gnsd.bi|diskmon|octssd.b|tnslsnr"'
defBGPROCS='"_dbw|_smon|_pmon|_lgwr|_lmd|_lms|_lck|_lmon|_ckpt|_arc|_rvwr|_gmon|_lmhb|_rms0"'
defuse_gv=
defuse_pmap=n
defVERSION_10_1=y
defVERSION_10_2=y
defVERSION_11_1=y
defVERSION_11_2=y
defVERSION_12_1=y
defVERSION_12_2=y
defVERSION_18_0=y
defVERSION_19_0=y
defVERSION_20_0=y
defFALL_BACK_TO_OSDEBUGGER=false
defSTACKCOUNT=3
defCUSTOMSQL1=
defCUSTOMSQL2=
defCUSTOMSQL3=
# end defaults
for param in USE_SQL sessionwait lock latchholder gesenqueue waitchains rmanclient sqltext ash errorstack sgamemwatch heapdump_level lib_cache_dump_level suspectprocthreshold warningprocthreshold hanganalyze_level systemstate_level CLUSTERPROCS BGPROCS use_gv use_pmap VERSION_10_1 VERSION_10_2 VERSION_11_1 VERSION_11_2 VERSION_12_1 VERSION_12_2 VERSION_18_0 VERSION_19_0 VERSION_20_0 FALL_BACK_TO_OSDEBUGGER STACKCOUNT CUSTOMSQL1 CUSTOMSQL2 CUSTOMSQL3
do
if [ `cat $PRWDIR/prwinit.ora | grep $param= | grep -v "#" | wc -l | tr -d ' '` = 1 ]; then
export $param=`cat $PRWDIR/prwinit.ora | grep $param= | grep -v "#" | cut -d '=' -f2`
else
eval $param=\$def$param
export $param
fi
done;
fi
### Try to use pstack if we have it
if [ -f /usr/bin/pstack ]; then
USE_PSTACK=true
PSTACK=/usr/bin/pstack
fi
ECHO=echo
# SGA mem queries
if [ "$sgamemwatch" = 'diag' ] || [ "$sgamemwatch" = 'avoid4031' ]; then
MEMsgastat=y
MEMheapdetails=y
MEMsgadynamic=y
MEMtop20sqls=y
MEMlru=y
else
MEMsgastat=n
MEMheapdetails=n
MEMsgadynamic=n
MEMtop20sqls=n
MEMlru=n
fi
# Function to set oratab based on platform
oratabplatform()
{
case $platform in
Linux)
ORATAB=/etc/oratab
;;
HP-UX)
ORATAB=/etc/oratab
;;
SunOS)
ORATAB=/var/opt/oracle/oratab
;;
AIX)
ORATAB=/etc/oratab
;;
OSF1)
ORATAB=/etc/oratab
;;
esac
}
# Set ORATAB
oratabplatform
### Cell check
if [ $EXAMINE_CELL = 'true' ] && [ `$findprocname | grep "/bin/cellsrv " | egrep -v "$badlist" | wc -l` -gt 0 ]; then
CELL_HOME_BIN=`$findprocname | grep "/bin/cellsrv " | egrep -v "$badlist" | awk '{print $2}' | sed "s@/cellsrv/bin/cellsrv@/cellsrv/bin@" | grep -v sed | cut -d ' ' -f1`
PRWDIR=/opt/oracle.procwatcher
fi
### BEGIN FUNCTIONS
### Log parameter settings
logparametersettings()
{
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
set -x
fi
### Log Parameter Settings
echo `date`: "### Parameters ###"
echo `date`: "Procwatcher Directory (PRWDIR): $PRWDIR"
for param in EXAMINE_CLUSTER EXAMINE_BG PRWPERM PRWGROUP RETENTION WARNINGEMAIL INTERVAL THROTTLE IDLECPU SIDLIST
do
eval psetting=\$$param
echo `date`: "$param=$psetting"
done
echo `date`: "### Advanced Parameters (non-default) ###"
for param in USE_SQL sessionwait lock latchholder gesenqueue waitchains rmanclient sqltext ash errorstack sgamemwatch heapdump_level lib_cache_dump_level suspectprocthreshold warningprocthreshold hanganalyze_level systemstate_level CLUSTERPROCS BGPROCS use_gv use_pmap VERSION_10_1 VERSION_10_2 VERSION_11_1 VERSION_11_2 VERSION_12_1 VERSION_12_2 VERSION_18_0 VERSION_19_0 VERSION_20_0 FALL_BACK_TO_OSDEBUGGER STACKCOUNT CUSTOMSQL1 CUSTOMSQL2 CUSTOMSQL3
do
defparam=`echo def$param`
eval dpsetting=\$def$param
eval psetting=\$$param
if ([ ! -z "$dpsetting" ] && [ ! -z "$psetting" ]) && [ `echo $psetting | cut -c1-3` = 'def' ]; then
psetting=$dpsetting
fi
if [ "$dpsetting" != "$psetting" ] && ([ ! -z "$dpsetting" ] && [ ! -z "$psetting" ]); then
echo `date`: "$param=$psetting"
fi
done
echo `date`: "### End Parameters ###"
}
### Capture vmstat
capturevmstat()
{
echo $DATESECONDS > $PRWDIR/PRW_SYS_$HOSTNAME/lastvmstat
vmstat 1 2 | egrep "id|0|1|2|3|4|5|6|7|8|9" | grep -v -i System > $PRWDIR/PRW_SYS_$HOSTNAME/vmstat
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME/vmstat
cat $PRWDIR/PRW_SYS_$HOSTNAME/vmstat | while read `cat $PRWDIR/PRW_SYS_$HOSTNAME/vmstat | head -1 | sed "s@--@aa@"`
do
idle=$id
if [ $idle != "id" ]; then
echo $idle > $PRWDIR/PRW_SYS_$HOSTNAME/idlecpu
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME/idlecpu
fi
done
}
### Throttle control - Don't start more debug processes than $THROTTLE or run with < $IDLECPU
### Check if we haven't checked for over 5 seconds
throttlecontrol()
{
if [ ! -f $PRWDIR/PRW_SYS_$HOSTNAME/idlecpu ]; then
echo 99 > $PRWDIR/PRW_SYS_$HOSTNAME/idlecpu
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME/idlecpu
fi
let DATESECONDS=`date +'%y'`*31556926+`date +'%m'`*2629743+`date +'%d'`*86400+`date +'%H'`*3600+`date +'%M'`*60+`date +'%S'`
if [ $IDLECPU -gt 0 ]; then
let timecheck=$DATESECONDS-5
else
let timecheck=0
fi
if [ `cat $PRWDIR/PRW_SYS_$HOSTNAME/lastvmstat` -lt $timecheck ]; then
capturevmstat
fi
sleeptime=5
while [ `cat $PRWDIR/PRW_SYS_$HOSTNAME/idlecpu` -lt $IDLECPU ]; do
let DATESECONDS=`date +'%y'`*31556926+`date +'%m'`*2629743+`date +'%d'`*86400+`date +'%H'`*3600+`date +'%M'`*60+`date +'%S'`
if [ $IDLECPU -gt 0 ]; then
let timecheck=$DATESECONDS-3
else
let timecheck=0
fi
if [ `cat $PRWDIR/PRW_SYS_$HOSTNAME/lastvmstat` -lt $timecheck ]; then
capturevmstat
fi
if [ `cat $PRWDIR/PRW_SYS_$HOSTNAME/idlecpu` -lt $IDLECPU ]; then
echo `date`: "WARNING: CPU is `cat $PRWDIR/PRW_SYS_$HOSTNAME/idlecpu` % idle - less than $IDLECPU % idle, sleeping $sleeptime seconds"
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
cat $PRWDIR/PRW_SYS_$HOSTNAME/vmstat
fi
sleep $sleeptime
else
break
fi
if [ $sleeptime -lt $INTERVAL ]; then
let sleeptime=sleeptime*1.5
else
let sleeptime=$INTERVAL
fi
done
sleeptime=5
until [ `ps -e -o args | egrep "$debugprocs" | grep -v grep | wc -l | tr -d ' '` -lt $THROTTLE ]; do
sleep $PROCINTERVAL
done
}
### Run this after throttle for big processes or jobs
halfthrottle()
{
# Half of throttle but round up
let halfthrottlenum=$THROTTLE/2+1
until [ `ps -e -o args | egrep "$debugprocs" | grep -v grep | wc -l | tr -d ' '` -lt $halfthrottlenum ]; do
sleep $PROCINTERVAL
done
}
### Check for clusterware migration
prwrelocate()
{
touch $HOME/.prwrelocate
if [ $CLUSTERWARE = 'true' ] && [ ! -f $PRWDIR/PRW_SYS_$HOSTNAME/prwdir ]; then
CWLOGDIR=`$findprocname | grep ocssd.bin | egrep -v "$badlist" | awk '{print $2}' | sed "s@/bin/ocssd.bin@/log/procwatcher@"`
GRIDLOGDIR=`echo $CWLOGDIR | sed "s@/procwatcher@@"`
# Check to see if clusterware moved
if [ -w $GRIDLOGDIR ] && [ $PRWDIR != $CWLOGDIR ]; then
### Clusterware moved
echo `date`: "Clusteware has moved, relocating Procwatcher directory to $CWLOGDIR"
cp $EXEDIR/prwinit.ora $CWLOGDIR/prwinit.ora
prwpermissions $CWLOGDIR/prwinit.ora
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
nohup ksh -x $EXEDIR/prw.sh deploy 2>&1 &
else
nohup ksh $EXEDIR/prw.sh deploy 2>&1 &
fi
exit
fi
fi
if [ -f $PRWDIR/.prw_masternode ] && [ `$findprocname | grep "ohasd.b" | grep -v grep | wc -l` -gt 0 ] && [ "$CRSREGISTERED" = 'true' ]; then
# Check to see if # of nodes changed
NODECOUNT=`$CRS_HOME_BIN/./olsnodes | wc -l | tr -d ' '`
CARDINALITY=`$CRS_HOME_BIN/crsctl stat res procwatcher -f | grep CARDINALITY= | cut -d '=' -f2`
if [ $NODECOUNT != $CARDINALITY ]; then
# Num of nodes changed, redeploy
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
nohup ksh -x $EXEDIR/prw.sh deploy 2>&1 &
else
nohup ksh $EXEDIR/prw.sh deploy 2>&1 &
fi
exit
fi
# Check to see if prw.sh exists on remote nodes
NODELIST=`$CRS_HOME_BIN/./olsnodes | tr '\n' ' '`
for prwnode in $NODELIST
do
if ssh $prwnode "[ ! -f $PRWDIR/prw.sh ]"
then
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
nohup ksh -x $EXEDIR/prw.sh deploy 2>&1 &
else
nohup ksh $EXEDIR/prw.sh deploy 2>&1 &
fi
fi
done
fi
}
### To find ORATAB entries
findoratabentry()
{
OH=
sidlength=`echo $sid | wc -m | tr -d ' '`
let sidlength=$sidlength-1
# Set oratab to platform specific location if there is no $PRWDIR/PRW_SYS_$HOSTNAME/oratab
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/oratab ] && [ -z "$ORATAB" ]; then
ORATAB=$PRWDIR/PRW_SYS_$HOSTNAME/oratab
else
oratabplatform
fi
# Is there an oratab file? If not then use default $OH
if [ ! -f $ORATAB ]; then
# Use default $OH which may not work...
OH=$ORACLE_HOME
else
until [ $sidlength -eq 1 ]; do
DBNAME=`echo $DBNAME | cut -c1-$sidlength`
if [ `grep $DBNAME $ORATAB | grep ":/" | wc -l | tr -d ' '` -eq 1 ]; then
# Best match
OH=`grep $DBNAME: $ORATAB | grep ":/" | cut -d ":" -f2`
break
elif [ `grep $DBNAME $ORATAB | grep ":/" | wc -l | tr -d ' '` -gt 1 ]; then
# Try ignoring commented lines
if [ `grep $DBNAME $ORATAB | grep ":/" | grep -v "#" | wc -l | tr -d ' '` -eq 1 ]; then
# Best match
OH=`grep $DBNAME $ORATAB | grep ":/" | grep -v "#" | cut -d ":" -f2`
break
fi
# See if it is ASM
if [ `grep +$DBNAME $ORATAB | grep ":/" | wc -l | tr -d ' '` -eq 1 ]; then
# Best match
OH=`grep +$DBNAME: $ORATAB | grep ":/" | cut -d ":" -f2`
break
fi
# Found more than 1 entry
badsid=blahblahblah
for oratabentry in `grep $DBNAME $ORATAB | cut -d ":" -f1 | grep -v "#"`
do
oratabsidlength=`echo $oratabentry | sed s@+@@ | sed s@-MGMTDB@MGMTDB@ | wc -m | tr -d ' '`
let oratabsidlength=$oratabsidlength-1
if [ $sidlength -ne $oratabsidlength ]; then
badsid=$oratabentry"|"$badsid
badsid=`echo $badsid | sed s@+@@ | sed s@-MGMTDB@MGMTDB@`
fi
done
if [ `grep $DBNAME: $ORATAB | egrep -v "$badsid" | grep -v "#$DBNAME" | grep -v "#+$DBNAME" | grep -v "#-$DBNAME" | grep ":/" | wc -l | tr -d ' '` -eq 1 ]; then
# good match
OH=`grep $DBNAME: $ORATAB | egrep -v "$badsid" | grep -v "#$DBNAME" | grep -v "#+$DBNAME" | grep -v "#-$DBNAME" | grep ":/" | cut -d ":" -f2`
break
fi
else
# not found in oratab, check clusterware?
if [ "$CLUSTERWARE" = 'true' ]; then
DBRES=ora.$DBNAME.db
if [ `$CRS_HOME_BIN/crsctl stat res $DBRES -f | grep ORACLE_HOME= | grep -v grep | wc -l | tr -d ' '` -gt 0 ]; then
OH=`$CRS_HOME_BIN/crsctl stat res $DBRES -f | grep ORACLE_HOME= | grep -v grep | cut -d "=" -f2 | sed 's@=@@`
break
fi
fi
fi
let sidlength=sidlength-1
done
if [ -z "$OH" ]; then
# If I couldn't find the home in the oratab use default $OH which may not work...
OH=$ORACLE_HOME
fi
fi
}
### For packing files
prwpack()
{
if [ -x /usr/bin/zip ] || [ -x $ORACLE_HOME/bin/zip ]; then
suffix=.zip
zip $filename.zip $source
elif [ -x /bin/tar ]; then
tar cvf $filename.tar $source
if [ -x /bin/gzip ]; then
suffix=.tar.gz
gzip -f $filename.tar
elif [ -x /bin/compress ]; then
suffix=.tar.Z
compress $filename.tar
else
suffix=.tar
fi
else
echo `date`: "Could not pack files...please pack them manually."
exit;
fi
}
# Check to see if the instance is running
isinstanceup()
{
isinstanceup=
sidlength=`echo $sqlsid | wc -m | tr -d ' '`
let sidlength=$sidlength-1
until [ $sidlength -eq 1 ]; do
PMONSIDNAME=`echo $sqlsid | cut -c1-$sidlength`
if [ `$findprocnameuser | grep "_pmon" | grep $PMONSIDNAME | egrep -v "$badlist" | wc -l | tr -d ' '` -gt 0 ]; then
badsid=
for pmonsid in `$findprocnameuser | grep "_pmon" | egrep -v "$badlist" | awk '{print $3}' | sed s@_pmon_@^@ | cut -d "^" -f2`
do
pmonsidlength=`echo $pmonsid | sed s@+@@ | sed s@-MGMTDB@MGMTDB@ | wc -m | tr -d ' '`
let pmonsidlength=$pmonsidlength-1
if [ $sidlength -ne $pmonsidlength ] && [ `echo $sqlsid | grep $pmonsid | wc -l | tr -d ' '` -lt 1 ]; then
if [ -z "$badsid" ]; then
badsid=$pmonsid
else
badsid=$pmonsid"|"$badsid
fi
fi
done
if [ -z "$badsid" ]; then
badsid=blahblahblahblah
else
badsid=`echo $badsid | sed s@+@@ | sed s@-MGMTDB@MGMTDB@`
fi
if [ `$findprocnameuser | grep "_pmon" | grep $PMONSIDNAME | egrep -v "$badsid" | egrep -v "$badlist" | wc -l | tr -d ' '` -eq 1 ]; then
# good match
isinstanceup=1
break
else
isinstanceup=0
fi
else
isinstanceup=0
fi
let sidlength=sidlength-1
done
if [ -z "$isinstanceup" ]; then
isinstanceup=0
fi
}
processwarning()
{
let DATESECONDS=`date +'%y'`*31556926+`date +'%m'`*2629743+`date +'%d'`*86400+`date +'%H'`*3600+`date +'%M'`*60+`date +'%S'`
if [ ! -f $PRWDIR/PRW_SYS_$HOSTNAME/warning_$warningsid ]; then
echo 0 > $PRWDIR/PRW_SYS_$HOSTNAME/warning_$warningsid
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME/warning_$warningsid
fi
LASTWARNING=`cat $PRWDIR/PRW_SYS_$HOSTNAME/warning_$warningsid`
let DIFFWARNING=$DATESECONDS-$LASTWARNING
if [ "$warningtype" != "DATABASE CONTENTION" ]; then
# always warn if not DB contention
DIFFWARNING=10000
fi
# Wait 5 min between contention warnings and only send warning if $WARNINGEMAIL is configured
if [ -n "$WARNINGEMAIL" ] && [ $DIFFWARNING -gt 300 ]; then
echo $DATESECONDS > $PRWDIR/PRW_SYS_$HOSTNAME/warning_$warningsid
mailheader=`echo "PROCWATCHER $warningtype WARNING FOR INSTANCE $warningsid!"`
mail -s "$mailheader" $WARNINGEMAIL < $warningfile
echo `date`: "E-MAIL sent to $WARNINGEMAIL : $mailheader"
fi
}
prwpermissions()
{
prwfile=$1
chmod $PRWPERM $prwfile
chgrp $PRWGROUP $prwfile
}
### END FUNCTIONS
# Starting command line arguments...
case $1 in
'run')
### BEGIN FUNCTIONS
buildinitialsidlist()
{
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
set -x
fi
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/usersidlist ] && ([ "$EXAMINE_BG" = 'true' ] || [ "$USE_SQL" = 'true' ]); then
SIDLIST=`cat $PRWDIR/PRW_SYS_$HOSTNAME/usersidlist`
# Make a bad sidlist (sids we don't want to debug)
for sid in `$findprocnameuser | grep "_pmon" | grep -v "$SIDLIST" | egrep -v "$badlist" | awk '{print $3}' | sed s@_pmon_@^@ | cut -d "^" -f2`
do
sid=`echo $sid | sed s@+@@ | sed s@-MGMTDB@MGMTDB@ | grep -v sed`
BADSIDLIST="$BADSIDLIST""|""$sid"
done
elif [ ! -f $PRWDIR/PRW_SYS_$HOSTNAME/usersidlist ] && ([ "$EXAMINE_BG" = 'true' ] || [ "$USE_SQL" = 'true' ]); then
SIDLIST=
BADSIDLIST=
userstring="_pmon"
if [ "$user" != 'root' ]
then
### Only get SIDs for this user
userstring="$user"
fi
# Make a good sidlist (sids we want to debug)
for sid in `$findprocnameuser | grep "_pmon" | grep "$userstring" | egrep -v "$badlist" | awk '{print $3}' | sed s@_pmon_@^@ | cut -d "^" -f2`
do
sid=`echo $sid | sed s@+@@ | sed s@-MGMTDB@MGMTDB@ | grep -v sed`
SIDLIST="$SIDLIST""|""$sid"
done
# Make a bad sidlist (sids we don't want to debug)
for sid in `$findprocnameuser | grep "_pmon" | grep -v "$userstring" | egrep -v "$badlist" | awk '{print $3}' | sed s@_pmon_@^@ | cut -d "^" -f2`
do
sid=`echo $sid | sed s@+@@ | sed s@-MGMTDB@MGMTDB@ | grep -v sed`
BADSIDLIST="$BADSIDLIST""|""$sid"
done
if [ ! -z "$SIDLIST" ]; then
sidlistlength=`echo $SIDLIST | wc -m | tr -d ' '`
if [ $sidlistlength -gt 2 ]; then
SIDLIST=`echo $SIDLIST | cut -c2-$sidlistlength | tr "+" " " | tr "-" " " | grep -v sed`
else
SIDLIST=
fi
fi
if [ ! -z "$BADSIDLIST" ]; then
badsidlistlength=`echo $BADSIDLIST | wc -m | tr -d ' '`
if [ $badsidlistlength -gt 2 ]; then
BADSIDLIST=`echo $BADSIDLIST | cut -c2-$badsidlistlength | tr "+" " " | tr "-" " " | grep -v sed`
else
BADSIDLIST=
fi
fi
fi
}
# Function to build the oratab, check the DB version, filter, and save the SIDLIST
filtersidlist()
{
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
set -x
fi
### Build procwatcher oratab
if [ "$USE_SQL" = 'true' ] || [ "$EXAMINE_BG" = 'true' ]; then
if [ -n "$SIDLIST" ]; then
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/oratab ]; then
rm -f $PRWDIR/PRW_SYS_$HOSTNAME/oratab
fi
for sid in `echo $SIDLIST | tr "|" " "`
do
DBNAME=$sid
oratabplatform
findoratabentry
echo $sid":"$OH >> $PRWDIR/PRW_SYS_$HOSTNAME/oratab
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/oratab ]; then
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME/oratab
fi
### Get DB version
sqlsid=$sid
isinstanceup
if [ $isinstanceup -gt 0 ]; then
if [ "$USE_SQL" = 'true' ] || [ "$EXAMINE_BG" = 'true' ]; then
echo `date`: "Checking DB version for SID $sid"
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid ]; then
rm -f $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid
fi
throttlecontrol
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
ksh -x $EXEDIR/prw.sh sqlstart $PRWDIR/PRW_SYS_$HOSTNAME/SQLvinstance $user $sid $OH
else
ksh $EXEDIR/prw.sh sqlstart $PRWDIR/PRW_SYS_$HOSTNAME/SQLvinstance $user $sid $OH
fi
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/procinterval ]; then
sleep $PROCINTERVAL
fi
# Give it a chance for version info to show up
for n in 1 2 3 4 5 6 7 8 9 10
do
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/SQLvinstance$sid.out ]; then
if [ `cat $PRWDIR/PRW_SYS_$HOSTNAME/SQLvinstance$sid.out | grep DBVERSION | wc -l` -eq 0 ]; then
sleep $PROCINTERVAL
else
break
fi
else
sleep $PROCINTERVAL
fi
done
### Save version info
for n in 1 2 3 4 5 6 7 8 9 10
do
if [ `grep "DBVERSION" $PRWDIR/PRW_SYS_$HOSTNAME/SQLvinstance$sid.out | awk '{print $2}' | wc -l` -lt 1 ]; then
sleep $PROCINTERVAL
else
break
fi
done
grep "DBVERSION" $PRWDIR/PRW_SYS_$HOSTNAME/SQLvinstance$sid.out | awk '{print $2}' > $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid
if [ `cat $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid | egrep $SUPPORTEDVERSIONS | wc -l` -gt 0 ]; then
echo `date`: "DB Version for SID $sid is "`cat $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid`
fi
if [ `cat $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid | egrep $SUPPORTEDVERSIONS | wc -l` -eq 0 ]; then
echo `date`: "WARNING: Could not get version info for SID $sid..."
echo `date`: "There may be an environment or install issue."
fi
fi
fi
### Create PRW Directory and External Table if it doesn't exist
if [ ! -f $PRWDIR/PRW_SYS_$HOSTNAME/ppids ]; then
touch $PRWDIR/PRW_SYS_$HOSTNAME/ppids
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME/ppids
fi
if [ `echo $sid | cut -c1-3` != 'ASM' ] && [ `echo $sid | cut -c1-3` != 'APX' ] && [ `cat $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid | egrep $SUPPORTEDVERSIONS | wc -l` -gt 0 ] && [ `cat $PRWDIR/PRW_SYS_$HOSTNAME/ppids | grep "SQLprocwatcher_pids$sid " | wc -l | tr -d ' '` -eq 0 ]; then
throttlecontrol
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
ksh -x $EXEDIR/prw.sh sqlstart $PRWDIR/PRW_SYS_$HOSTNAME/SQLdrop_procwatcher_pids $user $sid $OH 2>&1
sleep 1
nohup ksh -x $EXEDIR/prw.sh sqlstart $PRWDIR/PRW_SYS_$HOSTNAME/SQLprocwatcher_pids $user $sid $OH 2>&1
else
ksh $EXEDIR/prw.sh sqlstart $PRWDIR/PRW_SYS_$HOSTNAME/SQLdrop_procwatcher_pids $user $sid $OH 2>&1 &
sleep 1
nohup ksh $EXEDIR/prw.sh sqlstart $PRWDIR/PRW_SYS_$HOSTNAME/SQLprocwatcher_pids $user $sid $OH 2>&1 &
fi
if [ "$sgamemwatch" = 'avoid4031' ]; then
# Clearing LRU count since sgamemwatch=avoid4031
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/debug ]; then
ksh -x $EXEDIR/prw.sh sqlstart $PRWDIR/PRW_SYS_$HOSTNAME/SQLMEMlru $user $sid $OH 2>&1
else
ksh $EXEDIR/prw.sh sqlstart $PRWDIR/PRW_SYS_$HOSTNAME/SQLMEMlru $user $sid $OH 2>&1
fi
fi
fi
done
fi
### Filter SIDLIST based on version
NEWSIDLIST=
for sid in `echo $SIDLIST | tr "|" " "`
do
if [ -f $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid ]; then
if [ `cat $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid | wc -l` -gt 0 ]; then
ver1=`cat $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid | cut -d "." -f1`
ver2=`cat $PRWDIR/PRW_SYS_$HOSTNAME/version_$sid | cut -d "." -f2`
version=`echo $ver1"_"$ver2`
if [ "$version" = '10_1' ] && [ "$VERSION_10_1" = 'y' ]; then
goodsid=true
elif [ "$version" = '10_2' ] && [ "$VERSION_10_2" = 'y' ]; then
goodsid=true
elif [ "$version" = '11_1' ] && [ "$VERSION_11_1" = 'y' ]; then
goodsid=true
elif [ "$version" = '11_2' ] && [ "$VERSION_11_2" = 'y' ]; then
goodsid=true
elif [ "$version" = '12_1' ] && [ "$VERSION_12_1" = 'y' ]; then
goodsid=true
elif [ "$version" = '12_2' ] && [ "$VERSION_12_2" = 'y' ]; then
goodsid=true
elif [ "$version" = '18_0' ] && [ "$VERSION_18_0" = 'y' ]; then
goodsid=true
elif [ "$version" = '19_0' ] && [ "$VERSION_19_0" = 'y' ]; then
goodsid=true
elif [ "$version" = '20_0' ] && [ "$VERSION_20_0" = 'y' ]; then
goodsid=true
else
goodsid=false
fi
else
goodsid=false
fi
else
goodsid=false
fi
if [ "$goodsid" = 'true' ]; then
if [ -z "$NEWSIDLIST" ]; then
NEWSIDLIST=$sid
else
NEWSIDLIST=$sid"|"$NEWSIDLIST
fi
elif [ "$goodsid" = 'false' ]; then
if [ ! -z "$BADSIDLIST" ]; then
BADSIDLIST=$sid"|"$BADSIDLIST
else
BADSIDLIST=$sid
fi
fi
done
fi
# Save the $SIDLIST
echo "$NEWSIDLIST" > $PRWDIR/PRW_SYS_$HOSTNAME/sidlist
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME/sidlist
echo "$BADSIDLIST" > $PRWDIR/PRW_SYS_$HOSTNAME/badsidlist
prwpermissions $PRWDIR/PRW_SYS_$HOSTNAME/badsidlist
if [ `echo $NEWSIDLIST | wc -m | tr -d ' '` != `echo $SIDLIST | wc -m | tr -d ' '` ]; then
echo `date`: "Adjusting SIDLIST after version check"
echo `date`: "SIDLIST=$NEWSIDLIST"
fi
SIDLIST=$NEWSIDLIST
### Make DB_SID dir and check for RAC
for sid in `echo $SIDLIST | tr "|" " "`
do
if [ ! -d $PRWDIR/PRW_DB_$sid ]
then mkdir $PRWDIR/PRW_DB_$sid
prwpermissions $PRWDIR/PRW_DB_$sid
echo `date`: "Created "$PRWDIR/PRW_DB_$sid" directory"
fi
# Find out if it is RAC
if [ `ps -e -o args | grep "_lmd0" | egrep -v "$badlist" | wc -l | tr -d ' '` -gt 0 ]; then
echo "true" > $PRWDIR/PRW_SYS_$HOSTNAME/israc_$sid
else
Morty Proxy This is a proxified and sanitized view of the page, visit original site.