server{ server_name 0.0.0.0; listen 12222; access_log off; location /nginx_status { # Turn on nginx stats stub_status on; # I do not need logs for stats access_log off; # Security: Only allow access from 116.229.215.247 #allow 116.229.215.247; allow all; # Send rest of the world to /dev/null #deny all; } }
# # Error handling: # - need to be displayable in Zabbix (avoid NOT_SUPPORTED) # - items need to be of type "float" (allow negative + float) # ERROR_NO_ACCESS_FILE="-0.9900" ERROR_NO_ACCESS="-0.9901" ERROR_WRONG_PARAM="-0.9902" ERROR_DATA="-0.9903" # either can not connect / bad host / bad port
# Handle host and port if non-default if [ ! -z "$ZBX_REQ_DATA_URL" ]; then URL="$ZBX_REQ_DATA_URL" else URL="$NGINX_STATUS_DEFAULT_URL" fi
# save the nginx stats in a variable for future parsing NGINX_STATS=$($WGET_BIN -q $URL -O - 2> /dev/null)
# error during retrieve if [ $? -ne 0 -o -z "$NGINX_STATS" ]; then echo $ERROR_DATA exit 1 fi