Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. TIME_SAMPLE=10
  4. MAX_SAMPLES=2
  5.  
  6. STATSD_HOST=localhost
  7. STATSD_PORT=8125
  8.  
  9. STAT_PREFIX=mke.abortion
  10.  
  11. MAX_DEVICES=20
  12.  
  13. if ! which iostat >&/dev/null; then
  14. echo "Cannot find iostat in \$PATH" >&2
  15. exit 1
  16. fi
  17.  
  18. if ! which tac >&/dev/null; then
  19. echo "Cannot find tac in \$PATH" >&2
  20. exit 1
  21. fi
  22.  
  23. iostat -x $TIME_SAMPLE $MAX_SAMPLES | tac | egrep -B${MAX_DEVICES} -m1 ^Device | egrep -v -e ^Device -e '^\s*$' | \
  24. ( while read iostatLine; do \
  25. iodev=$(echo $iostatLine | cut -d' ' -f1)
  26. ( \
  27. echo "${STAT_PREFIX}.iostat.${iodev}.rrqms:$(echo $iostatLine | cut -d' ' -f2)|g" ; \
  28. echo "${STAT_PREFIX}.iostat.${iodev}.wrqms:$(echo $iostatLine | cut -d' ' -f3)|g" ; \
  29. echo "${STAT_PREFIX}.iostat.${iodev}.rs:$(echo $iostatLine | cut -d' ' -f4)|g" ; \
  30. echo "${STAT_PREFIX}.iostat.${iodev}.ws:$(echo $iostatLine | cut -d' ' -f5)|g" ; \
  31. echo "${STAT_PREFIX}.iostat.${iodev}.rKBs:$(echo $iostatLine | cut -d' ' -f6)|g" ; \
  32. echo "${STAT_PREFIX}.iostat.${iodev}.wKBs:$(echo $iostatLine | cut -d' ' -f7)|g" ; \
  33. echo "${STAT_PREFIX}.iostat.${iodev}.avgrq-sz:$(echo $iostatLine | cut -d' ' -f8)|g" ; \
  34. echo "${STAT_PREFIX}.iostat.${iodev}.avgqu-sz:$(echo $iostatLine | cut -d' ' -f9)|g" ; \
  35. echo "${STAT_PREFIX}.iostat.${iodev}.await:$(echo $iostatLine | cut -d' ' -f10)|g" ; \
  36. echo "${STAT_PREFIX}.iostat.${iodev}.r_await:$(echo $iostatLine | cut -d' ' -f11)|g" ; \
  37. echo "${STAT_PREFIX}.iostat.${iodev}.w_await:$(echo $iostatLine | cut -d' ' -f12)|g" ; \
  38. echo "${STAT_PREFIX}.iostat.${iodev}.svctm:$(echo $iostatLine | cut -d' ' -f13)|g" ; \
  39. echo "${STAT_PREFIX}.iostat.${iodev}.percentutil:$(echo $iostatLine | cut -d' ' -f14)|g" \
  40. ) \
  41. done ) | nc -w 1 -u $STATSD_HOST $STATSD_PORT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement