ivan_sobolevskiy

Untitled

Aug 19th, 2019
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.00 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. PREFIX='php.fpm'
  4. URL='http://127.0.0.1/status-php-fpm'
  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. OUTPUT="$(${CURL} --no-keepalive -s -m 5 ${URL} -w 'ping: %{time_total}')"
  19. echo "${OUTPUT}" | awk -v pr="- ${PREFIX}." '
  20. /^accepted c/ {print pr"accepted_conn "$3}
  21. /^active proc/ {print pr"active_processes "$3}
  22. /^idle proc/ {print pr"idle_processes "$3}
  23. /^listen queue:/ {print pr"listen_queue_len "$3}
  24. /^max children reach/ {print pr"max_children_reached "$4}
  25. /^max listen queue:/ {print pr"max_listen_queue_len "$4}' | ${SENDER} -c ${CONFIG} -i - > /dev/null 2>&1
  26. echo "${OUTPUT}" | awk '/^ping:/ {print $2}' | sed 's/,/./'
  27.  
  28. exit 1
Add Comment
Please, Sign In to add comment