在网上看到很多nginx的调节器,发现大多配置复杂,因为我写了一个自动发现的脚本,热烈欢迎制砖。
nginx_status的实际配置这里很少提及。在这里,假装你已经成功了!
#coding=utf-8 import urllib,urllib2,urllib2 import sys,json url="http://127.0.0.1/nginx_status" li=["ActiveConnections","Reading","Writing","Wss="superseo">ss="superseo">aiting"] js=[] if len(sys.argv) < 2: for stat in li: js = [{'{#NGINXSTATUS}':stat}] print json.dumps({'data':js},sort_keys=True,indent=4,separators=(',',':')) else: arg=sys.argv[1] argm="%s:" % arg request = urllib2.Request(url) response = urllib2.urlopen(request) result=response.readlines() loop=0 dic={} for i in result: loop = 1 if loop == 1: ActiveConnections=int(i.split(":")[1]) dic['ActiveConnections:']=ActiveConnections elif loop == 4: Status=tuple(i.split(" ")) cloop=0 for st in Status: cloop = 1 if cloop == 2 : dic["Reading:"]=st elif cloop == 4: dic["Writing:"]=st elif cloop == 6: dic["Waiting:"]=st print dic[argm]Zabbix_agent自定义密钥配置
则自动发现键值为
nginx.status新项目原型的关键值是
nginx.status[{#NGINXSTATUS}]师傅,不要喷!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)