Skip to content

Instantly share code, notes, and snippets.

@iamshreeram
Created August 3, 2019 20:37
Show Gist options
  • Select an option

  • Save iamshreeram/2feeecd47a6b262eb5143c0667f570f7 to your computer and use it in GitHub Desktop.

Select an option

Save iamshreeram/2feeecd47a6b262eb5143c0667f570f7 to your computer and use it in GitHub Desktop.
takes dump and top file
#!/bin/bash
mondir="/tmp"
if [ ! -d $mondir ];then
mkdir $mondir
fi
DATE=`date "+%Y:%m:%d-%H:%M:%S"`
pid=`ps -eaf | grep 'java'| grep -v grep | awk -F' ' '{print $2}'`
jcmd org.apache.catalina.startup.Bootstrap Thread.print>>$mondir/jcmdr.$pid.$(date "+%m%d%H%M%S")
top -H -b -n1 -p $pid>>$mondir/top.$pid.$(date "+%m%d%H%M%S")
# jcmd $pid GC.heap_dump filename=$mondir/heapdump.$pid.$(date "+%m%d%H%M%S")
if [ `df -P | awk '0+$5 >= 80 {print $0}'`];then
df -P | awk -v dat=$DATE '0+$5 >= 80 {print dat " - "$0}'>>$mondir/diskspace.$pid.$(date "+%m%d%H%M%S")
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment