Database patch set details on one server of serveral homes
=======================================================================================
Database patch set details on one server of serveral homes
How to gather OPatch inventory for all RAC Oracle Homes, regardless of role separation.
(Doc ID 1922360.1)
========================================================================================
#!/bin/bash
# File: ListAllOraHomesInv.sh (Author: Bob Clare, Oracle Support Engineer)
# Created: 21-Mar-15 Modified: 19-Sep-16
# Checks Oracle Central/Global Inventory & Local Registry (along w/OraTab &
# OraGCHomeList files) to list all active Oracle Homes & Instances, then finds
# each Home's Owner and runs OPatch from each Home as the Owner, filtering for
# just the key info. LFD is Loc[ation] File Directory, OCI is Oracle Central
# Inventory, OLR is Oracle Local Registry, rest should be self-explanatory!
export PATH=/sbin:/bin:/usr/sbin:/usr/bin ; Script=$(basename $0)
(($EUID)) && { echo "Script $Script must be run as root!" ; exit 1 ; }
# Above check for root uses a "bash-ism", but remainder is also ksh-compliant.
{ case $(uname) in SunOS ) OCILFD=/var/opt/oracle ; OLRLFD=$OCILFD ;; * )
OCILFD=/etc ; OLRLFD=$OCILFD/oracle ;; esac ; OCILOC=$OCILFD/oraInst.loc
OEMHL=$OCILFD/oragchomelist ; OLRLOC=$OLRLFD/olr.loc ; ORATAB=$OCILFD/oratab
DL=$(printf '%80s' | tr ' ' '=') ; echo $DL ; [ -r $ORATAB ] && { echo \
"Active Oracle instances (from $ORATAB):" ; cut -d# -f1 $ORATAB | cut -d: \
-f-3 -s | sort | cat -n ; echo $DL ; echo "Oracle Homes (of Active Oracle \
instances from $ORATAB):" ; cut -d# -f1 $ORATAB | cut -d: -f2 -s | sort -u | \
cat -n ; echo $DL ; } ; [ -r $OCILOC ] && { echo "Oracle Central Inventory \
Location Pointer: $OCILOC" ; OCIDIR=$(grep _loc= $OCILOC | cut -d= -f2)
[ -d $OCIDIR ] && { echo "Oracle Central Inventory Directory: $OCIDIR"
OCIXML=$OCIDIR/ContentsXML/inventory.xml ; [ -r $OCIXML ] && { echo "Oracle \
Homes in Central Inventory, except EM plugins" ; echo "(from $OCIXML):"
egrep -v 'REMOVED|sbin|plugins' $OCIXML | grep "HOME NAME=" | cut -d\" -f2,4 \
| tr '"' '=' | sort ; echo $DL ; } ; } ; } ; [ -r $OLRLOC ] && { echo "Oracle \
Local Registry Location Pointer: $OLRLOC" ; CRS_HOME=$(grep home= $OLRLOC | \
cut -d= -f2) ; [ -d $CRS_HOME ] && { echo "CRS Home: $CRS_HOME" ; CRSCFG=\
$CRS_HOME/crs/install/crsconfig_params ; [ -r $CRSCFG ] && { CRS_OWNER=\
$(grep OWNER $CRSCFG | cut -d= -f2) ; [ -n "$CRS_OWNER" ] && { echo "CRS Home \
Owner: $CRS_OWNER" ; OPATCH=$CRS_HOME/OPatch/opatch ; [ -x $OPATCH ] && su \
$CRS_OWNER -c "$OPATCH lsinv -oh $CRS_HOME -all | awk '/^List of Oracle Homes:\
$/,/^$/ { print }'" | egrep -v 'sbin|plugins' ; echo $DL ; } ; } ; } ; }
[ -r $ORATAB ] && { for OH in $(cut -d# -f1 $ORATAB | cut -d: -f2 -s | sort -u)
do OH_OWNER=$(ls -dl $OH | awk '{ print $3 }') ; [ "$OH_OWNER" == "root" ] && \
OH_OWNER=$CRS_OWNER ; ls -dl $OH ; OPATCH=$OH/OPatch/opatch ; [ -x $OPATCH ] \
&& su $OH_OWNER -c "$OPATCH lsinv -oh $OH | egrep '^Ce|^I|^O|^P|^T|from|node'"
echo $DL ; done ; } ; [ -r $OEMHL ] && { echo "Oracle Enterprise Manager OMS \
and/or Agent Homes in $OEMHL :" ; cat -bs $OEMHL ; echo $DL ; { for OH in $(\
cut -d: -f1 $OEMHL | sort -u) ; do [ -d $OH ] && { ls -dl $OH ; OH_OWNER=$(ls \
-dl $OH | awk '{ print $3 }') ; OPATCH=$OH/OPatch/opatch ; [ -x $OPATCH ] && \
su $OH_OWNER -c "$OPATCH lsinv -oh $OH | egrep '^Ce|^E|^I|^O|^P|^T|from|node'"
echo $DL ; } ; done ; } ; } ; } | tee /tmp/OPinv.log
# EOF