Operating System - HP-UX
1836401 Members
3568 Online
110100 Solutions
New Discussion

how to make package monitor other packages

 
SOLVED
Go to solution
Rafal Bieniek
New Member

how to make package monitor other packages

Hello,
I have three packages, one with oracle and other two with apps. I want my apps packages check if oracle runs, if no, wait till it's run, when oracle goes down they go too
5 REPLIES 5
Steven E. Protter
Exalted Contributor
Solution

Re: how to make package monitor other packages

Shalom,

I suggest you make one package that starts multiple services in order.

Example, I need to start the database and then theapplication servver.

packge does thus:

starts the db
if the db is started correctly starts the app server.

It needs to do the reverse on the way down.

There is no rule that says a package can only do one thing.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Rafal Bieniek
New Member

Re: how to make package monitor other packages

HI,
Thanks a lot Steven
just to claryfi, in oracle package, in cu_def_functions except starting and stoping oracle put starting and stoping of ap package? does it cover every scenario?
the point is not to have ap's packages running without database accecible
thanks in advance
romek
Samir Pujara_1
Frequent Advisor

Re: how to make package monitor other packages

Hi,

I dont think that will work. However you can create a script to monitor your database when it goes down, will trigger app pakage (cmholdpkg) for that apps. Put this script in cron.
Cesare Salvioni
Trusted Contributor

Re: how to make package monitor other packages

hi,

what steven meant, if i well understand, is to join in ONE package ALL the functions, not to start other packages from one package: this is NOT good at all in my opinion.

I think that you should plan carefully what is your goal. You could have two solutions:

1. one package may do many things together, for instance starting a oracle server and a web server too. I usually create a different script for each function (like the rc scripts) and start them from the control script of the package checking each script return code. In this way you start/stop each function in a given order when the package start/stop and decide what to do if a function fails. The cons to this solution is that all the functions will run on the same node.

2. create a package for each function and, for package which depend from other, write a script like:
while true; do
if break
done
That is to say a script which exit if the dependencies are not avilable
Configure the package to use this script as a SERVICE (see the control file of the package)
In this way if the first package is not avilable the second one will try first to switch node then will die automatically
This second solution is more difficult to configure and you must pay attention to the scripts: they must be really good working to avoid unwanted switch of the packages, but in this way you have packages running on different nodes and checking each other

Hope this helps, ciao
nagendra k
New Member

Re: how to make package monitor other packages

I assume that the oracle package is an oracle single instance package.

To avoid app startup before oracle:
===================================
Add a functionality to validate in your app startup script if oracle package status is "up". If the oracle package status is "starting", then wait till it is up and then start your app. If the oracle package status is "down", retry for a considerable amount of time then do not start your app, error out or start oracle package by issueing "cmrunpkg ".

If you feel it is not feasible to edit your app startup/halt scripts, you can write enough logic to the customer_defined_run/halt_cmds function in the package control scripts.

for ex:
function customer_defined_run_cmds
{
# script/logic to startup oracle database.

while :; do
status=`cmviewcl -p | grep | awk '{print $2}'`
if [[ $status = "up" ]] || [[ $status = "starting" ]]; then
continue
else
# error out or retry
# break
# cmmodpkg -e -n -n
# cmmodpkg -e
# do anything you wish
fi
done
}



To go down if oracle goes down:
===============================
Add another app monitor script (configured as another service - SERVICE_CMD), which will periodically check the status of oracle package. If the status is "down", retry for a considerable amount of time and get your app package down too.

Another alternative is to add the foll statements in the customer_defined_halt_cmds of oracle package control script.

function customer_defined_halt_cmds
{
# script to halt oracle database
cmhaltpkg app_pkg1
cmhaltpkg app_pkg2
}


The advantage of doing this:
There is no need to package oracle and other apps as a single package. This is in line to maintain data integrity.