Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- PREFIX='nginx'
- URL='http://127.0.0.1/nginx_status'
- CURL='/usr/bin/curl'
- SENDER='/usr/bin/zabbix_sender'
- CONFIG='/etc/zabbix/zabbix_agentd.conf'
- if [ ! -x ${CURL} ]
- then echo Seems, path to curl is incorrect or not installed. && exit 0
- else if [ ! -x ${SENDER} ]
- then echo Seems, path to zabbix_sender is incorrect or not installed. && exit 0
- else if [ ! -f ${CONFIG} ]
- then echo Seems, path to zabbix_agentd.conf is incorrect && exit 0
- fi fi fi
- nginx_status="$(${CURL} --no-keepalive -s -m 5 ${URL} -w 'ping: %{time_total}')"
- arr=($nginx_status)
- if [[ "${arr[7]}" =~ ([0-9]+) ]]
- then
- echo "\
- - ${PREFIX}.accepts ${arr[7]}
- - ${PREFIX}.connections.active ${arr[2]}
- - ${PREFIX}.connections.reading ${arr[11]}
- - ${PREFIX}.connections.waiting ${arr[15]}
- - ${PREFIX}.connections.writing ${arr[13]}
- - ${PREFIX}.handled ${arr[8]}
- - ${PREFIX}.requests ${arr[9]}" | ${SENDER} -c ${CONFIG} -i - > /dev/null 2>&1
- echo "${nginx_status}" | awk '/^ping:/ {print $2}' | sed 's/,/./'
- else
- echo '-0.001'
- fi
- exit 1
Add Comment
Please, Sign In to add comment