Tuesday, November 05, 2013

Play: automate Start/Stop OSWBB on Linux

I installed OSWatcher on Linux and want to Start OSWatcher Black Box (OSWBB) every system boot. I suggest you download package on Oracle Support - How To Start OSWatcher Black Box (OSWBB) Every System Boot (Doc ID 580513.1). If not? You might write simple script.
Install:
[oracle@test12c ~]$ pwd
/home/oracle
[oracle@test12c ~]$ ls oswbb601.tar
oswbb601.tar
[oracle@test12c ~]$ tar xf oswbb601.tar
[oracle@test12c ~]$ ls oswbb
analysis    call_sar.sh         extras.txt      iosub.sh  nfssub.sh       oswbba.jar  oswrds.sh  pssub.sh       stopOSWbb.sh   topaix.sh
archive     docs                gif             locks     OSWatcherFM.sh  oswib.sh    oswsub.sh  src            tarupfiles.sh  vmsub.sh
call_du.sh  Exampleprivate.net  init_oswbb.log  mpsub.sh  OSWatcher.sh    oswnet.sh   profile    startOSWbb.sh  tmp            xtop.sh
Example script:
#!/bin/bash
#
# chkconfig: 2345 15 90
# description: Starts and stops the OSWatcher
#
#
OSWBB_SRC_DIR=/home/oracle/oswbb
echo $OSWBB_SRC_DIR
echo "******************************************************" >> $OSWBB_SRC_DIR/init_oswbb.log
case $1 in
'start')
        echo "...Starting OSWBB from init at `date` " >> $OSWBB_SRC_DIR/init_oswbb.log
        su oracle -c "cd $OSWBB_SRC_DIR; ./startOSWbb.sh 60 72"
        touch /var/lock/subsys/oswatcher
;;
'stop')
        echo "...Stopping OSWBB from init at `date` " >> $OSWBB_SRC_DIR/init_oswbb.log
        su oracle -c "cd $OSWBB_SRC_DIR; ./stopOSWbb.sh"
        rm -f /var/lock/subsys/oswatcher
;;
'status')
        ps -aef |grep OSWatcher |grep -v grep
;;
*)
        echo "Usage: $0 start|stop" >&2
        exit 1
;;
esac
exit 0
Test Script:
[root@test12c init.d]# pwd
/etc/init.d
[root@test12c init.d]# ls -l oswatcher
-rwxr-xr-x. 1 root root 720 Nov  5 10:30 oswatcher
[root@test12c init.d]# cat oswatcher
#!/bin/bash
#
# chkconfig: 2345 15 90
# description: Starts and stops the OSWatcher
#
#
OSWBB_SRC_DIR=/home/oracle/oswbb
echo $OSWBB_SRC_DIR
echo "******************************************************" >> $OSWBB_SRC_DIR/init_oswbb.log
case $1 in
'start')
        echo "...Starting OSWBB from init at `date` " >> $OSWBB_SRC_DIR/init_oswbb.log
        su oracle -c "cd $OSWBB_SRC_DIR; ./startOSWbb.sh 60 72"
        touch /var/lock/subsys/oswatcher
;;
'stop')
        echo "...Stopping OSWBB from init at `date` " >> $OSWBB_SRC_DIR/init_oswbb.log
        su oracle -c "cd $OSWBB_SRC_DIR; ./stopOSWbb.sh"
        rm -f /var/lock/subsys/oswatcher
;;
'status')
        ps -aef |grep OSWatcher |grep -v grep
;;
*)
        echo "Usage: $0 start|stop" >&2
        exit 1
