-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrs_stat-t
executable file
·51 lines (44 loc) · 1.55 KB
/
crs_stat-t
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
#!/usr/bin/ksh
# copied from Doc ID: NOTE:259301.1
# v. 1.02 - 2019.11.29 - small typo fixed
# v. 1.01 - 2019.11.19 - added check for $ORA_CRS_HOME/bin/crs_stat file
#
# Sample 10g CRS resource status query script
#
# Description:
# - Returns formatted version of crs_stat -t, in tabular
# format, with the complete rsc names and filtering keywords
# - The argument, $RSC_KEY, is optional and if passed to the script, will
# limit the output to HA resources whose names match $RSC_KEY.
# Requirements:
# - $ORA_CRS_HOME should be set in your environment
RSC_KEY=$1
QSTAT=-u
if [ -f /usr/xpg4/bin/awk ]
then
AWK=/usr/xpg4/bin/awk
else
AWK=/usr/bin/awk
fi
if [ ! -f $ORA_CRS_HOME/bin/crs_stat ];then
echo
echo '$ORA_CRS_HOME/bin/crs_stat' "($ORA_CRS_HOME/bin/crs_stat) NOT FOUND, exiting ..."
echo "to debug check lines below (1 below you can run to see)"
echo echo '$ORA_CRS_HOME'
echo and this line shows the value of '$ORA_CRS_HOME' actually set
echo '$ORA_CRS_HOME' "= $ORA_CRS_HOME"
echo
exit 1
fi
# Table header:echo ""
$AWK \
'BEGIN {printf "%-45s %-10s %-18s\n", "HA Resource", "Target", "State";
printf "%-45s %-10s %-18s\n", "-----------", "------", "-----";}'
# Table body:
$ORA_CRS_HOME/bin/crs_stat $QSTAT | $AWK \
'BEGIN { FS="="; state = 0; }
$1~/NAME/ && $2~/'$RSC_KEY'/ {appname = $2; state=1};
state == 0 {next;}
$1~/TARGET/ && state == 1 {apptarget = $2; state=2;}
$1~/STATE/ && state == 2 {appstate = $2; state=3;}
state == 3 {printf "%-45s %-10s %-18s\n", appname, apptarget, appstate; state=0;}'