For many years I have been frustrated with displaying data provided by MQ midrange in PCF format, as there was nothing to help you use it. Yes, you could display it, but it was a bit like saying … here is a bucket of bits, now build your own program from it to process the data – good luck.
I had started to write some C code to process it, but then I retired from IBM, and since then have found that Python is a brilliant systems management language.
I have put up on Github, some Python code which does the following.
You can create PCF command, such as INQUIRE QUEUES. It can then parse the output into “English” and you can then do things with it. By “English” I mean
Q_TYPE: LOCAL rather than the value 1
DEF_BIND: BIND_ON_OPEN rather than the value 16384
There are examples of what you can do with it.
get_pcf.py. You specify the connection details, and the queue, and it returns the data in json format which you can pipe into another command.
queues.py issues the INQUIRE QUEUE command. This outputs the data in json format. queues2.py then writes it into a file, one file per queue, one line per attribute. This is great
- you do not have to worry about trying to parse the output from runmqsc
- you can use standard tools on the file
- you can do more…
There is a diff.py sample you give it a list of files and it tells you the difference in the queue definitions (while ignoring attributes like change date), for example
CP0000.yml CP0001.yml : Q_NAME CP0000 / CP0001 CP0000.yml CP0001.yml : Q_DESC Main queue / None CP0000.yml CP0001.yml : MAX_Q_DEPTH 2000 / 5000 CP0000.yml CP0001.yml : Q_DEPTH_HIGH_EVENT ENABLED / DISABLED
There is standards.py which allows you to check attributes in the .yml file meet your corporate standards!
There is events.py and events2.py so you can now process the events produced by the define, delete and alter commands, and see who made the change what the change was, and when the change was made.
I am working on making the stats and accounting usable, so you can create a .csv file with useful data in it, or pass it into Kibana and other tools. So watch this space.
I would welcome any comments of feedback. Ive had one already. When using Eclipse and Python it supports text completion – so if you typed in MQ.INQ… it should give you a list of options to pick from.
These tools build on top of the excellent pymqi package which provide the MQAPI for Python programs. You use pymqi to put and get messages, then use the mqtools package to process the data.
How to get hold of it…
The README has instructions on how to download it. If there is enough interest I’ll package it up so PIP INSTALL can find it.
One thought on “You can now easily display MQ PCF data using Python”