OSW

OSWatcher 工具

下载文档 :Metalink Doc ID 301137.1

Oswatcher 主要用于监控主机资源,如CPU,内存,网络以及私有网络等.其中私有网络需要单独配置.

需要说明的执行OSWatcher用户需要常见OS 命令 的执行权限.

如下所述.

OSW will need access to the OS utilities: top, vmstat, iostat, mpstat, netstat, and andtraceroute. These OS utilities need to be install on the system prior to running OSW. Execute permission on these utilities need to be granted to the user of OSW.

支持的平台有:

AIX

Tru 64

Solaris

HP-UNIX

Linux

  1. tar zxvf 解压osw安装文件*.tar.gz
  2. osw相应的脚本工具

l  运行Oswatcher

开始运行osw

运行OSWatcher.sh脚本,这个脚本包括两个参数

参数1:快照时间间隔,单位为秒

参数2:快照记录保持的时间,单位为小时

如,用nohup在后台运行osw:

nohup sh OSWatcher.sh 10 36 &

l  查看osw运行数据

osw运行后在osw的安装目录中会创建archive目录,目录中包括IOSTAT/VMWAT/TOP/等数据

l  中止Oswatcher

使用stopOSW.sh脚本

例1

表示60s 搜集1次,保存10小时

./startOSW.sh 60 10

例2

默认是30s搜集1次,保存24小时

./startOSW.sh

例3

默认60s搜集1次,保存10小时

nohup ./startOSW.sh 60 10 &

l  配置私有网络监控

如果需要监控私有网络,可以使用Exampleprivate.net 的参考,建立private.net ,并且给予执行权限,并且使用下面的内容拷内进去,之后运行Oswatcher 即可 . 不同操作系统的建立方法不一样.参见如下:

 chmod 777 private.net

d

######################################################################

#Solaris Example

######################################################################

echo "zzz ***"`date`

traceroute -r -F node1

traceroute -r -F node2

######################################################################

#HP Example

######################################################################

echo "zzz ***"`date`

traceroute -r -F node1

traceroute -r -F node2

######################################################################

#Linux Example

######################################################################

echo "zzz ***"`date`

traceroute -r -F node1

traceroute -r -F node2

######################################################################

#Tru64 Example

######################################################################

echo "zzz ***"`date`

traceroute -r -f node1

traceroute -r -f node2

######################################################################

#AIX Example

######################################################################

echo "zzz ***"`date`

traceroute -r node1

traceroute -r node2

######################################################################

# DO NOT DELETE THE FOLLOWING LINE!!!!!!!!!!!!!!!!!!!!!

#

######################################################################

rm locks/lock.file

可以使用下面命令收集间隔1小时OSWatcher 日志。

#cd /opt/oracle.oswatcher/osw/archive

###for linux

#find . -name "*12.09.14.1[6-7]*" -exec zip /tmp/osw_`hostname`_120914_1617.zip {} ;

<<--------12.09.14.1[6-7] 表示12年09月14日下午16点到17点的,使用时需要替换这个时间。

 ###for aix     “” |“” 的 stdout  放在第二句的 最后  {}

 find . -name "*18.09.11.0[0-2]*"  |xargs tar -cvUf  /tmp/osw_`hostname`_180911_0002.tar

#find . -name "*12.09.14.1[6-7]*"  |xargs tar crvf  /tmp/osw_`hostname`_120914_1617.tar

<<--------12.09.14.1[6-7] 表示12年09月14日下午16点到17点的,使用时需要替换这个时间。

 ###hp

find . -name "*18.09.1[0-6].*" |xargs tar -cvf /tmp/osw_`hostname`_180911_0002.tar
find . -name "*18.09.1[0-6].*" |xargs tar -rvf /tmp/osw_`hostname`_180911_0002.tar

############解析OSW


五、启动OSWg.jar,以便调用图形界面

将路径切换到osw目录下:$cd /home/oracle/osw

然后执行以下语句:$java -jar OSWg.jar -i /home/oracle/osw/archive --这里要找到archive目录

--一般建议分析1个小时OSW 即可,太多时间,图标不准

注意:

1.在执行过程中,要想退出图形界面,要按Q键来退出;

2.若要想退出osw(即startOSW.sh),停止OSW 服务,通过stopOSW.sh来完成../stopOSW.sh 或者 ./stopOWSbb.sh

