1 Star 0 Fork 109

paste / MySQLMTOP

forked from 茹憶 / MySQLMTOP 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mtopctl 1.88 KB
一键复制 编辑 原始数据 按行查看 历史
ruzuojun 提交于 2017-07-28 15:36 . 代码目录结构重新调整和优化
#!/bin/bash
basedir=""
#check system,This script must be run on CentOS/RHEL only.
############################################################################
if [ ! -f /etc/redhat-release ]; then
echo "[ERROR]: Sorry, this script is for CentOS/RHEL only."
exit 1
fi
#check basedir
#############################################################################
if test -z "$basedir"
then
basedir=/usr/local/mysqlmtop
else
basedir="$basedir"
fi
arg=$1
mtop_process=`ps -ef|grep mtop |grep -v grep|wc -l`
case "$arg" in
'status')
#check mtop status
if [ $mtop_process -ge "5" ];then
echo "mysql mtop is run!"
else
echo "mysql mtop is not run!"
fi
;;
'start')
#start mtop
if [ $mtop_process -ge "5" ];then
echo "mysql mtop is already run!"
else
cd $basedir && nohup ./mtopd.py & > /dev/null 2>&1
sleep 1
mtop_process=`ps -ef|grep mtop |grep -v grep|wc -l`
if [ $mtop_process -ge "5" ];then
echo "mysql mtop start success!"
else
echo "mysql mtop start fail!"
fi
fi
;;
'stop')
#stop mtop
if [ $mtop_process -le "5" ];then
echo "mysql mtop is not run..."
else
ps -ef |grep -i -E "mtopctl|mtopd.py"|grep -v -E "vi|grep"|awk '{print $2}' |while read line; do kill $line; echo "mtop processes id $line been stop"; done
fi
;;
'--help')
#for help
echo "mysql mtop help:"
echo "support-site:www.mtop.cc www.ruzuojun.com"
echo "===================================================================="
echo "start Start mysql mtop monitor server; Command: #mtopctl start"
echo "stop Stop mysql mtop monitor server; Command: #mtopctl stop"
echo "status Check mysql mtop monitor run status; Command: #mtopctl status"
;;
*)
echo "Please input --help to read the help info."
;;
esac
exit 0
Python
1
https://gitee.com/paste/MySQLMTOP.git
git@gitee.com:paste/MySQLMTOP.git
paste
MySQLMTOP
MySQLMTOP
master

搜索帮助