Thursday, January 30, 2014

Script checks for Fusion Middleware OID process running or not and send an email. ..

#!/bin/ksh

 export MW_HOME=/u01/app/oracle/Middleware

export INSTANCE_HOME=/u01/app/oracle/Middleware/asinst_1

 ## Script compatable with FMW11g OID on Linux EL5 ###

oidps1=`ps -ef | grep oidldapd | grep "inst=1" | grep -v grep | awk '{print $2}'`

oidps2=`ps -ef | grep oidldapd | grep "control" |grep -v grep | awk '{print $2}'`

oidld1=`/u01/app/oracle/Middleware/asinst_1/bin/opmnctl status | grep $oidps1 | awk '{print $7}'`

oidld2=`/u01/app/oracle/Middleware/asinst_1/bin/opmnctl status | grep $oidps2 | awk '{print $7}'`

oidmon=`/u01/app/oracle/Middleware/asinst_1/bin/opmnctl status | grep oidmon| awk '{print $7}'`

oidem=`/u01/app/oracle/Middleware/asinst_1/bin/opmnctl status | grep EMAGENT | awk '{print $7}'`



if [ "$oidld1" == "Alive" ] && [ "$oidld2" == "Alive" ] && [ "$oidmon" == "Alive" ] && [ "$oidem" == "Alive" ];

then

echo "OID running"

echo "OID ldap Services are running " > /u01/app/oracle/ldap_scripts/ldap_running.txt

date >> /u01/app/oracle/ldap_scripts/ldap_running.txt

/u01/app/oracle/Middleware/asinst_1/bin/opmnctl status >> /u01/app/oracle/ldap_scripts/ldap_running.txt

mailx -s "OID processes are running on OID Server" test@test.com < /u01/app/oracle/ldap_scripts/ldap_running.txt

else

echo "failed"

mailx -s "OID processes are not running on OID Server" test@test.com < /u01/app/oracle/ldap_scripts/ldap_start_stop_process.txt

fi

====== ldap_start_stop_process.txt == File output ========

#######################################################################################
LDAP OID Services stop / Start procedure
#######################################################################################

INSTANCE_HOME=/u01/app/oracle/Middleware/asinst_1/bin/

MW_HOME=/u01/app/oracle/Middleware/

 ### LDAP Services Status Check ###

/u01/app/oracle/Middleware/asinst_1/bin/opmnctl status

### LDAP Services Stop all services ###

/u01/app/oracle/Middleware/asinst_1/bin/opmnctl stopall

### LDAP Services Start all services ###

/u01/app/oracle/Middleware/asinst_1/bin/opmnctl startall

===== Script End opmnctl status sample output ==============

oidsrv1$

oidsrv1$ /u01/app/oracle/Middleware/asinst_1/bin/opmnctl status

Processes in Instance: asinst_1

---------------------------------+--------------------+---------+---------

ias-component                    | process-type       |     pid | status

---------------------------------+--------------------+---------+---------

oid1                             | oidldapd           |    4962 | Alive

oid1                             | oidldapd           |    4953 | Alive

oid1                             | oidmon             |    4914 | Alive

EMAGENT                  | EMAGENT     |    4912 | Alive

 oidsrv1$

Switchover and Switch back standby database using DGMGRL - log

----- Switch over ------

[oaracle@orasrv1](DB11@ORADB_1):/u01/app/oracle/product/11.2.0/db_1/dbs\>dgmgrl
DGMGRL for Linux: Version 11.2.0.2.0 - 64bit Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys
Password:
Connected.
DGMGRL> show configuration

Configuration - itii_itio_ORADB

  Protection Mode: MaxPerformance
  Databases:
    ORADB   - Primary database
    ORADBdr - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> switchover to ORADBdr;
Performing switchover NOW, please wait...
New primary database "ORADBdr" is opening...
Operation requires shutdown of instance "ORADB_1" on database "ORADB"
Shutting down instance "ORADB_1"...
ORACLE instance shut down.
Operation requires startup of instance "ORADB_1" on database "ORADB"
Starting instance "ORADB_1"...
Unable to connect to database
ORA-12514: TNS:listener does not currently know of service requested in connect de                                                                           scriptor

Failed.
Warning: You are no longer connected to ORACLE.

Please complete the following steps to finish switchover:
        start up and mount instance "ORADB_1" of database "ORADB"

DGMGRL> DGMGRL>

---- Startup the database ORADB
1. Startup nomount
2. Alter database mount standby database disconnect.

--- Switch back -----

[oracle@orasrv1](DB11@ORADB_1):/u01/app/oracle/product/11.2.0/db_1/dbs\>dgmgrl
DGMGRL for Linux: Version 11.2.0.2.0 - 64bit Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys
Password:
Connected.
DGMGRL> show configuration

Configuration - itii_itio_ORADB

  Protection Mode: MaxPerformance
  Databases:
    ORADBdr - Primary database
    ORADB   - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> switchover to ORADB;
Performing switchover NOW, please wait...
New primary database "ORADB" is opening...
Operation requires shutdown of instance "ORADBDR_1" on database "ORADBdr"
Shutting down instance "ORADBDR_1"...
ORACLE instance shut down.
Operation requires startup of instance "ORADBDR_1" on database "ORADBdr"
Starting instance "ORADBDR_1"...
Unable to connect to database
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

Failed.
Warning: You are no longer connected to ORACLE.

Please complete the following steps to finish switchover:
        start up and mount instance "ORADBDR_1" of database "ORADBdr"

DGMGRL> exit

---- Startup the database ORADBDR

1. Startup nomount
2. Alter database mount standby database disconnect.