;;
esac
exit 0
[root@test12c init.d]# chkconfig --add oswatcher
[root@test12c init.d]# chkconfig --list oswatcher
oswatcher       0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@test12c init.d]# service oswatcher status
/home/oracle/oswbb
oracle   15004     1  0 10:20 ?        00:00:00 /bin/sh ./OSWatcher.sh 60 72
oracle   15146 15004  0 10:21 ?        00:00:00 /bin/sh ./OSWatcherFM.sh 72 /home/oracle/oswbb/archive
[root@test12c init.d]# service oswatcher stop
/home/oracle/oswbb
[root@test12c init.d]# service oswatcher status
/home/oracle/oswbb
[root@test12c init.d]# service oswatcher start
/home/oracle/oswbb
[root@test12c init.d]# Setting the archive log directory to/home/oracle/oswbb/archive
Testing for discovery of OS Utilities...
VMSTAT found on your system.
IOSTAT found on your system.
MPSTAT found on your system.
NETSTAT found on your system.
TOP found on your system.
Testing for discovery of OS CPU COUNT
oswbb is looking for the CPU COUNT on your system
CPU COUNT will be used by oswbba to automatically look for cpu problems
CPU COUNT found on your system.
CPU COUNT = 1
Discovery completed.
Starting OSWatcher Black Box v6.0.1  on Tue Nov 5 10:33:49 ICT 2013
With SnapshotInterval = 60
With ArchiveInterval = 72
OSWatcher Black Box - Written by Carl Davis, Center of Expertise,
Oracle Corporation
For questions on install/usage please go to MOS (Note:301137.1)
If you need further assistance or have comments or enhancement
requests you can email me Carl.Davis@Oracle.com
Data is stored in directory: /home/oracle/oswbb/archive
Starting Data Collection...
oswbb heartbeat:Tue Nov 5 10:33:54 ICT 2013
[root@test12c init.d]# service oswatcher status
/home/oracle/oswbb
oracle   21561     1  0 10:33 ?        00:00:00 /bin/sh ./OSWatcher.sh 60 72
oracle   21730 21561  0 10:33 ?        00:00:00 /bin/sh ./OSWatcherFM.sh 72 /home/oracle/oswbb/archive
[root@test12c init.d]#
After Rebooted!
[root@test12c ~]# service oswatcher status
/home/oracle/oswbb
oracle    1092     1  0 10:36 ?        00:00:00 /bin/sh ./OSWatcher.sh 60 72
oracle    1547  1092  0 10:37 ?        00:00:00 /bin/sh ./OSWatcherFM.sh 72 /home/oracle/oswbb/archive
[root@test12c ~]#
What if you can download "oswbb-service*.rpm" on Oracle Support.
[root@test12c oracle]# ls -l oswbb-service-1.1.5-1.noarch.rpm
-rw-r--r--. 1 oracle oinstall 5431 Nov  5 11:39 oswbb-service-1.1.5-1.noarch.rpm
[root@test12c oracle]# rpm --query --filesbypkg --package oswbb-service-1.1.5-1.noarch.rpm
oswbb-service             /etc/init.d/oswbb
oswbb-service             /etc/oswbb.conf
oswbb-service             /usr/libexec/oswbb-service/oswbb-helper
oswbb-service             /usr/share/doc/oswbb-service-1.1.5
oswbb-service             /usr/share/doc/oswbb-service-1.1.5/AUTHORS
oswbb-service             /usr/share/doc/oswbb-service-1.1.5/ChangeLog
oswbb-service             /usr/share/doc/oswbb-service-1.1.5/NEWS
oswbb-service             /usr/share/doc/oswbb-service-1.1.5/README
[root@test12c oracle]# rpm -ivh oswbb-service-1.1.5-1.noarch.rpm
Preparing...                ########################################### [100%]
   1:oswbb-service          ########################################### [100%]
[root@test12c oracle]#
[root@test12c oracle]# /etc/init.d/oswbb status
OSWatcher is not running.
[root@test12c oracle]# chkconfig --list oswbb
oswbb           0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@test12c oracle]# vi /etc/oswbb.conf
[root@test12c oracle]# cp /etc/oswbb.conf /etc/oswbb.conf.orig
[root@test12c oracle]# vi /etc/oswbb.conf
[root@test12c oracle]#
[root@test12c oracle]# diff /etc/oswbb.conf.orig /etc/oswbb.conf
2c2
< OSW_HOME='/opt/oswbb'
---
> OSW_HOME='/home/oracle/oswbb'
4c4
< OSW_INTERVAL='30'
---
> OSW_INTERVAL='60'
6c6
< OSW_RETENTION='48'
---
> OSW_RETENTION='72'
8c8
< OSW_USER='root'
---
> OSW_USER='oracle'
[root@test12c oracle]# /etc/init.d/oswbb status
OSWatcher is not running.
[root@test12c oracle]# ps -aef |grep -i oswatch
root     12196  6176  0 11:54 pts/0    00:00:00 grep -i oswatch
[root@test12c oracle]# /etc/init.d/oswbb start
Starting OSWatcher:                                        [  OK  ]
[root@test12c oracle]# ps -aef |grep -i oswatch
oracle   12216     1  0 11:55 ?        00:00:00 /bin/sh ./OSWatcher.sh 60 72 gzip
oracle   12364 12216  0 11:55 ?        00:00:00 /bin/sh ./OSWatcherFM.sh 72 /home/oracle/oswbb/archive
root     12860  6176  0 11:55 pts/0    00:00:00 grep -i oswatch
[root@test12c oracle]# /etc/init.d/oswbb status
OSWatcher is running.
You will see. It's very easy -:)

Related Post:
Use OSWatcher

No comments: