Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- TEMPLATE="/opt/tomcat/OutOfMemoryError.html"
- APP_ENV="/opt/tomcat/conf/tomcat-env.sh"
- [ -r "$APP_ENV" ] && . "${APP_ENV}"
- IP=`ifconfig venet0:0 | awk /venet0:0/'{next}//{split($0,a,":");split(a[2],a," ");print a[1];exit}'`
- HOST=`hostname`
- JVM_PID="`ps awwx | grep \"jvm=$JVM_ID \" | grep -v grep | head -n 1 | cut -c -5`"
- PSOUT=`ps -p $JVM_PID u | tail -n 1`
- MD=(`echo $PSOUT | awk 'BEGIN {FS="[ \t]+"} {for (i=1; i<=10; i++) print $i}'`)
- USR_COMMAND=`echo $PSOUT | awk 'BEGIN {cmd=""} {for (i=11; i<=NF; i++) cmd = cmd " " $i} END {print cmd}'`
- sed "s/%(IP)/$IP/;s/%(HOST)/$HOST/;s/%(USER)/${MD[0]}/;s/%(PID)/${MD[1]}/;s/%(CPU)/${MD[2]}/;s/%(MEM)/${MD[3]}/;s/%(VSZ)/${MD[4]}/;s/%(RSS)/${MD[5]}/;s/%(TTY)/${MD[6]}/;s/%(STAT)/${MD[7]}/;s/%(START)/${MD[8]}/;s/%(TIME)/${MD[9]}/;s/%(COMMAND)/$(echo $USR_COMMAND | sed "s/\//\\\\\//g;s/\./\\\\./g")/" $TEMPLATE > "/tmp/$$.mail"
- mail -s "OutOfMemoryError Node: tomcat" andrey.nm80@gmail.com < "/tmp/$$.mail"
- rm "/tmp/$$.mail"
- echo $(echo "sudo /etc/init.d/tomcat stop; sudo /etc/init.d/tomcat start" | at now)
Add Comment
Please, Sign In to add comment