#!/bin/bash
#Date：2017-5-20 13:14:00
#Author blog:
#       https://www.yangxingzhen.com
#Author site:
#       https://www.yangxingzhen.com/sitemap.html
#Author mirrors site:
#       https://mirrors.yangxingzhen.com
#About the Author
#       BY：、、、小柒
#       QQ：675583110
#	Mail：675583110@qq.com
#Zabbix监控Nginx性能以及进程状态

HOST='www.yangxingzhen.com'

if [ $# -eq 0 ];then
	echo -e "\033[32m Usage:/bin/bash|sh $0 ping|accepts|handled|requests|active|reading|writing|waiting\033[0m"
	exit 0
fi

function ping {
	/sbin/pidof nginx | wc -l
	}
function accepts {
	curl -s "https://$HOST/nginx_status" | awk NR==3 | awk '{print $1}'
	}
function handled {
	curl -s "https://$HOST/nginx_status" | awk NR==3 | awk '{print $2}'
	}
function requests {
	curl -s "https://$HOST/nginx_status" | awk NR==3 | awk '{print $3}'
	}
function active	{
	curl -s "https://$HOST/nginx_status" | grep Active | awk '{print $NF}'
	}
function reading {
	curl -s "https://$HOST/nginx_status" | grep Reading | awk '{print $2}'
	}
function writing {
	curl -s "https://$HOST/nginx_status" | grep Writing | awk '{print $4}'
	}
function waiting {
	curl -s "https://$HOST/nginx_status" | grep Waiting | awk '{print $6}'
	}
$1
