I'm using system calls to display information about server resources in a simple dashboard type display that I threw together in php. Currently I'm using sed to get individual attributes. So the command line to get current depth is:

 % echo 'DISPLAY QLOCAL('QUEUE.NAME') CURDEPTH' | runmqsc QMNAME 5724-H72 (C) Copyright IBM Corp. 1994, 2009. ALL RIGHTS RESERVED. Starting MQSC for queue manager QMNAME. 1 : DISPLAY QLOCAL(QUEUE.NAME) CURDEPTH AMQ8409: Display Queue details. QUEUE(QUEUE.NAME) TYPE(QLOCAL) CURDEPTH(77) One MQSC command read. No commands have a syntax error. All valid MQSC commands were processed. 

Command to get just the value (77) via sed:

% echo 'DISPLAY QLOCAL('QUEUE.NAME') CURDEPTH' | runmqsc QMNAME | grep "CURDEPTH" | sed 's/.*CURDEPTH//' | tr -d '()' 77 

Finally, to assign to a variable I use the following after setting $qn and $qm appropriately:

$curdepth = trim(shell_exec('echo \'DISPLAY QLOCAL(\''.$qn.'\') CURDEPTH\' | runmqsc '.$qm.' | grep "CURDEPTH(" | sed \'s/.*CURDEPTH//\' | tr -d \'()\'')); 

Now, I can get all variables by running a standard DISPLAy mqsc command:

 % echo 'DISPLAY QLOCAL('QUEUE.NAME')' | runmqsc QMNAME 5724-H72 (C) Copyright IBM Corp. 1994, 2009. ALL RIGHTS RESERVED. Starting MQSC for queue manager QMNAME. 1 : DISPLAY QLOCAL(QUEUE.NAME) AMQ8409: Display Queue details. QUEUE(QUEUE.NAME) TYPE(QLOCAL) ACCTQ(QMGR) ALTDATE(2010-10-13) ALTTIME(15.48.06) BOQNAME( ) BOTHRESH(0) CLUSNL( ) CLUSTER(CLUSTERVV) CLWLPRTY(0) CLWLRANK(0) CLWLUSEQ(QMGR) CRDATE(2010-10-13) CRTIME(15.48.06) CURDEPTH(77) DEFBIND(OPEN) DEFPRTY(0) DEFPSIST(NO) DEFPRESP(SYNC) DEFREADA(NO) DEFSOPT(SHARED) DEFTYPE(PREDEFINED) DESCR( ) DISTL(NO) GET(ENABLED) HARDENBO INITQ( ) IPPROCS(0) MAXDEPTH(5000) MAXMSGL(4194304) MONQ(QMGR) MSGDLVSQ(PRIORITY) NOTRIGGER NPMCLASS(NORMAL) OPPROCS(1) PROCESS( ) PUT(ENABLED) PROPCTL(COMPAT) QDEPTHHI(80) QDEPTHLO(20) QDPHIEV(DISABLED) QDPLOEV(DISABLED) QDPMAXEV(ENABLED) QSVCIEV(NONE) QSVCINT(999999999) RETINTVL(999999999) SCOPE(QMGR) SHARE STATQ(QMGR) TRIGDATA( ) TRIGDPTH(1) TRIGMPRI(0) TRIGTYPE(FIRST) USAGE(NORMAL) One MQSC command read. No commands have a syntax error. All valid MQSC commands were processed. 

I've been trying for a couple days now to find some elegant way to assign the value of each of those attributes to an appropriately named variable with just the one system call (as they are expensive), so ie. $CURDEPTH=77 and $RETINTVL=999999999 and PROCESS is null. Needless to say I've been failing miserably and wondering if anyone has any ideas on how they would do this.

Thanks!

1 Answer

  1. You are reinventing the wheel here. MQ monitoring is well understood now and for example this Zabbix template should be of you to you: There are others as well.

  2. Have you tried arrays? Dump everything into ARRAY and get stuff out of your array (the things which you need)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.