diff --git a/plugins/simpleping/index.py b/plugins/simpleping/index.py index 856116ec2..89a8b16fb 100755 --- a/plugins/simpleping/index.py +++ b/plugins/simpleping/index.py @@ -265,40 +265,16 @@ def runLog(): return getServerDir() + '/data/log.pl' -def getRedisConfInfo(): - conf = getServerDir() + '/redis.conf' - - gets = [ - {'name': 'bind', 'type': 2, 'ps': '绑定IP(修改绑定IP可能会存在安全隐患)','must_show':1}, - {'name': 'port', 'type': 2, 'ps': '绑定端口','must_show':1}, - {'name': 'timeout', 'type': 2, 'ps': '空闲链接超时时间,0表示不断开','must_show':1}, - {'name': 'maxclients', 'type': 2, 'ps': '最大连接数','must_show':1}, - {'name': 'databases', 'type': 2, 'ps': '数据库数量','must_show':1}, - {'name': 'requirepass', 'type': 2, 'ps': 'redis密码,留空代表没有设置密码','must_show':1}, - {'name': 'maxmemory', 'type': 2, 'ps': 'MB,最大使用内存,0表示不限制','must_show':1}, - {'name': 'slaveof', 'type': 2, 'ps': '同步主库地址','must_show':0}, - {'name': 'masterauth', 'type': 2, 'ps': '同步主库密码', 'must_show':0} - ] - content = mw.readFile(conf) - - result = [] - for g in gets: - rep = "^(" + g['name'] + ')\s*([.0-9A-Za-z_& ~]+)' - tmp = re.search(rep, content, re.M) - if not tmp: - if g['must_show'] == 0: - continue - - g['value'] = '' - result.append(g) - continue - g['value'] = tmp.groups()[1] - if g['name'] == 'maxmemory': - g['value'] = g['value'].strip("mb") - result.append(g) - - return result - +def ipList(): + config = getServerDir() + '/conf/app.conf' + content = mw.readFile(config) + rep = 'ip\s*=\s*(.*)' + tmp = re.search(rep, content) + if not tmp: + return '' + ip = tmp.groups()[0] + ips = ip.split(",") + return mw.returnJson(True, 'OK', ips) if __name__ == "__main__": func = sys.argv[1] @@ -320,15 +296,7 @@ if __name__ == "__main__": print(initdUinstall()) elif func == 'conf': print(getConf()) - elif func == 'run_log': - print(runLog()) - elif func == 'get_redis_conf': - print(getRedisConf()) - elif func == 'submit_redis_conf': - print(submitRedisConf()) - elif func == 'config_tpl': - print(configTpl()) - elif func == 'read_config_tpl': - print(readConfigTpl()) + elif func == 'ip_list': + print(ipList()) else: print('error') diff --git a/plugins/simpleping/js/simpleping.js b/plugins/simpleping/js/simpleping.js index 550b1c1f6..d0456e394 100755 --- a/plugins/simpleping/js/simpleping.js +++ b/plugins/simpleping/js/simpleping.js @@ -136,7 +136,8 @@ function pingDataGraphPosData(){ var dlen = chartPingData.length; last_pos = chartPingData[dlen-1]; // console.log(start,end); - pingPostCallbakN('pingData', {'type':'pos', 'pos':last_pos['created_unix']}, function(data){ + var cur_ip = $('select[name="ip_list"]').val(); + pingPostCallbakN('pingData', {'type':'pos', 'pos':last_pos['created_unix'],"ip":cur_ip}, function(data){ var tmp_data = data.data; for (x in tmp_data){ chartPingData.push(tmp_data[x]); @@ -167,8 +168,9 @@ function pingDataGraphData(day){ var end = Math.round(now); } + var cur_ip = $('select[name="ip_list"]').val(); // console.log(start,end); - pingPostCallbak('pingData', {'type':'range', 'start':start, 'end':end}, function(data){ + pingPostCallbak('pingData', {'type':'range', 'start':start, 'end':end, 'ip':cur_ip}, function(data){ chartPingData = data.data; pingDataGraphRender(); @@ -223,11 +225,33 @@ function pingDataGraphRender(){ ] }; chartPing.setOption(option); +} + +function pingIpList(){ + pingPost('ip_list', {}, function(data){ + var rdata = $.parseJSON(data.data); + var ips = rdata.data; + + var option = ''; + option += ''; + + for (var i = 0; i < ips.length; i++) { + option += ''; + } + $('select[name="ip_list"]').html(option); + + + $('select[name="ip_list"]').change(function(){ + chartPingData = []; + pingDataGraphData(0); + }); + + pingDataGraphData(0); + }); } // console.log('pingDataGraph'); - function pingDataGraph(){ var tpl = '\