Guest User

Untitled

a guest
Oct 16th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. TEMPLATE="/opt/tomcat/OutOfMemoryError.html"
  4. APP_ENV="/opt/tomcat/conf/tomcat-env.sh"
  5. [ -r "$APP_ENV" ] && . "${APP_ENV}"
  6.  
  7. IP=`ifconfig venet0:0 | awk /venet0:0/'{next}//{split($0,a,":");split(a[2],a," ");print a[1];exit}'`
  8. HOST=`hostname`
  9. JVM_PID="`ps awwx | grep \"jvm=$JVM_ID \" | grep -v grep | head -n 1 | cut -c -5`"
  10. PSOUT=`ps -p $JVM_PID u | tail -n 1`
  11. MD=(`echo $PSOUT | awk 'BEGIN {FS="[ \t]+"} {for (i=1; i<=10; i++) print $i}'`)
  12. USR_COMMAND=`echo $PSOUT | awk 'BEGIN {cmd=""} {for (i=11; i<=NF; i++) cmd = cmd " " $i} END {print cmd}'`
  13.  
  14. 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"
  15.  
  16. mail -s "OutOfMemoryError Node: tomcat" andrey.nm80@gmail.com < "/tmp/$$.mail"
  17. rm "/tmp/$$.mail"
  18. echo $(echo "sudo /etc/init.d/tomcat stop; sudo /etc/init.d/tomcat start" | at now)
Add Comment
Please, Sign In to add comment