v_upd_sys_rrd_httpd 2.6 KB

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