I'd been asked about scripting access to IBM MQ ... as it's been a while since last I worked with it, I decided to install MQ 9 onto a Linux VM, and have a quick play .....
So my VM is running Ubuntu 18.04.4, and, therefore, I downloaded the appropriate MQ 9.2 image: -
IBM_MQ_9.2.0_UBUNTU_X86-64.tar.gz
Having accepted the license: -
./mqlicense.sh accept
and installed the binaries: -
dpkg --list | grep IBM
ii ibmmq-amqp 9.2.0.0 amd64 IBM MQ AMQP Service
ii ibmmq-ams 9.2.0.0 amd64 IBM MQ Advanced Message Security
ii ibmmq-bcbridge 9.2.0.0 amd64 IBM MQ Blockchain Bridge
ii ibmmq-client 9.2.0.0 amd64 IBM MQ Client FileSet
ii ibmmq-explorer 9.2.0.0 amd64 IBM MQ Explorer
ii ibmmq-ftbase 9.2.0.0 amd64 IBM MQ Managed File Transfer Base Component
ii ibmmq-ftlogger 9.2.0.0 amd64 IBM MQ Managed File Transfer Logger
ii ibmmq-fttools 9.2.0.0 amd64 IBM MQ Managed File Transfer Tools
ii ibmmq-gskit 9.2.0.0 amd64 IBM MQ GSKit FileSet
ii ibmmq-java 9.2.0.0 amd64 IBM MQ Java, JMS and Web Services support
ii ibmmq-jre 9.2.0.0 amd64 IBM MQ Java JRE
ii ibmmq-man 9.2.0.0 amd64 IBM MQ Man Pages FileSet
ii ibmmq-msg-cs 9.2.0.0 amd64 IBM MQ Messages (Czech) FileSet
ii ibmmq-msg-de 9.2.0.0 amd64 IBM MQ Messages (German) FileSet
ii ibmmq-msg-es 9.2.0.0 amd64 IBM MQ Messages (Spanish) FileSet
ii ibmmq-msg-fr 9.2.0.0 amd64 IBM MQ Messages (French) FileSet
ii ibmmq-msg-hu 9.2.0.0 amd64 IBM MQ Messages (Hungarian) FileSet
ii ibmmq-msg-it 9.2.0.0 amd64 IBM MQ Messages (Italian) FileSet
ii ibmmq-msg-ja 9.2.0.0 amd64 IBM MQ Messages (Japanese) FileSet
ii ibmmq-msg-ko 9.2.0.0 amd64 IBM MQ Messages (Korean) FileSet
ii ibmmq-msg-pl 9.2.0.0 amd64 IBM MQ Messages (Polish) FileSet
ii ibmmq-msg-pt 9.2.0.0 amd64 IBM MQ Messages (Brazilian Portuguese) FileSet
ii ibmmq-msg-ru 9.2.0.0 amd64 IBM MQ Messages (Russian) FileSet
ii ibmmq-msg-zh-cn 9.2.0.0 amd64 IBM MQ Messages (Simplified Chinese) FileSet
ii ibmmq-msg-zh-tw 9.2.0.0 amd64 IBM MQ Messages (Traditional Chinese) FileSet
ii ibmmq-runtime 9.2.0.0 amd64 IBM MQ Runtime FileSet
ii ibmmq-samples 9.2.0.0 amd64 IBM MQ Samples FileSet
ii ibmmq-sdk 9.2.0.0 amd64 IBM MQ SDK FileSet
ii ibmmq-server 9.2.0.0 amd64 IBM MQ Server FileSet
ii ibmmq-sfbridge 9.2.0.0 amd64 IBM MQ SalesForce Bridge
ii ibmmq-web 9.2.0.0 amd64 IBM MQ REST API and Console
ii ibmmq-xrservice 9.2.0.0 amd64 IBM MQ Telemetry Service
I switched to the mqm user: -
su - mqm
and created and started a Queue Manager: -
crtmqm -u SYSTEM.DEAD.LETTER.QUEUE QM_MDB
strmqm QM_MDB
A quick bit of validation: -
dspmqver
Name: IBM MQ
Version: 9.2.0.0
Level: p920-L200709
BuildType: IKAP - (Production)
Platform: IBM MQ for Linux (x86-64 platform)
Mode: 64-bit
O/S: Linux 4.15.0-117-generic
O/S Details: Ubuntu 18.04.4 LTS (Bionic Beaver)
InstName: Installation1
InstDesc:
Primary: No
InstPath: /opt/mqm
DataPath: /var/mqm
MaxCmdLevel: 920
LicenseType: Production
dspmq
QMNAME(QM_MDB) STATUS(Running)
and then a spot of scripting using runmqsc : -
Display Queue Manager
echo "DISPLAY QMGR" | runmqsc `dspmq | awk '{print $1}' | sed 's/QMNAME//g' | sed 's/[()]//g'`
5724-H72 (C) Copyright IBM Corp. 1994, 2020.
Starting MQSC for queue manager QM_MDB.
1 : DISPLAY QMGR
AMQ8408I: Display Queue Manager details.
QMNAME(QM_MDB) ACCTCONO(DISABLED)
ACCTINT(1800) ACCTMQI(OFF)
ACCTQ(OFF) ACTIVREC(MSG)
ACTVCONO(DISABLED) ACTVTRC(OFF)
ADVCAP(ENABLED) ALTDATE(2020-09-24)
ALTTIME(10.05.08) AMQPCAP(YES)
AUTHOREV(DISABLED) CCSID(1208)
CERTLABL(ibmwebspheremqqm_mdb) CERTVPOL(ANY)
CHAD(DISABLED) CHADEV(DISABLED)
CHADEXIT( ) CHLEV(DISABLED)
CHLAUTH(ENABLED) CLWLDATA( )
CLWLEXIT( ) CLWLLEN(100)
CLWLMRUC(999999999) CLWLUSEQ(LOCAL)
CMDEV(DISABLED) CMDLEVEL(920)
COMMANDQ(SYSTEM.ADMIN.COMMAND.QUEUE) CONFIGEV(DISABLED)
CONNAUTH(SYSTEM.DEFAULT.AUTHINFO.IDPWOS)
CRDATE(2020-09-24) CRTIME(10.05.08)
CUSTOM( ) DEADQ(SYSTEM.DEAD.LETTER.QUEUE)
DEFCLXQ(SCTQ) DEFXMITQ( )
DESCR( ) DISTL(YES)
IMGINTVL(60) IMGLOGLN(OFF)
IMGRCOVO(YES) IMGRCOVQ(YES)
IMGSCHED(MANUAL) INHIBTEV(DISABLED)
IPADDRV(IPV4) LOCALEV(DISABLED)
LOGGEREV(DISABLED) MARKINT(5000)
MAXHANDS(256) MAXMSGL(4194304)
MAXPROPL(NOLIMIT) MAXPRTY(9)
MAXUMSGS(10000) MONACLS(QMGR)
MONCHL(OFF) MONQ(OFF)
PARENT( ) PERFMEV(DISABLED)
PLATFORM(UNIX) PSMODE(ENABLED)
PSCLUS(ENABLED) PSNPMSG(DISCARD)
PSNPRES(NORMAL) PSRTYCNT(5)
PSSYNCPT(IFPER) QMID(QM_MDB_2020-09-24_10.05.08)
REMOTEEV(DISABLED) REPOS( )
REPOSNL( ) REVDNS(ENABLED)
ROUTEREC(MSG) SCHINIT(QMGR)
SCMDSERV(QMGR) SPLCAP(ENABLED)
SSLCRLNL( ) SSLCRYP( )
SSLEV(DISABLED) SSLFIPS(NO)
SSLKEYR(/var/mqm/qmgrs/QM_MDB/ssl/key)
SSLRKEYC(0) STATACLS(QMGR)
STATCHL(OFF) STATINT(1800)
STATMQI(OFF) STATQ(OFF)
STRSTPEV(ENABLED) SUITEB(NONE)
SYNCPT TREELIFE(1800)
TRIGINT(999999999) VERSION(09020000)
XRCAP(YES)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
echo "DISPLAY CHANNEL(*)" | runmqsc `dspmq | awk '{print $1}' | sed 's/QMNAME//g' | sed 's/[()]//g'`
5724-H72 (C) Copyright IBM Corp. 1994, 2020.
Starting MQSC for queue manager QM_MDB.
1 : DISPLAY CHANNEL(*)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.ADMIN.SVRCONN) CHLTYPE(SVRCONN)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.AUTO.RECEIVER) CHLTYPE(RCVR)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.AUTO.SVRCONN) CHLTYPE(SVRCONN)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.DEF.AMQP) CHLTYPE(AMQP)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.DEF.CLUSRCVR) CHLTYPE(CLUSRCVR)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.DEF.CLUSSDR) CHLTYPE(CLUSSDR)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.DEF.RECEIVER) CHLTYPE(RCVR)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.DEF.REQUESTER) CHLTYPE(RQSTR)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.DEF.SENDER) CHLTYPE(SDR)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.DEF.SERVER) CHLTYPE(SVR)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.DEF.SVRCONN) CHLTYPE(SVRCONN)
AMQ8414I: Display Channel details.
CHANNEL(SYSTEM.DEF.CLNTCONN) CHLTYPE(CLNTCONN)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
Display Queues
echo "DISPLAY QUEUE(*)" | runmqsc `dspmq | awk '{print $1}' | sed 's/QMNAME//g' | sed 's/[()]//g'`
5724-H72 (C) Copyright IBM Corp. 1994, 2020.
Starting MQSC for queue manager QM_MDB.
1 : DISPLAY QUEUE(*)
AMQ8409I: Display Queue details.
QUEUE(Q_MDB) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.ACCOUNTING.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.ACTIVITY.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.CHANNEL.EVENT) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.COMMAND.EVENT) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.COMMAND.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.CONFIG.EVENT) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.LOGGER.EVENT) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.PERFM.EVENT) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.PUBSUB.EVENT) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.QMGR.EVENT) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.STATISTICS.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.TRACE.ACTIVITY.QUEUE)
TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.ADMIN.TRACE.ROUTE.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.AMQP.COMMAND.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.AUTH.DATA.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.BROKER.ADMIN.STREAM) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.BROKER.CONTROL.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.BROKER.DEFAULT.STREAM) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.BROKER.INTER.BROKER.COMMUNICATIONS)
TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.CHANNEL.INITQ) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.CHANNEL.SYNCQ) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.CHLAUTH.DATA.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.CICS.INITIATION.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.CLUSTER.COMMAND.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.CLUSTER.HISTORY.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.CLUSTER.REPOSITORY.QUEUE)
TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.CLUSTER.TRANSMIT.MODEL.QUEUE)
TYPE(QMODEL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.CLUSTER.TRANSMIT.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.DDELAY.LOCAL.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.DEAD.LETTER.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.DEFAULT.ALIAS.QUEUE) TYPE(QALIAS)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.DEFAULT.INITIATION.QUEUE)
TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.DEFAULT.LOCAL.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.DEFAULT.MODEL.QUEUE) TYPE(QMODEL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.DEFAULT.REMOTE.QUEUE) TYPE(QREMOTE)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.DOTNET.XARECOVERY.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.DURABLE.MODEL.QUEUE) TYPE(QMODEL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.DURABLE.SUBSCRIBER.QUEUE)
TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.HIERARCHY.STATE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.INTER.QMGR.CONTROL) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.INTER.QMGR.FANREQ) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.INTER.QMGR.PUBS) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.INTERNAL.REPLY.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.INTERNAL.REQUEST.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.JMS.TEMPQ.MODEL) TYPE(QMODEL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.MQEXPLORER.REPLY.MODEL) TYPE(QMODEL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.MQSC.REPLY.QUEUE) TYPE(QMODEL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.NDURABLE.MODEL.QUEUE) TYPE(QMODEL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.PENDING.DATA.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.PROTECTION.ERROR.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.PROTECTION.POLICY.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.REST.REPLY.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.RETAINED.PUB.QUEUE) TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.SELECTION.EVALUATION.QUEUE)
TYPE(QLOCAL)
AMQ8409I: Display Queue details.
QUEUE(SYSTEM.SELECTION.VALIDATION.QUEUE)
TYPE(QLOCAL)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
Display Listeners
echo "DISPLAY LISTENER(*)" | runmqsc `dspmq | awk '{print $1}' | sed 's/QMNAME//g' | sed 's/[()]//g'`
5724-H72 (C) Copyright IBM Corp. 1994, 2020.
Starting MQSC for queue manager QM_MDB.
1 : DISPLAY LISTENER(*)
AMQ8630I: Display listener information details.
LISTENER(SYSTEM.DEFAULT.LISTENER.TCP)
AMQ8630I: Display listener information details.
LISTENER(TCP.LISTENER)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
You get the picture ....
For the record, this is how I'm getting the Queue Manager name from the dspmq command: -
QMNAME(QM_MDB) STATUS(Running)
dspmq | awk '{print $1}' | sed 's/QMNAME//g' | sed 's/[()]//g'
QM_MDB
In other words, using awk to extract the first column, which is the Queue Manager name, albeit wrapped up with QMNAME() and then using a pair of sed commands to remove (a) the word QMNAME and (b) the opening / closing brackets.
I'm sure there's 73 different ways ....
but that worked for me ...
Of course, all of that could be put into a Bash script: -
cat queryMQ.sh
#!/bin/bash
echo $1 | runmqsc `dspmq | awk '{print $1}' | sed 's/QMNAME//g' | sed 's/[()]//g'`
./queryMQ.sh "DISPLAY LISTENER(*)"
5724-H72 (C) Copyright IBM Corp. 1994, 2020.
Starting MQSC for queue manager QM_MDB.
1 : DISPLAY LISTENER(*)
AMQ8630I: Display listener information details.
LISTENER(SYSTEM.DEFAULT.LISTENER.TCP)
AMQ8630I: Display listener information details.
LISTENER(TCP.LISTENER)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
Again, you get the point .....
For more information on MQ commands etc., please check out the
Knowledge Center.