0
点赞
收藏
分享

微信扫一扫

达梦数据库服务器CPU使用率监控


脚本内容:

#!/bin/bash
TMPDIR=`ps -ef|grep dmserver|grep -v grep|awk '{print $8}'`
export DM_HOME=`echo ${TMPDIR%%/bin*}`
#Change the password of SYSDBA
SYSDBA_PASSWD=SYSDBA
#change IP
IP=localhost
#change PORT
PORT=5236
export PATH=$PATH:$DM_HOME/bin
while(true)
do
/bin/sleep 1
idle_cpu=`sar -u 1 1 | sed -n 4p | awk '{print $8}'`
cpu_used=$(printf "%.2f" `echo "100-$idle_cpu"|bc`)
cpuinfo=`echo "current cpu_used is:" $cpu_used% $(date "+%Y-%m-%d %H:%M:%S")`
echo "--------------------------------------------------------------------------------"
echo $cpuinfo
echo "--------------------------------------------------------------------------------"
if [ $(echo "$cpu_used > 80.00" | bc) -eq 1 ] ; then
echo "WARNING! The cpu usage is greater than 80%."
echo " "
echo "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND"
ps aux | grep -v USER | sort -rn -k3 | head
echo "--------------------------------------------------------------------------------"
disql -s SYSDBA/''\"$DB_USERPASSWD\"''@$IP:$PORT -e "select 'ACTTIVE:'||(select count(1) from v\$sessions where state='ACTIVE') ||' TOTAL:'||(select count(1) from v\$sessions) as session_info from dual;"
fi
done

执行脚本:
nohup /bin/bash /home/dmdba/cpu_monitor.sh >> cpucheck.log 2>&1 &

举报

相关推荐

0 条评论