Operating System - Tru64 Unix
1830932 Members
2224 Online
110017 Solutions
New Discussion

Script for CAA script

 
Vladimir Fabecic
Honored Contributor

Script for CAA script

Hello
I have the following envirement:
TRU64 cluster with two ES47 and EVA.
In normal condition first node has to run Oracle database and second Oracle Application server.
If one of members fail, other have to run both applications.
I made caa scripts and it is working OK, except one little thing: when relocating database, application server has to be restarted. Also, database has to be up when starting application server.
So I made a little script which does not work as it should.
The idea is to check if "oracleapps" cluster alias is up, and if so then do something (restart application server), otherwise do nothing. Problem with my script is that it sends wrong exit code to caa. Please help me and say what I did wrong.
Script (for starting database server):

# /bin/ksh
apps/proddb/9.2.0/appsutil/scripts/PROD_axpcldb/addbctl.sh start
/apps/proddb/9.2.0/appsutil/scripts/PROD_axpcldb/addlnctl.sh start PROD
ping -c 1 -t 2 oracleapps
if [ $? -eq 0 ]; then
rsh oracleapps $HOME/stop_prodapp.sh
rsh oracleapps $HOME/start_prodapp.sh
fi
exit 0

In vino veritas, in VMS cluster
12 REPLIES 12
Ajay Agarwal
Frequent Advisor

Re: Script for CAA script

Is this CAA action script for your CAA application or you are calling this script from your CAA action script?

Check your CAA action script to check if you are returning with correct exit code. Try executing the action script from the command line and check the return value (echo $?).



Vladimir Fabecic
Honored Contributor

Re: Script for CAA script

I am calling this script from my CAA script.
This is a script for database startup.
When executed manually, it works. It also works with caa_start when cluster alias oracleapps is up (when $? is 0).
Problem is when cluster alias is down. In that case script must not execute rsh commands. Script does go to "fi" but returns non zero exit code.
In vino veritas, in VMS cluster
Venkatesh BL
Honored Contributor

Re: Script for CAA script

How do you say that the script reached the "fi" part?...did you try "else..."?

I am wondering if the script reached till that point when the alias was down...
Vladimir Fabecic
Honored Contributor

Re: Script for CAA script

BL, that is a very simple script. It reaches fi part.
I do not need "else ..." , but have tried it. No luck.
I can not see where is the problem.
Maybe to replace "ping" with something else?
In vino veritas, in VMS cluster
Ivan Ferreira
Honored Contributor

Re: Script for CAA script

The code seems to be good. If this code runs in the caa script, test the caa script outside CAA daemon and check the code returned.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Vladimir Fabecic
Honored Contributor

Re: Script for CAA script

Hello Ivan
I tried to execute the script outside CAA daemon. And it did the job. And "echo $?" returns 0. But when started inside CAA deamon, it fails.
If I comment lines from "ping ..." till end, script works fine inside CAA daemon.
Any other idea how to check if alias oracleapps is up (instead of ping)?
In vino veritas, in VMS cluster
Ivan Ferreira
Honored Contributor

Re: Script for CAA script

You could use rsh again, check the process status or the cluamgr output. The bad thing is that if the nodes are down, the rsh will take a long time to finish.

What if you remove the exit 0 from the script?
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Vladimir Fabecic
Honored Contributor

Re: Script for CAA script

Ivan
Yes,if the nodes are down, the rsh will take a long time to finish (and return wrong status). So I must use "if ..."
First version of that script was without "exit 0". No difference.
In vino veritas, in VMS cluster
Venkatesh BL
Honored Contributor

Re: Script for CAA script

Can you post the 'check' portion of the CAA script that calls this script?
Ajay Agarwal
Frequent Advisor

Re: Script for CAA script

Try returning different exit code from this script. If ping succeeds, then return 0 else return 1.

ping -c 1 -t 2 oracleapps >2&1
if [$? -eq 0]; then
...
exit 0
else
exit 1
fi

From your application action acript, check the return value of this script and then take the required action.
Vladimir Fabecic
Honored Contributor

Re: Script for CAA script

The problem is that script has to exit with status 0 in both cases.
If alias is up rsh commands should be executed, if alias is down, rsh commands should not be executed.
This script should be START_APPCMD script which should be executed from CAA script.
In vino veritas, in VMS cluster
Vladimir Fabecic
Honored Contributor

Re: Script for CAA script

This script works:
/apps/proddb/9.2.0/appsutil/scripts/PROD_axpcldb/addbctl.sh start
/apps/proddb/9.2.0/appsutil/scripts/PROD_axpcldb/addlnctl.sh start PROD
STATUS=`/usr/bin/caa_stat oracleapps | grep TARGET`
if test $STATUS = "TARGET=ONLINE" ; then
rsh oracleapps $HOME/stop_prodapp.sh
rsh oracleapps $HOME/start_prodapp.sh
echo $STATUS > /tmp/st.st
else
echo $STATUS > /tmp/st.st
fi

Still do not know what is wrong with script with "ping".
Thanks everybody.
In vino veritas, in VMS cluster