Last active
August 29, 2015 14:03
-
-
Save jiaozhu/b09d09f53e569682e70e to your computer and use it in GitHub Desktop.
定期检测JAVA进程CPU占用,假如超过10%,则生成THREADDUMP信息
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
##################################################################### | |
# # | |
# Env:Aix # | |
# Copyright (c) 2014, jiaozhu <[email protected]> # | |
# All rights reserved. # | |
# Distributed under the GNU General Public License, version 3.0. # | |
# # | |
##################################################################### | |
JAVAPLSIT=`ps aux| grep java|grep -v grep | awk '{OFS=":";print $2,$3}'` | |
for i in $JAVAPLSIT; do | |
PID=`echo $i |awk -F: '{print $1}'` | |
CPUUSAGE=`echo $i |awk -F: '{print $2}'` | |
if [ $CPUUSAGE -gt 10 ]; then | |
echo "发现存在问题的JAVA进程,将要对此进程做THREADDUMP" | |
echo "进程PID为:"$PID | |
kill -3 $PID | |
echo "DUMP日志生成完毕,请检查域下生成的DUMP信息" | |
echo "DUMP日志生成的时间为:"`date` | |
else | |
echo "系统一切正常" | |
fi | |
echo " " | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment