Greetings!
Imagine 2 hosts: host A runs Oracle 10g , host B runs IBM DB2 v9. I
have to write a shell script (bask/Korn...) that checks if a database
instance is up and running and does a bunch of other stuff.
For instance, I can do something like this on host A (the host for the
Oracle 10g database):
export ORACLE_SID=<ins tance name>
check_db=`ps -ef|grep ${ORACLE_SID}|g rep pmon|wc -l`;
checkdb_retval= `expr $check_db` ...
if [ $checkdb_retval -lt 1 ]
then
echo "Database not running!"
exit 1
fi
This works like a charm with Oracle. However, DB2 is different: I
tried the following snippet of code on host B but to no avail:
export DB2=db2inst1
export DBNAME=<databas e name>
check_db=`ps -ef|grep ${DB2}|grep ${DBNAME}|wc -l`;
checkdb_retval= `expr $check_db`
if [ $checkdb_retval -lt 1 ]
then
echo "Database not running!"
exit 1
fi
This is not going to work : the result this code outputs is way too
verbose to tell what's what.
Is there a sure-fire way to tell in a shell script that a DB2 instance
is up and running, e.g. something similar to grep-ping for DB2's
equivalent of PMON???
Hope you can help. TIA,
Alan.
Imagine 2 hosts: host A runs Oracle 10g , host B runs IBM DB2 v9. I
have to write a shell script (bask/Korn...) that checks if a database
instance is up and running and does a bunch of other stuff.
For instance, I can do something like this on host A (the host for the
Oracle 10g database):
export ORACLE_SID=<ins tance name>
check_db=`ps -ef|grep ${ORACLE_SID}|g rep pmon|wc -l`;
checkdb_retval= `expr $check_db` ...
if [ $checkdb_retval -lt 1 ]
then
echo "Database not running!"
exit 1
fi
This works like a charm with Oracle. However, DB2 is different: I
tried the following snippet of code on host B but to no avail:
export DB2=db2inst1
export DBNAME=<databas e name>
check_db=`ps -ef|grep ${DB2}|grep ${DBNAME}|wc -l`;
checkdb_retval= `expr $check_db`
if [ $checkdb_retval -lt 1 ]
then
echo "Database not running!"
exit 1
fi
This is not going to work : the result this code outputs is way too
verbose to tell what's what.
Is there a sure-fire way to tell in a shell script that a DB2 instance
is up and running, e.g. something similar to grep-ping for DB2's
equivalent of PMON???
Hope you can help. TIA,
Alan.