mycheckpoint --host=localhost --port=3306 --user=moni_user --password=moni_passwd --database=check_host1 --monitored-host=host1 --monitored-port=3306
#!/bin/bash
#Edit by zheng.zhang@enmotech.com 2013-08-09
#This script. is helpful that using mycheckpoint monitor mysql server.
#Here are some parameters:
HOST=localhost
USER=moni_user
PASSWD=moni_passwd
DATABASE=check_master
SOCKET="-S xxxxxx "
PORT=
LOGFILE_PATH="/root/mycheckpoint_http.log"
pid=`ps -ef|grep mycheckpoint |grep -v grep|grep python|grep mycheckpoint|awk '{print $2}'`
case "$*" in
start)
test -z $pid
if (( $? > 0 ))
then
echo "-------------------------------------------------------"
echo "..........mycheckpoint_http is running(pid $pid) ......"
echo "-------------------------------------------------------"
else
nohup mycheckpoint --host=$HOST -u $USER -p$PASSWD --database=$DATABASE http >> $LOGFILE_PATH &
v_time1=`date "+%Y-%m-%d %H:%M:%S"`
echo "mycheckpoint started at : $v_time1 " >> $LOGFILE_PATH
sleep 2
new_pid=`ps -ef|grep mycheckpoint |grep -v grep|grep python|grep mycheckpoint|awk '{print $2}'`
echo "---------------------------------------------------------"
echo "..........mycheckpoint_http started,pid is $new_pid......"
echo "---------------------------------------------------------"
fi
;;
stop)
test -z $pid
if (( $? > 0 ))
then
kill -9 $pid
v_time=`date "+%Y-%m-%d %H:%M:%S"`
echo "mycheckpoint stopped at : $v_time " >> $LOGFILE_PATH
echo "-----------------------------------------"
echo "..........mycheckpoint_http stopped......"
echo "-----------------------------------------"
else
echo "------------------------------------------------"
echo "..........mycheckpoint_http is not running......"
echo "------------------------------------------------"
fi
;;
status)
test -z $pid
if (( $? > 0 ))
then
echo "------------------------------------------------------"
echo "..........mycheckpoint_http is running.....(PID $pid)"
echo "------------------------------------------------------"
else
echo "------------------------------------------------"
echo "..........mycheckpoint_http is not running......"
echo "------------------------------------------------"
fi
;;
restart)
######stop######
echo -n " stopping mysql_monitor......"
sleep 1
test -z $pid
if (( $? > 0 ))
then
kill -9 $pid
v_time=`date "+%Y-%m-%d %H:%M:%S"`
echo "mycheckpoint stopped at : $v_time " >> $LOGFILE_PATH
echo ".[OK] "
else
echo ".[FAILED] (mysql_mointor is not running)"
fi
sleep 1
######start######
pid=`ps -ef|grep mycheckpoint |grep -v grep|grep python|grep mycheckpoint|awk '{print $2}'`
echo -n " starting mysql_monitor......"
sleep 1
test -z $pid
if (( $? > 0 ))
then
echo ".[FAILED] "
echo " mycheckpoint_http is running(pid $pid) .........."
else
nohup mycheckpoint --host=$HOST -u $USER -p$PASSWD --database=$DATABASE http >> $LOGFILE_PATH &
v_time1=`date "+%Y-%m-%d %H:%M:%S"`
echo "mycheckpoint started at : $v_time1 " >> $LOGFILE_PATH
sleep 2
new_pid=`ps -ef|grep mycheckpoint |grep -v grep|grep python|grep mycheckpoint|awk '{print $2}'`
echo ".[OK] (pid is $new_pid)"
fi
;;
*)
echo "----------------------------------------------------"
echo " please input: start | status | stop | restart"
echo "----------------------------------------------------"
;;
esac
|