ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General IBM MQ Support » monitoring script

Post new topic  Reply to topic
 monitoring script « View previous topic :: View next topic » 
Author Message
peter.j.k
PostPosted: Mon Jan 19, 2015 11:41 am    Post subject: monitoring script Reply with quote

Newbie

Joined: 13 Jan 2015
Posts: 3

Hi everyone, first post for me!
I'm a linux admin with littel MQ experience.

I am trying to implement a monitoring script [below] from IBM which is supposed to monitor the primary qmanager queue of our new MQ server, Linux RHEL 6.5.

I keep getting the error:
ERROR! No queue manager name supplied
when running the script.
Even when I enter the queue name[PROD1] I still get the error.
I am also not sure how to get the path name, which I believe is optional.
Can TIMEOUT be specified? As in:
TIMEOUT=$2
The two variables which I believe need to be edited are:
# This script must be run by the mqm user.
PROD1=$1
MQ_INSTALLATION_PATH=$2

I am being told by an IBM rep that this script will monitor a running queue. so my first task is to get it to work.
Second issue is, what it's supposed to do if the qnamanger stops, the script does not appear to do anything. Meaning, it should send try to restart the queue and if that fails, send an email or something.

Thank you for your help in advance.

Code:
#!/bin/sh
#
# This script tests the operation of the queue manager.
#
# An exit code is generated by the runmqsc command:
# 0  => Either the queue manager is starting or the queue manager is running and responds.
#       Either is OK.
# >0 => The queue manager is not responding and not starting.
#
# This script must be run by the mqm user.
QM=$1
MQ_INSTALLATION_PATH=$2

if [ -z "$QM" ]
then
  echo "ERROR! No queue manager name supplied"
  exit 1
fi

if [ -z "$MQ_INSTALLATION_PATH" ]
then
  # No path specified, assume system primary install or MQ level < 7.1.0.0
  echo "INFO: Using shell default value for MQ_INSTALLATION_PATH"
else
  echo "INFO: Prefixing shell PATH variable with $MQ_INSTALLATION_PATH/bin"
  PATH=$MQ_INSTALLATION_PATH/bin:$PATH
fi

# Test the operation of the queue manager. Result is 0 on success, non-zero on error.
echo "ping qmgr" | runmqsc ${QM} > /dev/null 2>&1
pingresult=$?

if [ $pingresult -eq 0 ]
then # ping succeeded

  echo "Queue manager '${QM}' is responsive"
  result=0

else # ping failed

  # Don't condemn the queue manager immediately, it might be starting.
  srchstr="( |-m)$QM *.*$"
  cnt=`ps -ef | tr "\t" " " | grep strmqm | grep "$srchstr" | grep -v grep \
                | awk '{print $2}' | wc -l`
  if [ $cnt -gt 0 ]
  then
    # It appears that the queue manager is still starting up, tolerate
    echo "Queue manager '${QM}' is starting"
    result=0
  else
    # There is no sign of the queue manager starting
    echo "Queue manager '${QM}' is not responsive"
    result=$pingresult
  fi

fi

exit $result
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jan 19, 2015 12:20 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Don't pass the MQ Installation path...
Use instead:
<path to highest MQ installation>/bin/setmqenv -m <QMGR>

This should work every time and not make your path grow unduely long...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
peter.j.k
PostPosted: Mon Jan 19, 2015 12:48 pm    Post subject: Reply with quote

Newbie

Joined: 13 Jan 2015
Posts: 3

Thank you, now I am getting...after adding /opt/mqm=$2

./monitor.sh: line 12: /opt/mqm=: No such file or directory
INFO: Using shell default value for MQ_INSTALLATION_PATH

I ran this command below to determine the path......
crtmqenv -m PROD02
CLASSPATH=/opt/mqm/java/lib/com.ibm.mq.jar:/opt/mqm/java/lib/com.ibm.mqjms.jar:/opt/mqm/samp/wmqjava/samples:/opt/mqm/samp/jms/samples
LD_LIBRARY_PATH=
MANPATH=/opt/mqm/man:/usr/share/man
MQ_DATA_PATH=/var/mqm
MQ_ENV_MODE=64
MQ_INSTALLATION_NAME=Installation1
MQ_INSTALLATION_PATH=/opt/mqm
MQ_JAVA_DATA_PATH=/var/mqm
MQ_JAVA_INSTALL_PATH=/opt/mqm/java
MQ_JAVA_JVM_FLAG=
MQ_JAVA_LIB_PATH=/opt/mqm/java/lib64
MQ_JRE_PATH=/opt/mqm/java/jre64/jre
PATH=/opt/mqm/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/euser/bin
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Mon Jan 19, 2015 2:55 pm    Post subject: Reply with quote

Jedi Knight

Joined: 25 Mar 2003
Posts: 2538
Location: Melbourne, Australia

Wow, the script doesn't use the most authoritive command for displaying the state of a Queue Manager, dspmq.

eg.
QMGRSTATUS=`dspmq -m $QMGR -o status | cut -f3 -d\( | cut -f1 -d\)`
Should evaluate to "Running"
_________________
Glenn
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jan 19, 2015 8:33 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

gbaddeley wrote:
Wow, the script doesn't use the most authoritive command for displaying the state of a Queue Manager, dspmq.

eg.
QMGRSTATUS=`dspmq -m $QMGR -o status | cut -f3 -d\( | cut -f1 -d\)`
Should evaluate to "Running"

Only if run in the highest installation. You may also get "unknown" if the script ran in a lower level installation...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
peter.j.k
PostPosted: Thu Jan 22, 2015 2:06 pm    Post subject: Reply with quote

Newbie

Joined: 13 Jan 2015
Posts: 3

Here's the script I got working, a stripped down version of the script above.

It just monitors the queue manager, via cron every 1 minute, start the queue once if it stops, then sends a alert email.

Please let me know what you think.


Code:
!/bin/sh
#
# This script tests the operation of the queue manager.
#
# An exit code is generated by the runmqsc command:
# 0  => Either the queue manager is starting or the queue manager is running and responds.
#       Either is OK.
# >0 => The queue manager is not responding and not starting.
#
# This script must be run by the mqm user.
#QM=$1
QM=PRODQ01


# Test the operation of the queue manager. Result is 0 on success, non-zero on error.
echo "ping qmgr" | runmqsc ${QM} > /dev/null 2>&1
pingresult=$?

if [ $pingresult -eq "0" ]
then # ping succeeded

  echo "Queue manager '${QM}' is responsive" >> /home/mqm/logs/mq.$(date +\%d) 2>&1
 

else # ping failed

  #Try startimg queue manager
  strmqm PRODQ01

  #Don't condemn the queue manager immediately, it might be starting.
  srchstr="( |-m)$QM *.*$"
  cnt=`ps -ef | tr "\t" " " | grep strmqm | grep "$srchstr" | grep -v grep \
                | awk '{print $2}' | wc -l`
  if [ $cnt -gt 0 ]
  then
    # It appears that the queue manager is still starting up, tolerate
    echo "Queue manager '${QM}' is starting" >> /home/mqm/logs/mq.$(date +\%d) 2>&1

  else
    # There is no sign of the queue manager failed
    echo "Queue manager '${QM}' is not responsive" >> /home/mqm/logs/mq.$(date +\%d) 2>&1
    mail -s "PRODQ01 failed." admin@whateversolutions.com  < /dev/null

  fi

fi

exit $result
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Jan 22, 2015 10:56 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

What user are you running this script under?

You may have to switch user so that the 'strmqm' runs under the appropriate user. i.e. the one that it originally gets started under.

If you are starting the QMGR at system boot time, why not simply call that startup script from yours if you really want to start the QMGR in your script.(might have to do an su -c ..... though)

You also need to be able to disable the startup/email if the QMGR is down for maintenance. Remembering to edit the cron job (twice) is sure to get forgotten.

But honestly, these days QMGRs don't generally fail. If we were talking about MQ V2.1 or even 5.0 then maybe but these days? Very rare (IMHO, YMMV etc)
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » monitoring script
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.