pull/109/head
midoks 6 years ago
parent d37806f4e0
commit e48dcfa61d
  1. 76
      plugins/abkill/init.d/abkill.tpl
  2. 3
      plugins/abkill/install.sh
  3. 4
      plugins/abkill/script/abkill.py
  4. 2
      plugins/mysql/index.py
  5. 18
      plugins/mysql/versions/5.5/install.sh

@ -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

@ -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
}

@ -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:

@ -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'

@ -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} && 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
cd ${mysqlDir}/mysql-5.5.62 && cmake \
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
&& make && make install
echo '5.5' > $serverPath/mysql/version.pl
echo '安装完成' > $install_tmp
}

Loading…
Cancel
Save