+

Search Tips | Advanced Search

runwithtrace command script for Linux

To trace MQ Explorer, close and restart the MQ Explorer by using the runwithtrace command script. A copy of this script for use on Linux systems is embedded in this topic.

Copy and save the following script as a text file called runwithtrace.cmd, then run the script as described in step 3 of "Using IBM MQ Explorer trace in other Eclipse environments".

#!/bin/sh
#---------------------------------------------------------------------------
# File Name : runwithtrace
#
# File Description : This script is used when MQ Explorer plug-ins are 
# installed into another Eclipse or Eclipse based product. 
# It launches eclipse and will run WebSphere MQ Explorer with trace enabled.
# 
#---------------------------------------------------------------------------

# ---------------------------------------------------------------------------
# Special processing for enabling trace
#  1.  Allow a user to supply their own properties file, pointed to by the 
#        MQPROPERTIES environment variable
#  2. Otherwise, build a properties file in /tmp which writes trace
#        to /var/mqm/trace directory if writeable, otherwise to /tmp itself
# ---------------------------------------------------------------------------

# test if variable is not set or refers to a file that does not exist
if [ -z "$MQPROPERTIES" -o ! -f "$MQPROPERTIES" ]
then
   # Create a properties file with the default trace options
   MQPROPERTIES=/tmp/mq_trace.properties
   # -----------------------------------------------------
   # Where should trace go - Try the trace directory first
   # -----------------------------------------------------
   echo "Confirming write access to the MQ trace directory /var/mqm/trace"
   MQTRACE=/var/mqm/trace
   # test if dir exists and is writable
   if [ -d $MQTRACE -a -w $MQTRACE ]
   then
     echo "Trace will be written to the MQ trace directory /var/mqm/trace"
   else
     echo "Trace will be written to the temporary directory /tmp"
     MQTRACE=/tmp
   fi
 
   # -------------------------------------------------------------
   # Now build the default properties file
   # -------------------------------------------------------------
   echo Diagnostics.MQ=enabled  > $MQPROPERTIES
   echo Diagnostics.Java=all >> $MQPROPERTIES
   echo Diagnostics.Java.Trace.Detail=high >> $MQPROPERTIES
   echo Diagnostics.Java.Trace.Destination.File=enabled >> $MQPROPERTIES
   echo Diagnostics.Java.Trace.Destination.Console=disabled >> $MQPROPERTIES
   echo Diagnostics.Java.Trace.Destination.Pathname=$MQTRACE >> $MQPROPERTIES
   echo Diagnostics.Java.FFDC.Destination.Pathname=$MQTRACE >> $MQPROPERTIES
   echo Diagnostics.Java.Errors.Destination.Filename=$MQTRACE >> $MQPROPERTIES
 
fi

# ---------------------------------------------------------------------------
# Build the command line to run
# Look in the current directory
# All parameters passed to this script are passed through.
# Set the load time weaving options, it's set as part of the vmargs parameter.
# ---------------------------------------------------------------------------

# Special case for when MQ Explorer plug-ins are installed in an Eclipse or an
# Eclipse based product.
# eclipse needs to be in current directory. 

if [ -f "eclipse" ]
then
  explorerCmd="./eclipse"
fi
 
if [ ! -f "${explorerCmd}" ]
then
  echo "ERROR - eclipse executable could not be found in the current directory"
  echo "ERROR - This script needs to be run in the same directory as the eclipse executable"
  exit 1
fi

# Note.
# In eclipse and eclipse based products the osgi.framework.extensions is set
# as part of the Equinox Weaving plug-ins eclipse installation.
# Therefore unlike in the normal MQ Explorer script LTW_OPTIONS is empty

# LTW_OPTIONS=-Dosgi.framework.extensions=org.eclipse.equinox.weaving.hook
LTW_OPTIONS=
explorerCmd="$explorerCmd $* -vmargs -Xmx512M $LTW_OPTIONS -Dcom.ibm.mq.commonservices=$MQPROPERTIES"

  
# ---------------------------------------------------------------------------
# Launch MQ Explorer
# ---------------------------------------------------------------------------
echo Launching $explorerCmd 

exec $explorerCmd
Parent topic: Use IBM MQ Explorer trace in other Eclipse environments

Last updated: 2020-10-04