2010-04-16

are my resources in favored place?

On a 11gR1 Oracle Cluster I had an issue with some resources not in their favored place.
While investigating, I had to get the affected resources fast (at least faster than reading a huge list of resources manually and think if they match the rules).

This brought me to a small script:

crs_stat -f | awk ' BEGIN { FS="="
c=0}
/^NAME=/{n=$2}
/TYPE=/{t=$2}
/HOSTING_MEMBERS=/{hm=$2}
/PLACEMENT=/{p=$2}
/TARGET=/{g=$2}
/STATE=/{s=$2;
ch=s
gsub("ONLINE on ", "",ch)
if( (p=="favored") && !( index(hm,ch)>0 ) ) {
printf("%-30s%-20s%-17s%-15s%-30s\n", n, " should be located on ", hm, " but has STATE: ", s) ;
c+=1 ;
}
}
END { exit c }'


It prints out a line for every resource which has a favored placement, but currently is not on any HOSTING_MEMBERS.

I'm sure it's not the best awk-code, but it's fine for me.

To use it in other scripts (e.g. monitoring) I can use | wc -l to get the number of suboptimal located resources or just get the return value $?

Keine Kommentare: