v_upd_sys_rrd_httpd 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/bash
  2. # info: updating httpd rrd
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. rrd_start=${1--1d}
  8. rrd_end=${2-now}
  9. rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
  10. # Importing variables
  11. source $VESTA/conf/vars.conf
  12. source $V_CONF/vesta.conf
  13. source $V_CONF/vesta.conf
  14. source $V_FUNC/shared.func
  15. source $V_FUNC/domain.func
  16. #----------------------------------------------------------#
  17. # Action #
  18. #----------------------------------------------------------#
  19. # Checking directory
  20. if [ ! -d "$V_RRD/web" ]; then
  21. mkdir $V_RRD/web
  22. fi
  23. # Checking database
  24. if [ ! -e "$V_RRD/web/httpd.rrd" ]; then
  25. # Adding database
  26. rrdtool create $V_RRD/web/httpd.rrd --step $V_RRD_STEP \
  27. DS:A:GAUGE:600:U:U \
  28. RRA:AVERAGE:0.5:1:600 \
  29. RRA:AVERAGE:0.5:6:700 \
  30. RRA:AVERAGE:0.5:24:775 \
  31. RRA:AVERAGE:0.5:288:797 \
  32. RRA:MAX:0.5:1:600 \
  33. RRA:MAX:0.5:6:700 \
  34. RRA:MAX:0.5:24:775 \
  35. RRA:MAX:0.5:288:797
  36. fi
  37. # Parsing data
  38. if [ -z "$1" ]; then
  39. web_port=$(get_config_value '$WEB_PORT')
  40. server_status=$(wget -qO- http://localhost:$web_port/server-status |\
  41. grep 'currently being processed'| \
  42. cut -f 2 -d '>' |\
  43. sed 's/requests currently being processed, //' | \
  44. cut -f 1,2 -d ' ')
  45. active=$(echo "$server_status"|cut -f 1 -d ' ')
  46. idle=$(echo "$server_status"|cut -f 1 -d ' ')
  47. a=$((active + idle))
  48. # Updating rrd database
  49. rrdtool update $V_RRD/web/httpd.rrd N:$a
  50. fi
  51. # Updating rrd graph
  52. rrdtool graph $V_RRD/web/httpd.png \
  53. --imgformat PNG \
  54. --height="120" \
  55. --width="440" \
  56. --start "$rrd_start" \
  57. --end "$rrd_end" \
  58. --title "HTTPD Usage" \
  59. --vertical-label "Connections" \
  60. --x-grid "$rrd_grid" \
  61. -c "BACK#484439" \
  62. -c "SHADEA#484439" \
  63. -c "SHADEB#484439" \
  64. -c "FONT#DDDDDD" \
  65. -c "CANVAS#202020" \
  66. -c "GRID#666666" \
  67. -c "MGRID#AAAAAA" \
  68. -c "FRAME#202020" \
  69. -c "ARROW#FFFFFF" \
  70. DEF:a=$V_RRD/web/httpd.rrd:A:AVERAGE \
  71. COMMENT:'\r' \
  72. LINE1:a#fefda0:"Connections " \
  73. GPRINT:a:'LAST:Current\:''%8.0lf' \
  74. GPRINT:a:'MIN:Min\:''%8.0lf' \
  75. GPRINT:a:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
  76. #----------------------------------------------------------#
  77. # Vesta #
  78. #----------------------------------------------------------#
  79. if [ "$result" -ne 0 ]; then
  80. exit $E_RRD_FAILED
  81. fi
  82. exit