From 63e272c4c60d93d8d3d1c43a57b4a68c507e7f20 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Wed, 19 Dec 2018 15:21:31 +0800 Subject: [PATCH] update --- class/core/public.py | 12 +------- plugins/php/conf/phpfpm_status.conf | 5 +++ plugins/php/conf/www.conf | 3 +- plugins/php/index.html | 2 +- plugins/php/index.py | 11 +++++++ plugins/php/js/php.js | 47 +++++++++++++++-------------- 6 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 plugins/php/conf/phpfpm_status.conf diff --git a/class/core/public.py b/class/core/public.py index 58583c324..c4d1e20b6 100755 --- a/class/core/public.py +++ b/class/core/public.py @@ -454,9 +454,7 @@ def isRestart(): def isUpdateLocalSoft(): - num = M('tasks').where('status!=?', ('1',)).count() - if os.path.exists('mdserver-web.zip'): return True @@ -476,7 +474,7 @@ def hasPwd(password): return crypt.crypt(password, password) -def get_timeout(url): +def getTimeout(url): start = time.time() result = httpGet(url) if result != 'True': @@ -557,14 +555,6 @@ def checkToken(get): return True -def get_webserver(): - # 获取Web服务器 - webserver = 'nginx' - if not os.path.exists('/www/server/nginx/sbin/nginx'): - webserver = 'apache' - return webserver - - def checkInput(data): # 过滤输入 if not data: diff --git a/plugins/php/conf/phpfpm_status.conf b/plugins/php/conf/phpfpm_status.conf new file mode 100644 index 000000000..4da6f2816 --- /dev/null +++ b/plugins/php/conf/phpfpm_status.conf @@ -0,0 +1,5 @@ +location /phpfpm_status_{$PHP_VERSION} { + fastcgi_pass unix:/tmp/php-cgi-{$PHP_VERSION}.sock; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; +} \ No newline at end of file diff --git a/plugins/php/conf/www.conf b/plugins/php/conf/www.conf index df5c911de..e693b0921 100644 --- a/plugins/php/conf/www.conf +++ b/plugins/php/conf/www.conf @@ -6,4 +6,5 @@ pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 -pm.max_spare_servers = 3 \ No newline at end of file +pm.max_spare_servers = 3 +pm.status_path = /phpfpm_status_{$PHP_VERSION} \ No newline at end of file diff --git a/plugins/php/index.html b/plugins/php/index.html index 3a617d748..910a5405c 100755 --- a/plugins/php/index.html +++ b/plugins/php/index.html @@ -10,7 +10,7 @@

配置文件

禁用函数

性能调整

-

负载状况

+

负载状况

FPM日志

慢日志

PHPIFNO

diff --git a/plugins/php/index.py b/plugins/php/index.py index acf8df75f..2200d4c7d 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -399,6 +399,15 @@ def setFpmConfig(version): return public.returnJson(True, '设置成功') +def getFpmStatus(version): + + result = public.httpGet( + 'http://127.0.0.1/phpfpm_status_' + version + '?json') + tmp = json.loads(result) + fTime = time.localtime(int(tmp['start time'])) + tmp['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime) + return public.getJson(tmp) + if __name__ == "__main__": if len(sys.argv) < 3: @@ -438,5 +447,7 @@ if __name__ == "__main__": print getFpmConfig(version) elif func == 'set_fpm_conf': print setFpmConfig(version) + elif func == 'get_fpm_status': + print getFpmStatus(version) else: print "fail" diff --git a/plugins/php/js/php.js b/plugins/php/js/php.js index 09761a97f..a131f38d3 100755 --- a/plugins/php/js/php.js +++ b/plugins/php/js/php.js @@ -268,6 +268,30 @@ function setFpmConfig(version){ }); } + +function getFpmStatus(version){ + phpPost('get_fpm_status', version, '', function(ret_data){ + var rdata = $.parseJSON(ret_data.data); + var con = "
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
应用池(pool)" + rdata.pool + "
进程管理方式(process manager)" + ((rdata['process manager'] == 'dynamic') ? '动态' : '静态') + "
启动日期(start time)" + rdata['start time'] + "
请求数(accepted conn)" + rdata['accepted conn'] + "
请求队列(listen queue)" + rdata['listen queue'] + "
最大等待队列(max listen queue)" + rdata['max listen queue'] + "
socket队列长度(listen queue len)" + rdata['listen queue len'] + "
空闲进程数量(idle processes)" + rdata['idle processes'] + "
活跃进程数量(active processes)" + rdata['active processes'] + "
总进程数量(total processes)" + rdata['total processes'] + "
最大活跃进程数量(max active processes)" + rdata['max active processes'] + "
到达进程上限次数(max children reached)" + rdata['max children reached'] + "
慢请求数量(slow requests)" + rdata['slow requests'] + "
"; + $(".soft-man-con").html(con); + $(".GetPHPStatus td,.GetPHPStatus th").css("padding", "7px"); + }); +} + //设置PATHINFO function setPathInfo(version, type) { var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] }); @@ -468,29 +492,6 @@ function GetPHPInfo(version) { } -//查看PHP负载状态 -function GetPHPStatus(version) { - $.post('/ajax?action=GetPHPStatus', 'version=' + version, function(rdata) { - var con = "
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
" + lan.bt.php_pool + "" + rdata.pool + "
" + lan.bt.php_manager + "" + ((rdata['process manager'] == 'dynamic') ? lan.bt.dynamic : lan.bt.static) + "
" + lan.bt.php_start + "" + rdata['start time'] + "
" + lan.bt.php_accepted + "" + rdata['accepted conn'] + "
" + lan.bt.php_queue + "" + rdata['listen queue'] + "
" + lan.bt.php_max_queue + "" + rdata['max listen queue'] + "
" + lan.bt.php_len_queue + "" + rdata['listen queue len'] + "
" + lan.bt.php_idle + "" + rdata['idle processes'] + "
" + lan.bt.php_active + "" + rdata['active processes'] + "
" + lan.bt.php_total + "" + rdata['total processes'] + "
" + lan.bt.php_max_active + "" + rdata['max active processes'] + "
" + lan.bt.php_max_children + "" + rdata['max children reached'] + "
" + lan.bt.php_slow + "" + rdata['slow requests'] + "
"; - $(".soft-man-con").html(con); - $(".GetPHPStatus td,.GetPHPStatus th").css("padding", "7px"); - }) -} - // function GetPHPStatus(a) { // if(a == "52") {