#############设置OSW 自动启动脚本。(if 判断后台启动 的 cron)

1.vi OSW_init.sh

##default 30s 搜集1次, keep 360 or 120小时
#!/bin/ksh
#Program : OSW_init.sh
#Author :
#Document : This is the main program,checks OSW stat staus
#

SYSTEM=`uname -s` #;qH!2YWwO5M3@`PM

SCRIPTLOC=/orabak/oswbb/oswbb

export SCRIPTLOC

db_stat=`ps -ef | grep pmon | grep -v grep| cut -f3 -d_ |wc -l`
if [ $db_stat -eq 0 ];then
exit 1
fi

if [ $SYSTEM = "Linux" ] ; then 
echo "Linux"

osw_stat=`ps -ef|grep OSW|grep -v grep| wc -l`
osw_chk=`expr $osw_stat`
if [ $osw_chk -eq 3 ]
then
cd $SCRIPTLOC
$SCRIPTLOC/OSWatcher.sh 30 360
fi

elif [ $SYSTEM = "HP-UX" ] ; then       
echo "HP-UNIX"
`ps -ef|grep OSW|grep -v grep >/tmp/2.log`
osw_stat=`ps -ef|grep OSW|grep -v grep| wc -l`
osw_chk=`expr $osw_stat`
if [ $osw_chk -eq 2 ]
then
cd $SCRIPTLOC
$SCRIPTLOC/OSWatcher.sh 30 360
fi


else
echo "Unix"
`ps -ef|grep OSW|grep -v grep >/tmp/2.log`
osw_stat=`ps -ef|grep OSW|grep -v grep| wc -l`
osw_chk=`expr $osw_stat`
if [ $osw_chk -eq 1 ]
then
cd $SCRIPTLOC
$SCRIPTLOC/OSWatcher.sh 30 360
fi

fi

echo "OSW exec result $? " >> /tmp/osw/osw.log

exit 0

#######
2.
chmod 770 /orabak/oswbb/oswbb/OSW_init.sh


3.crontab -e

38 14 * * * sh /orabak/oswbb/oswbb/OSW_init.sh

###38 14 * * * sh /orabak/oswbb/oswbb/OSW_init.sh 2>&1

 notice :

