ivan_sobolevskiy

Untitled

Aug 19th, 2019
934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.03 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. PREFIX='nginx'
  4. URL='http://127.0.0.1/nginx_status'
  5.  
  6. CURL='/usr/bin/curl'
  7. SENDER='/usr/bin/zabbix_sender'
  8. CONFIG='/etc/zabbix/zabbix_agentd.conf'
  9.  
  10. if [ ! -x ${CURL} ]
  11. then echo Seems, path to curl is incorrect or not installed. && exit 0
  12. else if [ ! -x ${SENDER} ]
  13. then echo Seems, path to zabbix_sender is incorrect or not installed. && exit 0
  14. else if [ ! -f ${CONFIG} ]
  15. then echo Seems, path to zabbix_agentd.conf is incorrect && exit 0
  16. fi fi fi
  17.  
  18.  
  19. nginx_status="$(${CURL} --no-keepalive -s -m 5 ${URL} -w 'ping: %{time_total}')"
  20. arr=($nginx_status)
  21.  
  22. if [[ "${arr[7]}" =~ ([0-9]+) ]]
  23. then
  24. echo "\
  25. - ${PREFIX}.accepts ${arr[7]}
  26. - ${PREFIX}.connections.active ${arr[2]}
  27. - ${PREFIX}.connections.reading ${arr[11]}
  28. - ${PREFIX}.connections.waiting ${arr[15]}
  29. - ${PREFIX}.connections.writing ${arr[13]}
  30. - ${PREFIX}.handled ${arr[8]}
  31. - ${PREFIX}.requests ${arr[9]}" | ${SENDER} -c ${CONFIG} -i - > /dev/null 2>&1
  32. echo "${nginx_status}" | awk '/^ping:/ {print $2}' | sed 's/,/./'
  33. else
  34. echo '-0.001'
  35. fi
  36.  
  37. exit 1
Add Comment
Please, Sign In to add comment