From 386ed67354d88dac97a79053344d7be94b27f5de Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 8 Dec 2018 16:24:36 +0800 Subject: [PATCH] update --- plugins/openresty/conf/nginx_status.conf | 2 +- plugins/openresty/index.py | 17 ++++++++++++++++ plugins/openresty/js/openresty.js | 25 +++++++++++++----------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/plugins/openresty/conf/nginx_status.conf b/plugins/openresty/conf/nginx_status.conf index e8dd05cef..1f9cdc9a2 100644 --- a/plugins/openresty/conf/nginx_status.conf +++ b/plugins/openresty/conf/nginx_status.conf @@ -1,5 +1,5 @@ server { - listen 80; + listen 6666; server_name 127.0.0.1; allow 127.0.0.1; location /nginx_status { diff --git a/plugins/openresty/index.py b/plugins/openresty/index.py index 0e69b7310..cdd38d860 100755 --- a/plugins/openresty/index.py +++ b/plugins/openresty/index.py @@ -201,6 +201,21 @@ def initdUinstall(): return 'ok' +def runInfo(): + # 取Openresty负载状态 + result = public.httpGet('http://127.0.0.1:6666/nginx_status') + tmp = result.split() + data = {} + data['active'] = tmp[2] + data['accepts'] = tmp[9] + data['handled'] = tmp[7] + data['requests'] = tmp[8] + data['Reading'] = tmp[11] + data['Writing'] = tmp[13] + data['Waiting'] = tmp[15] + return public.getJson(data) + + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -221,5 +236,7 @@ if __name__ == "__main__": print initdUinstall() elif func == 'conf': print getConf() + elif func == 'run_info': + print runInfo() else: print 'error' diff --git a/plugins/openresty/js/openresty.js b/plugins/openresty/js/openresty.js index e6d38a5fe..f6faaab21 100755 --- a/plugins/openresty/js/openresty.js +++ b/plugins/openresty/js/openresty.js @@ -249,18 +249,21 @@ function addWafKey(name) { function getOpenrestyStatus() { $.post('/plugins/run', {name:'openresty', func:'run_info'}, function(data) { - console.log(data); - },'json'); - $.post('/ajax?action=GetNginxStatus', '', function(rdata) { + if (!data.status){ + showMsg(data.msg, function(){}, null,3000); + return; + } + + var rdata = $.parseJSON(data.data); var con = "
\ - \ - \ - \ - \ - \ - \ - \ -
" + lan.bt.nginx_active + "" + rdata.active + "
" + lan.bt.nginx_accepts + "" + rdata.accepts + "
" + lan.bt.nginx_handled + "" + rdata.handled + "
" + lan.bt.nginx_requests + "" + rdata.requests + "
" + lan.bt.nginx_reading + "" + rdata.Reading + "
" + lan.bt.nginx_writing + "" + rdata.Writing + "
" + lan.bt.nginx_waiting + "" + rdata.Waiting + "
"; + 活动连接(Active connections)" + rdata.active + "\ + 总连接次数(accepts)" + rdata.accepts + "\ + 总握手次数(handled)" + rdata.handled + "\ + 总请求数(requests)" + rdata.requests + "\ + 请求数(Reading)" + rdata.Reading + "\ + 响应数(Writing)" + rdata.Writing + "\ + 驻留进程(Waiting)" + rdata.Waiting + "\ + "; $(".soft-man-con").html(con); },'json'); }