用python脚本获取php-fpm服务的状态和性能
直接上脚本,有需要的拿去自行测试:提示:该页比nginx status多一个实用功能---可以带参数,具体如下:
192.168.130.254/13/status?json
192.168.130.254/13/status?xml
192.168.130.254/13/status?html
192.168.130.254/13/status?full
这里我们通过json参数,来获取相应的数据#coding=utf-8
import urllib,urllib2
import json,sys
def data_result():
try:
data = urllib2.urlopen("http://www.xxxxxx.com/13/status?json").read()
except urllib2.HTTPError as err:
print str(err)
data_ret = json.loads(data)
return data_ret
def accepted_conn():
data = data_result()
return data["accepted conn"]
def listen_queue():
data = data_result()
return data["listen queue"]
def max_listen_queue():
data = data_result()
return data["max listen queue"]
def listen_queue_len():
data = data_result()
return data["listen queue len"]
def idle_processes():
data = data_result()
return data["idle processes"]
def active_processes():
data = data_result()
return data["active processes"]
def total_processes():
data = data_result()
return data["total processes"]
def max_active_processes():
data = data_result()
return data["max active processes"]
def max_children_reached():
data = data_result()
return data["max children reached"]
def slow_requests():
data = data_result()
return data["slow requests"]
if __name__== "__main__":
if sys.argv=="accepted_conn":
print accepted_conn()
if sys.argv=="listen_queue":
print listen_queue()
if sys.argv=="max_listen_queue":
print max_listen_queue()
if sys.argv=="listen_queue_len":
print listen_queue_len()
if sys.argv=="idle_processes":
print idle_processes()
if sys.argv=="active_processes":
print active_processes()
if sys.argv=="total_processes":
print total_processes()
if sys.argv=="max_active_processes":
print max_active_processes()
if sys.argv=="max_children_reached":
print max_children_reached()
if sys.argv=="slow_requests":
print slow_requests()
页:
[1]