From 56d042431b346ff9ef3334714f80dc923a47f01e Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 23 Jun 2022 02:49:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9debian=E6=97=A0127.0.0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/openresty/index.py | 18 +++++++++++++++++- plugins/php/index.py | 14 ++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/plugins/openresty/index.py b/plugins/openresty/index.py index 8875bb4e7..3fd4fc2af 100755 --- a/plugins/openresty/index.py +++ b/plugins/openresty/index.py @@ -265,9 +265,12 @@ def initdUinstall(): def runInfo(): + # 取Openresty负载状态 + try: - result = mw.httpGet('http://127.0.0.1/nginx_status') + url = 'http://' + mw.GetLocalIp() + '/nginx_status' + result = mw.httpGet(url) tmp = result.split() data = {} data['active'] = tmp[2] @@ -279,6 +282,19 @@ def runInfo(): data['Waiting'] = tmp[15] return mw.getJson(data) except Exception as e: + url = 'http://127.0.0.1/nginx_status' + result = mw.httpGet(url) + 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 mw.getJson(data) + else return 'oprenresty not started' diff --git a/plugins/php/index.py b/plugins/php/index.py index d23cfdff6..9bc5f19b2 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -534,8 +534,18 @@ def checkFpmStatusFile(version): def getFpmStatus(version): checkFpmStatusFile(version) - result = mw.httpGet( - 'http://127.0.0.1/phpfpm_status_' + version + '?json') + + try: + url = 'http://' + mw.getLocalIp() + '/phpfpm_status_' + version + '?json' + result = mw.httpGet(url) + except Exception as e: + url = 'http://127.0.0.1/phpfpm_status_' + version + '?json' + result = mw.httpGet(url) + else: + tmp = {} + tmp['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime) + return mw.getJson(tmp) + tmp = json.loads(result) fTime = time.localtime(int(tmp['start time'])) tmp['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime)