From 5a52354541bac2dadcdd085dfbda749c543a1c73 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 4 Jan 2019 19:16:47 +0800 Subject: [PATCH] update --- plugins/memcached/index.html | 3 ++- plugins/memcached/index.py | 36 ++++++++++++++++++++++++++++++------ plugins/mysql/index.py | 4 ++-- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/plugins/memcached/index.html b/plugins/memcached/index.html index 61acc3dca..63514e721 100755 --- a/plugins/memcached/index.html +++ b/plugins/memcached/index.html @@ -3,7 +3,8 @@

服务

自启动

-

配置修改

+

配置模板

+

配置文件

负载状态

性能调整

diff --git a/plugins/memcached/index.py b/plugins/memcached/index.py index c51dbc9e2..7179313a0 100755 --- a/plugins/memcached/index.py +++ b/plugins/memcached/index.py @@ -4,12 +4,13 @@ import sys import io import os import time +import re sys.path.append(os.getcwd() + "/class/core") import public app_debug = False -if public.getOs() == 'darwin': +if public.isAppleSystem(): app_debug = True @@ -32,16 +33,37 @@ def getInitDFile(): def getConf(): + path = getServerDir() + "/init.d/memcached" + return path + + +def getConfTpl(): path = getPluginDir() + "/init.d/memcached.tpl" return path +def getMemPort(): + path = getConf() + content = public.readFile(path) + rep = 'PORT\s*=\s*(\d*)' + tmp = re.search(rep, content) + return tmp.groups()[0] + + def getArgs(): args = sys.argv[2:] tmp = {} - for i in range(len(args)): - t = args[i].split(':') + args_len = len(args) + + if args_len == 1: + t = args[0].strip('{').strip('}') + t = t.split(':') tmp[t[0]] = t[1] + elif args_len > 1: + for i in range(len(args)): + t = args[i].split(':') + tmp[t[0]] = t[1] + return tmp @@ -55,7 +77,7 @@ def status(): def initDreplace(): - file_tpl = getConf() + file_tpl = getConfTpl() service_path = public.getServerDir() initD_path = getServerDir() + '/init.d' @@ -110,9 +132,9 @@ def runInfo(): # 获取memcached状态 import telnetlib import re - + port = getMemPort() try: - tn = telnetlib.Telnet('127.0.0.1', 11211) + tn = telnetlib.Telnet('127.0.0.1', int(port)) tn.write(b"stats\n") tn.write(b"quit\n") data = tn.read_all() @@ -221,6 +243,8 @@ if __name__ == "__main__": print runInfo() elif func == 'conf': print getConf() + elif func == 'conf_tpl': + print getConfTpl() elif func == 'save_conf': print saveConf() else: diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 7b4730167..69687c67b 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -188,11 +188,11 @@ def status(): def start(): initMysql = getServerDir() + '/scripts/mysql_install_db ' + '--basedir=' + \ getServerDir() + ' --datadir=' + getServerDir() + '/bin/mysql/data' - # return initMysql + return initMysql cmd = getServerDir() + '/bin/mysqld_safe ' + getServerDir() + \ '/conf/my.cnf ' + '--user=mysql&' - return cmd + # return cmd data = public.execShell(cmd) if data[0] == '': return 'stop'