A variety of ways to determine whether to start the mysql

#!/bin/sh

monitor mysql run

#by zkg 2019-08-05

# The following are a number of ways to determine whether to start mysql
#local monitoring
#if [ " netstat -lnt |grep 3306|awk '{print $4}'|awk -F: '{print $2}'" = "3306"]
#if [ ps -ef |grep mysql|grep -v grep|wc -l-gt 0]
#if [ netstat -lntup|grep mysqld|wc -l-gt 0]
#if [ lsof -i tcp:3306|wc -l-gt 0]
#remote monitor
if [ nmap 192.168.31.75 -p 3306 2>/dev/null|grep mysql|wc -l0 -gt]
the then
echo "MySQL IS running"
the else
echo "MySQL stopped IS"
/ Data / MySQL / MySQL Start
Fi

Guess you like

Origin blog.51cto.com/1009516/2426555