监控数据库脚本四

[root@db01-51 scripts]# cat check_db.sh 
#!/bin/bash
#remote
if [ "`nc -w 2 10.0.0.51 3306 &>/dev/null echo ok|grep ok|wc -l `" -gt 0 ]
  then
    echo "MySQL is running"
  else
    echo "MySQL is stoped"
    /etc/init.d/mysqld start
fi

  

posted @ 2017-03-09 22:30  reborn枪  阅读(89)  评论(0)    收藏  举报