Skip to content

Instantly share code, notes, and snippets.

@enriquemanuel
Created September 24, 2013 13:30
Show Gist options
  • Save enriquemanuel/6684699 to your computer and use it in GitHub Desktop.
Save enriquemanuel/6684699 to your computer and use it in GitHub Desktop.
I created this small GIST about creating 5 thread dumps one after the other waiting for 10 seconds and then gzipping them and sending them using mutt. you can install mutt using yum or your prefer method.
#! /bin/bash
#creating my folder to store them
if [ ! -d /tmp/`hostname` ]
then
mkdir -p /tmp/`hostname`
fi
#executing my command
/usr/local/blackboard/tools/admin/ServiceController.sh services.appserver.threaddump
sleep 10
/usr/local/blackboard/tools/admin/ServiceController.sh services.appserver.threaddump
sleep 10
/usr/local/blackboard/tools/admin/ServiceController.sh services.appserver.threaddump
sleep 10
/usr/local/blackboard/tools/admin/ServiceController.sh services.appserver.threaddump
sleep 10
/usr/local/blackboard/tools/admin/ServiceController.sh services.appserver.threaddump
#move all the thread dumps to the temp location
mv /usr/local/blackboard/logs/tomcat/thread_dump* /tmp/`hostname`/
#gzip them
tar -zcvf `hostname`.gz /tmp/`hostname`
#email them
SUBJECT='Thread Dumps from '`hostname`
mutt -s $SUBJECT mail@mail.com -a /tmp/`hostname`.gz < text.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment