您的位置:首页 > 数据库 > SQL

mysql监控

2016-04-17 17:06 691 查看
#!/bin/sh

#this script is created by oldboy 20160410

#fun:compare two num

#V1.0

read -t 10 -p "please input two num:" a b

if [ $a -gt $b ];then

#if (($a > $b));then
echo "yes $a > $b"

elif [ $a -eq $b ];then
echo "yes $a == $b"

else
echo "yes $a < $b"

fi

fack -A修复系统

1.命令行参数或者read读入的方式

2.对读入的数字做参数个数及是参数否数字的判断

3.开发脚本对http服务的监控

4.开发脚本实现对mysql的监控

判断mysql正常启动的几种方法

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

netstat -lnt|grep 3306|awk -F '[ :]+' '{print $5}

#!/bin/sh

#this script is created by oldboy 20160410

#fun:compare two num

#V1.0

protNum='netstat -lnt|grep 3306|awk -F '[ :]+' '{print $5}'

if[ $portNum eq 3306 ];then

    echo "db is running"

else 

    /data/3306/mysql restart

fi

第二种方法

#!/bin/sh

#this script is created by oldboy 20160410

#244541309@qq.com

#fun:compare two num

#V1.0

protNum=`netstat -lnt|grep 3306|awk -F '[ :]+' '{print $5}'`

if[ "$portNum" == "3306" ];then

    echo "db is running"

else

    /data/3306/mysql restart

fi

第三种#!/bin/sh

#this script is created by oldboy 20160410

#fun:compare two num

#V1.0

protNum=`netstat -lnt|grep 3306|wc -l`

echo $protNum

if[ $protNum -eq 1 ]then

    echo "db is running"

else

    /data/3306/mysql restart
fi

syntax error near unexpected t

结果执行时出现“syntax
error near unexpected token `then'”,看半天没看出原因,上网查了半天,终于搞明白了原因:if 与‘['之间没有加空格导致的。另外,在执行时,我也发现 ‘=’两边必须也得加空格,否则也会出错,不是语法出错,而是不管赋给a的值是多少,程序都会得到if 后面的语句为假,从而得出wrong的情况。oken `then'问题的解决
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: