pull/109/head
Mr Chen 6 years ago
parent 420d51a1b8
commit 63e272c4c6
  1. 12
      class/core/public.py
  2. 5
      plugins/php/conf/phpfpm_status.conf
  3. 1
      plugins/php/conf/www.conf
  4. 2
      plugins/php/index.html
  5. 11
      plugins/php/index.py
  6. 47
      plugins/php/js/php.js

@ -454,9 +454,7 @@ def isRestart():
def isUpdateLocalSoft(): def isUpdateLocalSoft():
num = M('tasks').where('status!=?', ('1',)).count() num = M('tasks').where('status!=?', ('1',)).count()
if os.path.exists('mdserver-web.zip'): if os.path.exists('mdserver-web.zip'):
return True return True
@ -476,7 +474,7 @@ def hasPwd(password):
return crypt.crypt(password, password) return crypt.crypt(password, password)
def get_timeout(url): def getTimeout(url):
start = time.time() start = time.time()
result = httpGet(url) result = httpGet(url)
if result != 'True': if result != 'True':
@ -557,14 +555,6 @@ def checkToken(get):
return True 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): def checkInput(data):
# 过滤输入 # 过滤输入
if not data: if not data:

@ -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;
}

@ -7,3 +7,4 @@ pm.max_children = 5
pm.start_servers = 2 pm.start_servers = 2
pm.min_spare_servers = 1 pm.min_spare_servers = 1
pm.max_spare_servers = 3 pm.max_spare_servers = 3
pm.status_path = /phpfpm_status_{$PHP_VERSION}

@ -10,7 +10,7 @@
<p onclick="pluginConfig('php', $('.plugin_version').attr('version'));">配置文件</p> <p onclick="pluginConfig('php', $('.plugin_version').attr('version'));">配置文件</p>
<p onclick="redisStatus();">禁用函数</p> <p onclick="redisStatus();">禁用函数</p>
<p onclick="getFpmConfig($('.plugin_version').attr('version'));">性能调整</p> <p onclick="getFpmConfig($('.plugin_version').attr('version'));">性能调整</p>
<p onclick="redisStatus();">负载状况</p> <p onclick="getFpmStatus($('.plugin_version').attr('version'));">负载状况</p>
<p onclick="pluginLogs('php',$('.plugin_version').attr('version'),'fpm_log');">FPM日志</p> <p onclick="pluginLogs('php',$('.plugin_version').attr('version'),'fpm_log');">FPM日志</p>
<p onclick="pluginLogs('php',$('.plugin_version').attr('version'),'fpm_show_log');">慢日志</p> <p onclick="pluginLogs('php',$('.plugin_version').attr('version'),'fpm_show_log');">慢日志</p>
<p onclick="redisStatus();">PHPIFNO</p> <p onclick="redisStatus();">PHPIFNO</p>

@ -399,6 +399,15 @@ def setFpmConfig(version):
return public.returnJson(True, '设置成功') 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 __name__ == "__main__":
if len(sys.argv) < 3: if len(sys.argv) < 3:
@ -438,5 +447,7 @@ if __name__ == "__main__":
print getFpmConfig(version) print getFpmConfig(version)
elif func == 'set_fpm_conf': elif func == 'set_fpm_conf':
print setFpmConfig(version) print setFpmConfig(version)
elif func == 'get_fpm_status':
print getFpmStatus(version)
else: else:
print "fail" print "fail"

@ -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 = "<div style='height:420px;overflow:hidden;'><table class='table table-hover table-bordered GetPHPStatus' style='margin:0;padding:0'>\
<tr><th>应用池(pool)</th><td>" + rdata.pool + "</td></tr>\
<tr><th>进程管理方式(process manager)</th><td>" + ((rdata['process manager'] == 'dynamic') ? '' : '') + "</td></tr>\
<tr><th>启动日期(start time)</th><td>" + rdata['start time'] + "</td></tr>\
<tr><th>请求数(accepted conn)</th><td>" + rdata['accepted conn'] + "</td></tr>\
<tr><th>请求队列(listen queue)</th><td>" + rdata['listen queue'] + "</td></tr>\
<tr><th>最大等待队列(max listen queue)</th><td>" + rdata['max listen queue'] + "</td></tr>\
<tr><th>socket队列长度(listen queue len)</th><td>" + rdata['listen queue len'] + "</td></tr>\
<tr><th>空闲进程数量(idle processes)</th><td>" + rdata['idle processes'] + "</td></tr>\
<tr><th>活跃进程数量(active processes)</th><td>" + rdata['active processes'] + "</td></tr>\
<tr><th>总进程数量(total processes)</th><td>" + rdata['total processes'] + "</td></tr>\
<tr><th>最大活跃进程数量(max active processes)</th><td>" + rdata['max active processes'] + "</td></tr>\
<tr><th>到达进程上限次数(max children reached)</th><td>" + rdata['max children reached'] + "</td></tr>\
<tr><th>慢请求数量(slow requests)</th><td>" + rdata['slow requests'] + "</td></tr>\
</table></div>";
$(".soft-man-con").html(con);
$(".GetPHPStatus td,.GetPHPStatus th").css("padding", "7px");
});
}
//设置PATHINFO //设置PATHINFO
function setPathInfo(version, type) { function setPathInfo(version, type) {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] }); 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 = "<div style='height:420px;overflow:hidden;'><table class='table table-hover table-bordered GetPHPStatus' style='margin:0;padding:0'>\
<tr><th>" + lan.bt.php_pool + "</th><td>" + rdata.pool + "</td></tr>\
<tr><th>" + lan.bt.php_manager + "</th><td>" + ((rdata['process manager'] == 'dynamic') ? lan.bt.dynamic : lan.bt.static) + "</td></tr>\
<tr><th>" + lan.bt.php_start + "</th><td>" + rdata['start time'] + "</td></tr>\
<tr><th>" + lan.bt.php_accepted + "</th><td>" + rdata['accepted conn'] + "</td></tr>\
<tr><th>" + lan.bt.php_queue + "</th><td>" + rdata['listen queue'] + "</td></tr>\
<tr><th>" + lan.bt.php_max_queue + "</th><td>" + rdata['max listen queue'] + "</td></tr>\
<tr><th>" + lan.bt.php_len_queue + "</th><td>" + rdata['listen queue len'] + "</td></tr>\
<tr><th>" + lan.bt.php_idle + "</th><td>" + rdata['idle processes'] + "</td></tr>\
<tr><th>" + lan.bt.php_active + "</th><td>" + rdata['active processes'] + "</td></tr>\
<tr><th>" + lan.bt.php_total + "</th><td>" + rdata['total processes'] + "</td></tr>\
<tr><th>" + lan.bt.php_max_active + "</th><td>" + rdata['max active processes'] + "</td></tr>\
<tr><th>" + lan.bt.php_max_children + "</th><td>" + rdata['max children reached'] + "</td></tr>\
<tr><th>" + lan.bt.php_slow + "</th><td>" + rdata['slow requests'] + "</td></tr>\
</table></div>";
$(".soft-man-con").html(con);
$(".GetPHPStatus td,.GetPHPStatus th").css("padding", "7px");
})
}
// function GetPHPStatus(a) { // function GetPHPStatus(a) {
// if(a == "52") { // if(a == "52") {

Loading…
Cancel
Save