Check JMS Queue

[scope@mon01 jms-queue]$ cat jms-queue-check.sh
#!/bin/bash
#written Andrew Stringer 17/09/2010

#Purpose is to check the jms queue size on RGS app servers
#and email if queue size is too big.
#Large queue size impacts Init.do and RB & Spin times.

#turn on debugging, -x starts, +x stops
set +x

TMPLOG=/tmp/jms-queue.txt-$$
DAY=`date +%b" "%d" "%Y`
THRESHOLD=0
FILETHRESHOLD=1600000000 #1.6 GB
#FILETHRESHOLD=680000000 #Testing limit


echo "JMS Queue Size monitor" > ${TMPLOG}
echo "======================" >> ${TMPLOG}
echo "" >> ${TMPLOG}
echo "From /usr/local/SiteScope/jms-queue/jms-queue-check.sh" >> ${TMPLOG}
echo "" >> ${TMPLOG};
echo "One of the files on a server below located in /wworks/rgs/weblogic/prod/data/jms " >> ${TMPLOG}
echo "has exceeded 1.5GB in size and should be deleted before it grows to 2 GB. " >> ${TMPLOG}
echo "" >> ${TMPLOG};
echo "Log in and su to wworks, cd to \"/wworks/rgs/weblogic/prod\", ">> ${TMPLOG}
echo "stop weblogic with \"bin/weblogic.platform.managed stop\", " >> ${TMPLOG}
echo "move file to /var/tmp and restart weblogic with \"bin/weblogic.platform.managed start\" "  >> ${TMPLOG}
echo "Check new file size with \"ls -l /data/jms/\" "  >> ${TMPLOG}
echo "" >> ${TMPLOG};
echo "After a new JMS queue file has been created, delete the old ones out of /var/tmp" >> ${TMPLOG};
echo "OR... run /home/wworks/scripts/clear-jms-queue.sh which clears all servers." >> ${TMPLOG};
echo "" >> ${TMPLOG};



for SERVER in app01 app02 app03 app04 ;

do
        echo "${SERVER}" >> ${TMPLOG};
	  echo "------------" >> ${TMPLOG};

	FILESTRING=`ssh ${SERVER} ls -lb /wworks/rgs/weblogic/prod/data/jms/ | awk '{print  $9, $5}'`
  	FILENAME=`echo ${FILESTRING} | awk '{print  $1}'`
	FILESIZE=`echo ${FILESTRING} | awk '{print  $2}'`
      HUMANFILESIZE=$((FILESIZE/1000000))
      #echo "Human Filesize >${HUMANFILESIZE} Mbytes<"

      echo "${FILENAME}, ${HUMANFILESIZE} Mbytes" >> ${TMPLOG};
      echo " " >> ${TMPLOG};

      if [ ${FILESIZE} -gt ${FILETHRESHOLD} ]
	       then
	       THRESHOLD=1
	       #echo "Threshold exceeded on ${SERVER}, ${FILESTRING}, ${FILESIZE}, ${THRESHOLD}"
	fi
	
      #echo "Threshold >${THRESHOLD}<"

	done

	echo "EOT." >> ${TMPLOG};
	echo " " >> ${TMPLOG};

if [ ${THRESHOLD} -eq 1 ]
   then
   #echo "Threshold exceeded, Sending mail"

   #Send out mail
   /bin/mailx -s "RGS App JMS queue size threshold exceeded." noc@zzz.com < ${TMPLOG}
fi

#debug - echo mailmsg
#cat ${TMPLOG}

#Clean up tmp files
rm ${TMPLOG}

exit 0

rb/checkjmsqueue.txt · Last modified: 10/10/2013 14:21 (external edit)