Advertisement
METAJIJI

nginx_status.sh

Sep 19th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.00 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. URL='http://localhost/nginx_status'
  4. TMP='/tmp/nginx-ping.tmp'
  5. ZABBIX_SENDER='/usr/bin/env zabbix_sender'
  6. CONFIG='/etc/zabbix/zabbix_agentd.conf'
  7.  
  8. #
  9. #Active connections: 94
  10. #server accepts handled requests
  11. # 653963 653963 1747934
  12. #Reading: 0 Writing: 19 Waiting: 75
  13.  
  14. (/usr/bin/env time -f %e /usr/bin/env wget --no-http-keep-alive --quiet --timeout 9 -O - $URL) 2>$TMP | \
  15. awk '/Active connections/ {active=int($NF)}
  16.     / ([0-9]+) ([0-9]+) ([0-9]+)/ {accepts=int($1); handled=int($2); requests=int($3)}
  17.     /Reading:/ {reading=int($2); writing=int($4); waiting=int($6)}
  18.     END {
  19.         print "- nginx.connections.active", active;
  20.         print "- nginx.connections.reading", reading;
  21.         print "- nginx.connections.writing", writing;
  22.         print "- nginx.connections.waiting", waiting;
  23.  
  24.         print "- nginx.accepts", accepts;
  25.         print "- nginx.handled", handled;
  26.         print "- nginx.requests", requests;
  27.     }' | $ZABBIX_SENDER \
  28.     --config $CONFIG \
  29.     --input-file - >/dev/null 2>&1
  30.  
  31. cat $TMP
  32. [ -f $TMP ] && rm $TMP
  33. exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement