Tuesday, August 23, 2011

WMQ channels monitoring

I have come across a situation wherein I have to monitor any dead channels; Using support pack MO71 & filters, you can develop a simple monitor quickly; Using MO71 support pack auto refresh, filters will scan WMQ channels automatically at specific intervals and write info to a file.

Below is a sample script to report channels which are open but not received a message more than few hours.

This Script opens a file in C:\IBM\WMQ\tools\mo71\temp\Channel_Status.log and appends the information with details.


@ChlStartTime := mqtime(CHSTADA,CHSTATI);
@LstMsgTime := mqtime(LSTMSGDA,LSTMSGTI);
@diffTime := @LstMsgTime - @ChlStartTime;
if (@diffTime > 3600) {
@fd := fopen("C:\\IBM\\WMQ\\tools\\mo71\\temp\\Channel_Status.log","a");
fprintf(@fd, "%-17s\t", date$(_time));
fprintf(@fd, "%-20s\t", _qmname);
fprintf(@fd, "%-20s %5s %5s \t",CHANNAME,STATUS,MCASTAT);
fprintf(@fd, "%-15s %-11s %-10s ",CONNAME,CHSTADA,CHSTATI);
fprintf(@fd, "%-11s %-10s ",LSTMSGDA,LSTMSGTI);
fprintf(@fd, "%-5s %-5s %20s ",CHLTYPE,SUBSTATE,JOBNAME);
fprintf(@fd, "\tChannel Start Time = %s\tLast Message Received Time = %s Difference in time = %s\t\t %s Days opened \n", @ChlStartTime,@LstMsgTime ,@diffTime, (@diffTime/86400) );
fclose(@fd);
} else {
csl(1,info,"All channel connections are good");
}



You can get more details on this WebSphere MQ MO71 support pack from IBM.