zabbix3.0.4关于java服务端程序内存溢出的处理
关于java服务端程序内存溢出的处理
java服务端程序内存溢出会产生jvm.log文件,此时程序会挂掉,无法正常处理业务,需要重启服务
思路:
当存在jvm.log这个文件的时候则触发clean_jvmlog.sh脚本删除jvm.log文件并重启对应的服务
1.添加触发器
vim /etc/zabbix/zabbix_agentd.conf
加入如下选项
UserParameter=jvm_count,sudo /bin/find /home/yunva -name jvm.log|wc -l
EnableRemoteCommands = 1
2.删除jvm.log并且重启服务脚本clean_jvmlog.sh
vim /usr/local/zabbix/scripts/clean_jvmlog.sh
dirpath1=/home/yunva/spark-task/
for path1 in `ls ${dirpath1}`
do
if [ -f $dirpath1/$path1/jvm.log ];then
rm -f $dirpath1/$path1/jvm.log
cd $dirpath1/$path1/
/bin/bash start.sh stop
sleep 3
/bin/bash start.sh start
fi
done
dirpath2=/home/yunva/remote-spark-task
for path2 in `ls ${dirpath2}`
do
if [ -f $dirpath2/$path2/jvm.log ];then
rm -f $dirpath2/$path2/jvm.log
cd $dirpath2/$path2/
/bin/bash start.sh stop
sleep 3
/bin/bash start.sh start
fi
done
java服务端程序内存溢出会产生jvm.log文件,此时程序会挂掉,无法正常处理业务,需要重启服务
思路:
当存在jvm.log这个文件的时候则触发clean_jvmlog.sh脚本删除jvm.log文件并重启对应的服务
1.添加触发器
vim /etc/zabbix/zabbix_agentd.conf
加入如下选项
UserParameter=jvm_count,sudo /bin/find /home/yunva -name jvm.log|wc -l
EnableRemoteCommands = 1
2.删除jvm.log并且重启服务脚本clean_jvmlog.sh
vim /usr/local/zabbix/scripts/clean_jvmlog.sh
dirpath1=/home/yunva/spark-task/
for path1 in `ls ${dirpath1}`
do
if [ -f $dirpath1/$path1/jvm.log ];then
rm -f $dirpath1/$path1/jvm.log
cd $dirpath1/$path1/
/bin/bash start.sh stop
sleep 3
/bin/bash start.sh start
fi
done
dirpath2=/home/yunva/remote-spark-task
for path2 in `ls ${dirpath2}`
do
if [ -f $dirpath2/$path2/jvm.log ];then
rm -f $dirpath2/$path2/jvm.log
cd $dirpath2/$path2/
/bin/bash start.sh stop
sleep 3
/bin/bash start.sh start
fi
done