标签:
#!/usr/bin/env python import os import json t=os.popen("""netstat -antp|awk ‘/LISTEN/&&/nginx/{print $4}‘|awk -F: ‘{print $NF}‘ """) ports = [] for port in t.readlines(): r = os.path.basename(port.strip()) ports += [{‘{#NGINXPORT}‘:r}] print json.dumps({‘data‘:ports},sort_keys=True,indent=4,separators=(‘,‘,‘:‘))
2, 状态脚本
#!/bin/bash function active { /usr/bin/curl "http://localhost/stub-status" 2>/dev/null| grep ‘Active‘ | awk ‘{print $NF}‘ } function reading { /usr/bin/curl "http://localhost/stub-status" 2>/dev/null| grep ‘Reading‘ | awk ‘{print $2}‘ } function writing { /usr/bin/curl "http://localhost/stub-status" 2>/dev/null| grep ‘Writing‘ | awk ‘{print $4}‘ } function waiting { /usr/bin/curl "http://localhost/stub-status" 2>/dev/null| grep ‘Waiting‘ | awk ‘{print $6}‘ } function accepts { /usr/bin/curl "http://localhost/stub-status" 2>/dev/null| awk NR==3 | awk ‘{print $1}‘ } function handled { /usr/bin/curl "http://localhost/stub-status" 2>/dev/null| awk NR==3 | awk ‘{print $2}‘ } function requests { /usr/bin/curl "http://localhost/stub-status" 2>/dev/null| awk NR==3 | awk ‘{print $3}‘ } # Run the requested function $1
# nginx UserParameter=nginx[*],/usr/local/zabbix/bin/nginx_status $1 UserParameter=nginx.discovery,/usr/local/zabbix/bin/nginx_port.py
4,
标签:
原文地址:http://www.cnblogs.com/tankt101/p/5551580.html