1.添加监控配置
#启用内置的监控页面
statViewServlet.enabled=true
#内置监控页面的地址
statViewServlet.urlPattern=/druid/*
#关闭 Reset All 功能
statViewServlet.resetEnable=false
#设置登录用户名
statViewServlet.loginUsername=admin
#设置登录密码
statViewServlet.loginPassword=123
#白名单(如果allow没有配置或者为空,则允许所有访问)
statViewServlet.allow=127.0.0.1
#黑名单(deny优先于allow,如果在deny列表中,就算在allow列表中,也会被拒绝)
statViewServlet.deny=
2.编写druidStat脚本
脚本druid-github官网有
#!/bin/sh
if [ -z "$JAVA_HOME" ] ; then
echo "Error: JAVA_HOME is not defined."
exit 1
fi
basepath=$(cd `dirname $0`; pwd)
dubboName=$(basename $basepath)
pid=$(ps -ef | grep $dubboName | grep -v grep | grep -v "$0" | awk '{print $2 }')
#echo $pid
"$JAVA_HOME/bin/java" -Dfile.encoding="UTF-8" -cp "./lib/druid-1.0.5.jar:$JAVA_HOME/lib/tools.jar" com.alibaba.druid.support.console.DruidStat $@ $pid
3.使用脚本
./druidStat -help