mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 05:59:25 +08:00
update
This commit is contained in:
+23
-16
@@ -107,6 +107,26 @@ class plugin_api:
|
||||
else:
|
||||
return_dict[i] = False
|
||||
|
||||
def checkStatusMProcess(self, plugins_info):
|
||||
manager = multiprocessing.Manager()
|
||||
return_dict = manager.dict()
|
||||
jobs = []
|
||||
ntmp_list = range(len(plugins_info))
|
||||
for i in ntmp_list:
|
||||
p = multiprocessing.Process(
|
||||
target=self.checkStatusProcess, args=(plugins_info[i], i, return_dict))
|
||||
jobs.append(p)
|
||||
p.start()
|
||||
|
||||
for proc in jobs:
|
||||
proc.join()
|
||||
|
||||
returnData = return_dict.values()
|
||||
for i in ntmp_list:
|
||||
plugins_info[i]['status'] = returnData[i]
|
||||
|
||||
return plugins_info
|
||||
|
||||
def checkDisplayIndex(self, name, version):
|
||||
if not os.path.exists(self.__index):
|
||||
public.writeFile(self.__index, '[]')
|
||||
@@ -265,22 +285,7 @@ class plugin_api:
|
||||
except Exception, e:
|
||||
print e
|
||||
|
||||
manager = multiprocessing.Manager()
|
||||
return_dict = manager.dict()
|
||||
jobs = []
|
||||
ntmp_list = range(len(plugins_info))
|
||||
for i in ntmp_list:
|
||||
p = multiprocessing.Process(
|
||||
target=self.checkStatusProcess, args=(plugins_info[i], i, return_dict))
|
||||
jobs.append(p)
|
||||
p.start()
|
||||
|
||||
for proc in jobs:
|
||||
proc.join()
|
||||
|
||||
returnData = return_dict.values()
|
||||
for i in ntmp_list:
|
||||
plugins_info[i]['status'] = returnData[i]
|
||||
plugins_info = self.checkStatusMProcess(plugins_info)
|
||||
return plugins_info
|
||||
|
||||
def makeListThread(self, data, sType='0'):
|
||||
@@ -446,6 +451,8 @@ class plugin_api:
|
||||
continue
|
||||
except Exception, e:
|
||||
print e
|
||||
|
||||
plist = self.checkStatusMProcess(plist)
|
||||
return plist
|
||||
|
||||
def setIndexSort(self, sort):
|
||||
|
||||
@@ -106,65 +106,6 @@ def reload():
|
||||
return 'fail'
|
||||
|
||||
|
||||
def runInfo():
|
||||
# 获取memcached状态
|
||||
import telnetlib
|
||||
import re
|
||||
|
||||
try:
|
||||
tn = telnetlib.Telnet('127.0.0.1', 11211)
|
||||
tn.write(b"stats\n")
|
||||
tn.write(b"quit\n")
|
||||
data = tn.read_all()
|
||||
if type(data) == bytes:
|
||||
data = data.decode('utf-8')
|
||||
data = data.replace('STAT', '').replace('END', '').split("\n")
|
||||
result = {}
|
||||
res = ['cmd_get', 'get_hits', 'get_misses', 'limit_maxbytes', 'curr_items', 'bytes',
|
||||
'evictions', 'limit_maxbytes', 'bytes_written', 'bytes_read', 'curr_connections']
|
||||
for d in data:
|
||||
if len(d) < 3:
|
||||
continue
|
||||
t = d.split()
|
||||
if not t[0] in res:
|
||||
continue
|
||||
result[t[0]] = int(t[1])
|
||||
result['hit'] = 1
|
||||
if result['get_hits'] > 0 and result['cmd_get'] > 0:
|
||||
result['hit'] = float(result['get_hits']) / \
|
||||
float(result['cmd_get']) * 100
|
||||
|
||||
conf = public.readFile(getConf())
|
||||
result['bind'] = re.search('IP=(.+)', conf).groups()[0]
|
||||
result['port'] = int(re.search('PORT=(\d+)', conf).groups()[0])
|
||||
result['maxconn'] = int(re.search('MAXCONN=(\d+)', conf).groups()[0])
|
||||
result['cachesize'] = int(
|
||||
re.search('CACHESIZE=(\d+)', conf).groups()[0])
|
||||
return public.getJson(result)
|
||||
except Exception, e:
|
||||
return public.getJson({})
|
||||
|
||||
|
||||
def saveConf():
|
||||
# 设置memcached缓存大小
|
||||
import re
|
||||
confFile = getConf()
|
||||
try:
|
||||
args = getArgs()
|
||||
content = public.readFile(confFile)
|
||||
content = re.sub('IP=.+', 'IP=' + args['ip'], content)
|
||||
content = re.sub('PORT=\d+', 'PORT=' + args['port'], content)
|
||||
content = re.sub('MAXCONN=\d+', 'MAXCONN=' + args['maxconn'], content)
|
||||
content = re.sub('CACHESIZE=\d+', 'CACHESIZE=' +
|
||||
args['cachesize'], content)
|
||||
public.writeFile(confFile, content)
|
||||
reload()
|
||||
return 'ok'
|
||||
except Exception as e:
|
||||
pass
|
||||
return 'fail'
|
||||
|
||||
|
||||
def initdStatus():
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
|
||||
Reference in New Issue
Block a user