External_ Monitor_for_MQ Series

Problem this snippet solves:

This external script helps you to check the MQSeries queue Status. So the idea is to check the listener with a simple TCP monitor (L4) + a external monitor to check the queue (L7). If both monitors are up the MQSeries server is really available.

MQSeries provides you with the "dspmq" utility which could be called through ssh command

So:

monitor MQPING { defaults from external run "mqping.sh" }

pool pool_mq { monitor all MQPING and tcp members x.x.x.x:1414 }

Code :

#!/bin/bash
MQPING=/usr/bin/dspmq
MQUSER=root
NODE_IP=$1
NODE_PORT=$2
IP=`echo $NODE_IP | sed 's/::ffff://'`

STATUS=`ssh -o 'StrictHostKeyChecking no' -l $MQUSER $IP $MQPING | awk '{ print $2 }'`

case "$STATUS" in
*Running*)
echo "Up"
;;
*)
esac
Published Mar 17, 2015
Version 1.0
No CommentsBe the first to comment