Files
zabbix/nginx/nginx.sh
2016-11-25 10:45:06 +08:00

69 lines
1.5 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
##################################################
# AUTHOR: Neo <netkiller@msn.com>
# WEBSITE: http://www.netkiller.cn
# Descriptionzabbix 通过 status 模块监控 nginx
# NoteZabbix 3.2
# DateTime: 2016-11-22
##################################################
HOST="localhost"
PORT="80"
stub_status=stub_status
function check() {
/sbin/pidof nginx | wc -l
}
function active() {
/usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Active' | awk '{print $NF}'
}
function accepts() {
/usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $1}'
}
function handled() {
/usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $2}'
}
function requests() {
/usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $3}'
}
function reading() {
/usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Reading' | awk '{print $2}'
}
function writing() {
/usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Writing' | awk '{print $4}'
}
function waiting() {
/usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Waiting' | awk '{print $6}'
}
case "$1" in
check)
check
;;
active)
active
;;
accepts)
accepts
;;
handled)
handled
;;
requests)
requests
;;
reading)
reading
;;
writing)
writing
;;
waiting)
waiting
;;
*)
echo $"Usage $0 {check|active|accepts|handled|requests|reading|writing|waiting}"
exit
esac