Author |
Message
|
Tom Hogan |
Posted: Tue Sep 24, 2002 8:50 am Post subject: Best UNIX script test to determine MQ server is running? |
|
|
Novice
Joined: 15 Aug 2001 Posts: 10
|
I have an application that connects directly to a local queue manager. The application will fail to start if the queue manager is not running. What is the best way to determine in a shell script if MQ server is running.
My application also requires Oracle, and I use a tnsping to check for Oracle. Is there something similar for MQ Series (or is it WebSphere MQ now)?
--Tom |
|
Back to top |
|
 |
bduncan |
Posted: Tue Sep 24, 2002 9:49 am Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
Well, if you wanna be a little more fancy, use perl and attempt to actually connect to the queue manager. If you fail, you will not only know the queue manager isn't running properly, but you'll know why (from the Reason code). If you want to stick strictly to shell scripts, then just use the 'runmqsc QMGRNAME' command. You can pipe the output somewhere (if it's not running properly you'll get an error message) and I also believe it will return a nonzero return code. _________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
sudhir |
Posted: Fri Dec 27, 2002 1:49 am Post subject: |
|
|
Novice
Joined: 17 Dec 2002 Posts: 20 Location: Pune, India
|
hi
There is another way to find out that Queue manger is running or not
you just give command dspmq and pipe it to some txt file and just reading this file you can find that queue manager is running or not
sudhir |
|
Back to top |
|
 |
hopfe_de |
Posted: Tue Jan 14, 2003 12:03 am Post subject: small Programm |
|
|
 Acolyte
Joined: 03 Mar 2002 Posts: 58 Location: Frankfurt, Germany
|
You can write a small Programm.
This have only to make a MQCONN call.
After the connect you write the Completioncode to an enviroment variable, or return it.
edit:
Code: |
/********** isup.c ***************/
#include <stdio.h>
#include <cmqc.h>
#include <cmqxc.h>
int main(int argc, char* argv[])
{
long rc,cc,hconn;
if(argc < 2)
return -1;
MQCONN(argv[1],&hconn,&cc,&rc);
if(cc!=0)
return (int)rc;
else
MQDISC(&hconn,&cc,&rc);
return 0; /* return 0 if queuemanger is running */
}
|
compile command
Code: |
xlC isup.c /lib/libmqm.a -o isup
|
test script
QMGR ... is the name of the Queuemanager
Code: |
up='./isup QMGR'
if($up == 0) then
echo "running";
else
echo "not running;
fi
|
This programm works, but it isn`t very much tested.
greez
Hopfe |
|
Back to top |
|
 |
aixmurderer |
Posted: Sun Oct 05, 2003 10:23 pm Post subject: |
|
|
Newbie
Joined: 12 Aug 2002 Posts: 9
|
Use this in your shell script:
QMGR=`dspmq|awk '{ print$1 }'|cut -c 8-|sed -e 's/)//'`
MQSTAT=`dspmq|awk '{ print$2 }'|cut -c 8-|sed -e 's/)//'`
f [ "$MQSTAT" = "Running" ]
then
echo "QManager $QMGR $MQSTAT"
else
echo "QManager $QMGR not running"
do/something/here.sh #/usr/bin/su - mqm -c "/usr/bin/strmqm $QMGR"
fi
If you have more than 1 QManager you can play around with "head -1". "tail -1" etc. |
|
Back to top |
|
 |
hopfe_de |
Posted: Sun Oct 05, 2003 10:59 pm Post subject: |
|
|
 Acolyte
Joined: 03 Mar 2002 Posts: 58 Location: Frankfurt, Germany
|
dspmq doesn't work with MQSeries 5.1 for AIX. dspmq is only supported in Websphere MQ Versions >= 5.3.
If you are using dspmq, and you have more than one QMGR running on the AIX you can use
Code: |
dspmq -m <QMGR-NAME> |
It's much easier than working with "tail -1".
greez
Hopfe |
|
Back to top |
|
 |
aixmurderer |
Posted: Mon Oct 06, 2003 12:12 pm Post subject: |
|
|
Newbie
Joined: 12 Aug 2002 Posts: 9
|
We are running MQ ver 5.2 on AIX, it works 100%. Not sure about ver 5.1. |
|
Back to top |
|
 |
hopfe_de |
Posted: Mon Oct 06, 2003 12:25 pm Post subject: |
|
|
 Acolyte
Joined: 03 Mar 2002 Posts: 58 Location: Frankfurt, Germany
|
I only tested 5.1 and 5.3. We don't have a running Version of 5.2. |
|
Back to top |
|
 |
|