check if log is ok , file is under  /orabak/oswbb/oswbb/archive/oswtop/*.dat

 ########

###########sample :

31 16 * * * sh /orabak/oswbb/oswbb/OSW_init.sh > /tmp/1.log

unix AIX: 使用cron fork 出一个OSW进程

[root@nbutest1:/]# ps -ef|grep OSW 
root 11862018 19202296 0 Nov 30 - 0:32 /bin/sh ./OSWatcherFM.sh 360 /oradata/oswbb/oswbb/archive 《— 第三级子进程
root 12910804 21889042 0 16:02:00 pts/5 0:00 grep OSW
root 19202296 29818988 0 Nov 30 - 1:14 /bin/sh /oradata/oswbb/oswbb/OSWatcher.sh 30 360 <- 第二级子进程
root 29818988 6815964 0 Nov 30 - 0:00 sh /oradata/oswbb/oswbb/OSW_init.sh <- 第一级子进程
[root@nbutest1:/]# ps -ef|grep 6815964 
root 6815964 1 0 Sep 15 - 0:53 /usr/sbin/cron <- 这是父进程,父进程是cron
root 29818988 6815964 0 Nov 30 - 0:00 sh /oradata/oswbb/oswbb/OSW_init.sh
root 32833782 21889042 0 16:03:07 pts/5 0:00 grep 6815964

linux: 使用cron fork 出3个OWS进程


[root@nbutest:/orabak/oswbb/oswbb]# more /tmp/2.log
root 10127 10126 0 16:26 ? 00:00:00 /bin/sh -c sh /orabak/oswbb/oswbb/OSW_init.sh > /tmp/1.log <- 第一级子进程
root 10128 10127 0 16:26 ? 00:00:00 sh /orabak/oswbb/oswbb/OSW_init.sh <- 第二级子进程 
root 10136 10128 0 16:26 ? 00:00:00 sh /orabak/oswbb/oswbb/OSW_init.sh <- 第三级子进程


[root@nbutest:/orabak/oswbb/oswbb]# ps -ef|grep 10126 
root 10126 5076 0 16:26 ? 00:00:00 crond <- 这是父进程,父进程是cron


unix HP-UNIX 使用cron fork 出2个OSW进程

[root@nbutest2:/]# more /tmp/2.log
root 20751 6990 2 16:31:00 ? 0:00 sh -c sh /orabak/oswbb/oswbb/OSW_init.sh > /tmp/1.log
root 20752 20751 0 16:31:00 ? 0:00 sh /orabak/oswbb/oswbb/OSW_init.sh

####201912 更新  TFA 自动初始化 OSW

https://blogs.oracle.com/database4cn/tfa

https://www.cnblogs.com/DataArt/p/10018773.html
通过检查发现,11G RAC PSU 201810 后的 和12C RAC,会自动集成TFA 运行在系统上.
存储目录是放在GI_HOME目录下,默认是每30秒执行一次,保留时间为48小时(2天)
所以新版本rac 11G PSU 201810或者12c rac 不需要部署OSW_init.sh.

配置信息如下:
[root@pDBdb02:/home/root]# /DB/DB/grid/11.2.0/bin/tfactl

tfactl> toolstatus
.----------------------------------------.
| External Support Tools |
+-----------+--------------+-------------+
| Host | Tool | Status |
+-----------+--------------+-------------+
| pDBdb02 | alertsummary | DEPLOYED |
| pDBdb02 | exachk | DEPLOYED |
| pDBdb02 | ls | DEPLOYED |
| pDBdb02 | pstack | DEPLOYED |
| pDBdb02 | orachk | DEPLOYED |
| pDBdb02 | sqlt | DEPLOYED |
| pDBdb02 | grep | DEPLOYED |
| pDBdb02 | summary | DEPLOYED |
| pDBdb02 | prw | NOT RUNNING |
| pDBdb02 | vi | DEPLOYED |
| pDBdb02 | tail | DEPLOYED |
| pDBdb02 | param | DEPLOYED |
| pDBdb02 | dbglevel | DEPLOYED |
| pDBdb02 | darda | DEPLOYED |
| pDBdb02 | history | DEPLOYED |
| pDBdb02 | oratop | DEPLOYED |
| pDBdb02 | oswbb | RUNNING |
| pDBdb02 | dbperf | DEPLOYED |
| pDBdb02 | changes | DEPLOYED |
| pDBdb02 | events | DEPLOYED |
| pDBdb02 | ps | DEPLOYED |
| pDBdb02 | srdc | DEPLOYED |
'-----------+--------------+-------------'
tfactl>

进程信息如下:

[grid@pDBdb02:/home/grid]$ ps -ef|grep OSW
grid 10551620 1 0 Nov 16 - 3:32 /bin/sh ./OSWatcher.sh 30 48 NONE /DB/DB/app/grid/tfa/repository/suptools/pDBdb02/oswbb/grid/archive
grid 9306984 10551620 0 Nov 16 - 1:55 /bin/sh ./OSWatcherFM.sh 48 /DB/DB/app/grid/tfa/repository/suptools/pDBdb02/oswbb/grid/archive

############部署OSW

 ### tar 的使用 http://www.cnblogs.com/feiyun8616/p/6180056.html

######the script is used to for deploy osw,it will prompt the password and yes
######保留时间360hours, 每隔30second 收集一次

cd /orabak
mkdir oswbb
--scp root@10.200.210.187:/backup/dba/oswbb810.tar /orabak/oswbb

ftp -v -n 10.200.210.187 << END
user root 123456
binary
hash
prompt
cd /orabak/oswbb
lcd /backup/dba/
get osw*.tar
bye
END


cd oswbb
tar xvf *.tar
cd oswbb

mkdir /tmp/osw
nohup /orabak/oswbb/oswbb/OSWatcher.sh 30 360 &

notice:

when tar xvf *.tar ,it will report below info, please ignore


tar: Read 6874 bytes from oswbb810.tar
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

###########paackage and ansylst  osw data

method 1: 
##########step 1 collect osw data in source
###below parameter is for yy(t1),mm(t2),dd(t3),T(t4),T(T5) ,就是17年11月20日22到23点
export t1=17
export t2=11
export t3=20
export t4=0
export t5="2-3"
export db=esb

mkdir /tmp/dba
cd /orabak/oswbb/oswbb/archive

###view 2017 11/20 2点到3点 osw 日志 , linux zip
#find . -name "*17.11.20.2[2-3]*" -exec zip
#/tmp/osw_`hostname`_171120_0203.zip {} ;

for linux

find . -name "*$t1.$t2.$t3.$t4[$t5]*"|xargs tar -crvf /tmp/dba/osw_`hostname`_`date '+%y%m%d'`.tar

###for every day data
####find . -name "*$t1.$t2.*.$t4[$t5]*"|xargs tar -crvf /tmp/dba/osw_`hostname`_`date '+%y%m%d'`.tar

gzip /tmp/dba/osw_`hostname`_`date '+%y%m%d'`.tar

####step 2: upload data to 10.200.210.187 /orabak/oswbb/archive/anaylst

ftp -v -n 10.200.210.187 << END
user root 123456
binary
hash
prompt
cd /orabak/oswbb/archive/analyst
lcd /tmp/dba
mput osw*.tar.gz
bye
END

rm /tmp/dba/*.tar.gz

method 2:

 cd /orabak/oswbb/oswbb/archive

 scp -rp *  root@10.200.210.187:/tmp/dba

##promtp password


########## running in yumserver step 3 use vncserver passwd:123456

method 1:


cd /tmp
gunzip /orabak/oswbb/archive/analyst/*.tar.gz
tar xvf /orabak/oswbb/archive/analyst/*.tar
cd /orabak/oswbb
java -jar oswbba.jar -i /tmp

rm -rf /tmp/osw*
rm -f /orabak/oswbb/archive/analyst/*.tar

method 2: 

java -jar /orabak/oswbb/oswbba.jar -i /tmp/dba

rm -rf /tmp/dba/*

 ####分析 :

选项 D  生成 文件 到 当前 目录 下 

选项A  分析并生成 一个 analyst.txt 的文件 

###dashboard 文件怎么看

sample 1:

图中PM 指的是从这个点开始 是下午 ,也就是上午和下午的分界线。

sample 2:

查看idle 进程应该反过来看看。也就是灰色部分是idle 部分。

sample 3: 

查看   dashborad/index.html

Linux DBS: 4 VCPUS: 8 SNAPS: 30

(cpu 8核,30 second /per )

##### anlyst.txt 怎么看


-》 ############################################################################
# Section 3: System General Findings
#
# This section lists all general findings that require attention. Each
# finding has a status along with a subsystem. Further advice may also
# available regarding the finding.
#


-》CPU UTILIZATION: The following snaps recorded cpu utilization of 100% busy:
SnapTime

-》

#######################################################################################
# Section 8.3: PS for (Processes with CPU > 0) When System Idle CPU < 30% Ordered By Time
# In this section list all processes captured in the oswbb logs with process cpu consumption
# > 0 and system idle cpu < 30%
#

-》

Section 8.5: Top RSS Processes Increasing Memory Per Snapshot

->>

CPU UTILIZATION: The following snaps recorded ROOT processes using high percent cpu:

-->>

# Section 8.2: PS for Processes With Status = D, T or W Ordered By Time
# In this section list all processes captured in the oswbb logs which have a
# status of D, T or W
#

###EXPLAIN:

  Linux是一个多用户,多任务的系统,可以同时运行多个用户的多个程序,就必然会产生很多的进程,而每个进程会有不同的状态。  在下文将对进程的

R、S、D、T、Z、X 六种状态做个说明。

PROCESS STATE CODES

       Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process.

       D    Uninterruptible sleep (usually IO)

       R    Running or runnable (on run queue)

       S    Interruptible sleep (waiting for an event to complete)

       T    Stopped, either by a job control signal or because it is being traced.

       W    paging (not valid since the 2.6.xx kernel)

       X    dead (should never be seen)

#####

##

附录:

/etc/inittab文件中每个登记项的结构都是一样的,共分为以冒号“:”分隔的4个字段。具体如下: 
      identifier :  run_level  :  action  :  process 
其中,各字段以及与其相关的说明如下: 
identifier  登记项标识符,最多为4个字符。用于惟一地标识/etc/inittab文件中的每一个登记项 

run_level  系统运行级,即执行登记项的init级别。用于指定相应的登记项适用于哪一个运行级,即在哪一个运行级中被处理。如果该字段为空,那么相应的登记项将适用于所有的运行级。在该字段中,可以同时指定一个或多个运行级,其中各运行级分别以数字0.1.2.3.4.5.6或字母a、b、c表示,且无需对其进行分隔。 

action    动作关键字。用于指定init(M)命令或进程对相应进程(在“process”字段定义)所实施的动作。具体动作包括: 
  1、boot:只有在引导过程中,才执行该进程,但不等待该进程的结束;当该进程死亡时,也不重新启动该进程。 
  2、bootwait:只有在引导过程中,才执行该进程,并等待进程的结束:当该进程死亡时,也不重新启动该进程。实际上,只有在系统被引导后,并从单用户方式进入多用户方式时,这些登记项才被处理;如果系统的默认运行级设置为2(即多用户方式),那么这些登记项在系统引导后将马上被处理。 
  3、initdefault:指定系统的默认运行级。系统启动时,init将首先查找该登记项。如果存在init将据此决定系统最初要进入的运行级。具体来说,init将指定登记项“run_level"字段中的最大数字(即最高运行级)为当前系统的默认运行级;如果该字段为空,那么将其解释为“0123456”,并以“6”作为默认运行级。如果不存在该登记项,那么init将要求用户在系统启动时指定一个最初的运行级。 
  4、off:如果相应的进程正在运行,那么就发出一个警告信号,等待20秒后,再通过杀死信号强行终止该进程。如果相应的进程并不存在那么就忽略该登记项。 
  5、once:启动相应的进程,但不等待该进程结束便继续处理/etc/inittab文件中的下一个登记项;当该进程死亡时,init也不重新启动该进程。注意:在从一个运行级进入另一个运行级时,如果相应的进程仍然在运行,那么init就不重新启动该进程。 
  6、ondemand:与“respawn”的功能完全相同,但只用于运行级为a、b或c的登记项。 
  7、powerfail:只在init接收到电源失败信号时执行相应的进程,但不等待该进程结束。 
  8、powerwait:只在init接收到电源失败信号时执行相应的进程,并在继续对/etc/inittab文件进行任何处理前等待该进程结束。 
  9、respawn:如果相应的进程还不存在,那么init就启动该进程,同时不等待该进程的结束就继续扫描/etc/inittab文件;当该进程死亡时,init将重新启动该进程。如果相应的进程已经存在,那么init将忽略该登记项并继续扫描/etc/inittab文件。 
  10、sysinit:只有在启动或重新启动系统并首先进入单用户时,init才执行这些登记项。而在系统从运行级1-6进入单用户方式时,init并不执行这些登记项。"action”字段为“sysinit”的登记项在“run_level”字段不指定任何运行级。 
  11、wait:启动进程并等待其结束,然后再处理/etc/inittab文件中的下一个登记项。 

   
  process   所要执行的shell命令。任何合法的shell语法均适用于该字段。 

inittab详细介绍

init进程是系统中所有进程的父进程,init进程繁衍出完成通常操作所需的子进程,这些操作包括:设置机器名、检查和安装磁盘及文件系统、启动系统日志、配置网络接口并启动网络和邮件服务,启动打印服务等。Solarisinit进程的主要任务是按照inittab文件所提供的信息创建进程,由于进行系统初始化的那些进程都由init创建,所以init进程也称为系统初始化进程。

    下面具体说明inittab文件的格式。

  inittab文件中每一记录都从新的一行开始,每个记录项最多可有512个字符,每一项的格式通常如下:id:rstate:action:process,下面分别解释。

  1. id字段是最多4个字符的字符串,用来唯一标志表项。

  2. rstate(run state)字段定义该记录项被调用时的运行级别,rstate可以由一个或多个运行级别构成,也可以是空,空则代表运行级别06。当请求init改变运行级别时,那些rstate字段中不包括新运行级别的进程将收到SIGTERM警告信号,并且最后被杀死;只有abc启动的命令外(abc不是真正的运行级别)

  3.action字段告诉init执行的动作,即如何处理process字段指定的进程,action字段允许的值及对应的动作分别为:

  1)respawn:如果process字段指定的进程不存在,则启动该进程,init不等待处理结束,而是继续扫描inittab文件中的后续进程,当这样的进程终止时,init会重新启动它,如果这样的进程已存在,则什么也不做。

  2)wait:启动process字段指定的进程,并等到处理结束才去处理inittab中的下一记录项。

  3)once:启动process字段指定的进程,不等待处理结束就去处理下一记录项。当这样的进程终止时,也不再重新启动它,在进入新的运行级别时,如果这样的进程仍在运行,init也不重新启动它。

  4)boot:只有在系统启动时,init才处理这样的记录项,启动相应进程,并不等待处理结束就去处理下一个记录项。当这样的进程终止时,系统也不重启它。

  5)bootwait:系统启动后,当第一次从单用户模式

#########sample 2 脚本收集日志,上传到SR

#!/bin/ksh
##the shell is collect os base info like memory and filesystem and system info and all oracle log and crs log
crs_log_collect()
{
##find /db -name
find /db -name crsd.log | xargs -I{} tail -100000 {} >> /tmp/check/crsd.log
##find /db -name
find /db -name ocssd.log | xargs -I{} tail -100000 {} >> /tmp/check/ocssd.log
##find /db -name
find /db -name evmd.log | xargs -I{} tail -100000 {} >> /tmp/check/evmd.log
##find /db -name
find /db -name alert`hostname`.log | xargs -I{} tail -100000 {} >> /tmp/check/alert`hostname`.log
##find /db -name
find /db -name oraagent_grid.log | xargs -I{} tail -100000 {} >> /tmp/check/oraagent_grid.log
###find /db
find /db -name alert_*.log | xargs -I{} tail -100000 {} >> /tmp/check/alert_db.log
###find /db
find /db -name alert_+*.log | xargs -I{} tail -100000 {} >> /tmp/check/alert_+ASM.log
###find /db
find /db -name ohasd.log | xargs -I{} tail -100000 {} >> /tmp/check/ohasd.log
tar -cvf - * |gzip > `hostname`_crs.tar.gz
cd /tmp/check
rm *.log
}

if [ ! -d "/tmp/check" ]; then
mkdir /tmp/check
fi

cd $HOME
OSNAME=`uname`
case $OSNAME in
SunOS) OSNAME=1 ;;
HP-UX) OSNAME=2 ;;
AIX) OSNAME=3 ;;
Linux) OSNAME=4 ;;
esac
if [ $OSNAME -eq 4 ]
then

cd /tmp/check
rm *.gz
echo "****filesystem****" >> os.log
df -h >> os.log
echo "****oslevel****" >> os.log
lsb_release -a |grep Release >> os.log
echo "****memory****" >> os.log
free -m >> os.log
echo "****boot info ****" >> os.log
cat /proc/meminfo >> os.log
echo "**** vmstat ****" >> os.log
vmstat 1 10 >> os.log
echo "**** iostat ****" >> os.log
iostat 1 10 >> os.log
echo "**** opatch ****" >> os.log
usernum=`ps -ef|grep grid|wc -l`
if [ $usernum -gt 1 ]
then
opatch=`find /db -name opatch|grep -v opatchprereqs | head -1`
/bin/su - grid -c "$opatch lsinventory" >> opatch.log
else
user=`ps -ef|grep ora_pmon|grep -v grep| head -1|awk '{print $1}'`
opatch=`find /db -name opatch|grep -v opatchprereqs | head -1`
/bin/su - $user -c "$opatch lsinventory " >> opatch.log
fi
echo "**** log ****" >> os.log
crs_log_collect

elif [ $OSNAME -eq 3 ]
then

cd /tmp/check
rm *.gz
echo "****filesystem****" >> os.log
df -g >> os.log
echo "****oslevel****" >> os.log
oslevel -s >> os.log
echo "****memory****" >> os.log
lsdev -Cc memory >> os.log
echo "****boot info ****" >> os.log
bootinfo -r >> os.log
echo "**** vmstat ****" >> os.log
vmstat 1 10 >> os.log
echo "**** iostat ****" >> os.log
iostat 1 10 >> os.log
echo "**** opatch ****" >> os.log
usernum=`ps -ef|grep grid|wc -l`
if [ $usernum -gt 1 ]
then
opatch=`find /db -name opatch|grep -v opatchprereqs | head -1`
su - grid -c "$opatch lsinventory" >> opatch.log
else
user=`ps -ef|grep ora_pmon|grep -v grep| head -1|awk '{print $1}'`
opatch=`find /db -name opatch|grep -v opatchprereqs | head -1`
su - $user -c "$opatch lsinventory " >> opatch.log
fi
echo "**** log ****" >> os.log
crs_log_collect

else
echo 'else'
fi

原文地址:https://www.cnblogs.com/feiyun8616/p/7028847.html