diff --git a/plugins/abkill/init.d/abkill.tpl b/plugins/abkill/init.d/abkill.tpl new file mode 100644 index 000000000..5534b24e9 --- /dev/null +++ b/plugins/abkill/init.d/abkill.tpl @@ -0,0 +1,76 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin + +ak_path={$SERVER_PATH}/abkill + +ak_start(){ + isStart=$(ps aux |grep 'abkill.py'|grep -v grep|awk '{print $2}') + if [ "$isStart" == '' ];then + echo -e "Starting abkill... \c" + cd $ak_path && nohup python abkill.py >> $ak_path/task.log 2>&1 & + sleep 0.3 + isStart=$(ps aux |grep 'abkill.py'|grep -v grep|awk '{print $2}') + if [ "$isStart" == '' ];then + echo -e "\033[31mfailed\033[0m" + echo '------------------------------------------------------' + tail -n 20 $ak_path/task.log + echo '------------------------------------------------------' + echo -e "\033[31mError: abkill service startup failed.\033[0m" + return; + fi + echo -e "\033[32mdone\033[0m" + else + echo "Starting abkill(pid $isStart) already running" + fi +} + + +ak_stop() +{ + echo -e "Stopping abkill... \c"; + pids=$(ps aux | grep 'abkill.py' | grep -v grep|awk '{print $2}') + arr=($pids) + + for p in ${arr[@]} + do + kill -9 $p + done + echo -e "\033[32mdone\033[0m" + +} + +ak_status() +{ + isStart=$(ps aux|grep 'abkill.py'|grep -v grep|awk '{print $2}') + if [ "$isStart" != '' ];then + echo -e "\033[32mabkill (pid $(echo $isStart)) already running\033[0m" + else + echo -e "\033[31mabkill not running\033[0m" + fi +} + + +ak_reload() +{ + isStart=$(ps aux|grep 'abkill.py'|grep -v grep|awk '{print $2}') + + if [ "$isStart" != '' ];then + ak_stop + ak_start + else + echo -e "\033[31mmw not running\033[0m" + mw_start + fi +} + + +case "$1" in + 'start') ak_start;; + 'stop') ak_stop;; + 'reload') ak_reload;; + 'restart') + ak_stop + sleep 0.3 + ak_start;; + 'status') ak_status;; +esac \ No newline at end of file diff --git a/plugins/abkill/install.sh b/plugins/abkill/install.sh index 0bb777503..8b92a9131 100755 --- a/plugins/abkill/install.sh +++ b/plugins/abkill/install.sh @@ -10,7 +10,6 @@ serverPath=$(dirname "$rootPath") install_tmp=${rootPath}/tmp/bt_install.pl - Install_abkill() { echo '正在安装脚本文件...' > $install_tmp @@ -21,7 +20,7 @@ Install_abkill() Uninstall_abkill() { - rm -rf $serverPath/abkill + rm -f $serverPath/abkill echo "卸载完成" > $install_tmp } diff --git a/plugins/abkill/abkill.py b/plugins/abkill/script/abkill.py similarity index 97% rename from plugins/abkill/abkill.py rename to plugins/abkill/script/abkill.py index 709417124..3f9df2fbd 100755 --- a/plugins/abkill/abkill.py +++ b/plugins/abkill/script/abkill.py @@ -31,12 +31,12 @@ class btkill: if cputimes.user < 0.1: continue print p - percent = p.cpu_percent(interval=0.1) + percent = p.cpu_percent(interval=1) vm = p.memory_info().vms if percent > self.__limit or vm > self.__vmsize: log = time.strftime('%Y-%m-%d %X', time.localtime()) + " (PID=" + str( pid) + ", NAME=" + name + ", VMS=" + str(vm) + ", PERCENT=" + str(percent) + "%)" - p.kill() + # p.kill() num += 1 print log + " >> killed\n" except Exception as ex: diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 7823205d8..5a23b6c20 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -144,7 +144,7 @@ MySQL_Opt def status(): data = public.execShell( - "ps -ef|grep redis |grep -v grep | grep -v python | awk '{print $2}'") + "ps -ef|grep mysqld |grep -v grep | grep -v python | awk '{print $2}'") if data[0] == '': return 'stop' return 'start' diff --git a/plugins/mysql/versions/5.5/install.sh b/plugins/mysql/versions/5.5/install.sh index fe063f001..7d5d49c86 100755 --- a/plugins/mysql/versions/5.5/install.sh +++ b/plugins/mysql/versions/5.5/install.sh @@ -2,6 +2,9 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH +#https://dev.mysql.com/downloads/mysql/5.5.html#downloads +#https://dev.mysql.com/downloads/file/?id=480541 + curPath=`pwd` rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") @@ -17,17 +20,20 @@ Install_mysql() echo '正在安装脚本文件...' > $install_tmp if [ ! -f ${mysqlDir}/mysql-5.5.62.tar.gz ];then - wget -O ${mysqlDir}/mysql-5.5.62.tar.gz https://github.com/mysql/mysql-server/archive/mysql-5.5.62.tar.gz + wget -O ${mysqlDir}/mysql-5.5.62.tar.gz https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz + fi + + if [ ! -f ${mysqlDir}/mysql-5.5.62 ];then + tar -zxvf ${mysqlDir}/mysql-5.5.62.tar.gz fi + + cd ${mysqlDir}/mysql-5.5.62 && cmake \ + -DCMAKE_INSTALL_PREFIX=$serverPath/mysql \ + && make && make install - cd ${mysqlDir} && tar -zxvf mysql-5.5.62.tar.gz - # cd ${mysqlDir}/mysql-5.5.62 && ./configure --prefix=$serverPath/mysql \ - # --with-openssl=$serverPath/source/lib/openssl-1.0.2q \ - # --with-http_stub_status_module && make && make install && \ echo '5.5' > $serverPath/mysql/version.pl - echo '安装完成' > $install_tmp }