LQ Newbie
Registered: Mar 2011
Posts: 8
Original Poster
Rep:
|
thanks for the input, got some script which is working
format_crs_status_resource='
BEGIN {
FS="=";
ittype=empty
}
{
if ( $1 == "NAME") {
tname=$2
tx=split( $2, tsplit, "_")
tabrev=tsplit[tx]
ttype="unknown"
if ( tabrev == "asm" )
ttype="ASM"
if ( tabrev == "lsnr" )
ttype="Listener"
if ( tabrev == "db" )
ttype="Database"
if ( tabrev == "inst" )
ttype="Instance"
if ( tabrev == "vip" )
ttype="Virtual IP"
if ( tabrev == "ons" )
ttype="Ora Notif Svc"
if ( tabrev == "cs" )
ttype="Service"
if ( tabrev == "srv" )
ttype="Service"
}
if ( $1 == "TYPE") {
ottype=$2
if (ottype == "application") {
ottype=ttype
ittype=empty
}
else {
tx=split( $2, tsplit, ".")
ittype=tsplit[2]
if ( ittype == "asm" )
ottype="ASM"
else if ( ittype == "gsd" )
ottype="Gbl Svc Daemon"
else if ( ittype == "listener" )
ottype="Listener"
else if ( ittype == "scan_listener" )
ottype="SCAN Listener"
else if ( ittype == "scan_vip" )
ottype="SCAN VIP"
else if ( ittype == "oc4j" )
ottype="OC4J"
else if ( ittype == "eons" )
ottype="eons"
else if ( ittype == "ons" )
ottype="Ora Notif Svc"
else if ( ittype == "network" )
ottype="Network (VIP)"
else if ( ittype == "cluster_vip_net1" )
ottype="Cluster VIP"
else ottype=ittype
}
}
if ( $1 == "TARGET") {
ttarget=$2
tx=split( $2, targetsplit, ",")
}
if ( $1 == "STATE") {
if ( ittype == "asm" || ittype == "ons" || ittype == "eons" || ittype == "network" || ittype == "listener" ) {
stx=split( $2, statesplit, ",")
}
else {
tx=split( $2, tsplit, " ")
tstate=tsplit[1]
tnode=tsplit[3]
}
}
if ( $1 == "RESTART_COUNT") {
trestart_count=$2
tx=split( $2, restart_countsplit, ",")
}
if ( $1 == "LAST_RESTART") {
tlast_restart=$2
tx=split( $2, last_restartsplit, ",")
}
if ( $1 == "STATE_DETAILS") {
tdetail=$2
if ( ittype == "asm" || ittype == "ons" || ittype == "eons" || ittype == "network" || ittype == "listener" ) {
for (i in statesplit) {
tx=split( statesplit[i], tsplit, " ")
tstate=tsplit[1]
tnode=tsplit[3]
ttarget=targetsplit[i]
gsub(/ */,"",ttarget)
gsub(/ */,"",tstate)
if ( ttarget == "ONLINE" && tstate != "ONLINE" )
printf( "%-40s %-14s %-12s %-15s %-15s %-15s %-20s %s\n", tname, ottype, ttarget, tstate, tnode, trestart_count, tlast_restart, tdetail)
else
printf( "%-40s %-14s %-12s %-15s %-15s %-15s %-20s %s\n", tname, ottype, ttarget, tstate, tnode, trestart_count, tlast_restart, tdetail)
}
}
else {
if ( ttarget == "ONLINE" && tstate != "ONLINE" )
printf( "%-40s %-14s %-12s %-15s %-15s %-15s %-20s %s\n", tname, ottype, ttarget, tstate, tnode, trestart_count, tlast_restart, tdetail)
else
printf( "%-40s %-14s %-12s %-15s %-15s %-15s %-20s %s\n", tname, ottype, ttarget, tstate, tnode, trestart_count, tlast_restart, tdetail)
}
}
}'
# End of variable: format_crs_status_resource
format_crs_stat='
{
if ($1 == "NAME") {
tname=$2
}
if ($1 == "TYPE") {
ttype=$2
}
if ($1 == "TARGET") {
ttarget=$2
}
if ($1 == "RESTART_COUNT") {
trestart_count=$2
}
if ($1 == "LAST_RESTART") {
tlast_restart=$2
}
if ($1 == "STATE") {
split( $2, tsplit, " ")
tstate=tsplit[1]
tnode=tsplit[3]
if ( ttarget == "ONLINE" && tstate != "ONLINE" )
printf( "%-40s %-14s %-12s %-15s %-15s %-15s %-20s\n", tname, ttype, ttarget, tstate, tnode, trestart_count, tlast_restart)
else
printf( "%-40s %-14s %-12s %-15s %-15s %-15s %-20s\n", tname, ttype, ttarget, tstate, tnode, trestart_count, tlast_restart)
}
}'
# End of variable: format_crs_stat
printf "\n\n%-40s %-14s %-12s %-15s %-15s %-15s %-20s %s\n" "Resource Name" "Resource Type" "Target" "State" "Node" "Restart count" "Last Restart" "State Details"
printf "%-40s %-14s %-12s %-15s %-15s %-15s %-15s %s\n" "----------------------------------------" "--------------" "------------" "------------" "---------------" "--------------" "--------------------" "---------------"
if [[ ${GRID_VER} == "11.2" ]] ; then
format_output=${format_crs_status_resource}
if [[ -z $1 ]] ; then
${GRID_HOME}/bin/crsctl status resource -v | awk "${format_output}"
else
${GRID_HOME}/bin/crsctl status resource -v | awk "${format_output}" | grep -i "$1"
fi
else
if [[ -e ${GRID_HOME}/bin/crs_stat ]] ; then
format_output=${format_crs_stat}
if [[ -z $1 ]] ; then
${GRID_HOME}/bin/crs_stat | awk -F= "${format_output}"
else
${GRID_HOME}/bin/crs_stat | awk -F= "${format_output}" | grep -i "$1"
fi
else
echo "crs_stat was not found in the ${GRID_HOME}/bin"
fi
fi
printf "\n"
exit 0
|