| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #!/bin/bash
- # info: updating httpd rrd
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument defenition
- rrd_start="${1--1d}"
- rrd_end="${2-now}"
- rrd_grid="${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}"
- # Importing variables
- source $VESTA/conf/vars.conf
- source $V_CONF/vesta.conf
- source $V_FUNC/shared_func.sh
- source $V_FUNC/domain_func.sh
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Checking directory
- if [ ! -d "$V_RRD/web" ]; then
- mkdir $V_RRD/web
- fi
- # Checking database
- if [ ! -e "$V_RRD/web/httpd.rrd" ]; then
- # Adding database
- rrdtool create $V_RRD/web/httpd.rrd --step $V_RRD_STEP \
- DS:A:GAUGE:600:U:U \
- RRA:AVERAGE:0.5:1:600 \
- RRA:AVERAGE:0.5:6:700 \
- RRA:AVERAGE:0.5:24:775 \
- RRA:AVERAGE:0.5:288:797 \
- RRA:MAX:0.5:1:600 \
- RRA:MAX:0.5:6:700 \
- RRA:MAX:0.5:24:775 \
- RRA:MAX:0.5:288:797
- fi
- # Parsing data
- if [ -z "$1" ]; then
- web_port=$(get_config_value '$WEB_PORT')
- server_status=$(wget -qO- http://localhost:$web_port/server-status |\
- grep 'currently being processed'| \
- cut -f 2 -d '>' |\
- sed 's/requests currently being processed, //' | \
- cut -f 1,2 -d ' ')
- active=$(echo "$server_status"|cut -f 1 -d ' ')
- idle=$(echo "$server_status"|cut -f 1 -d ' ')
- a=$((active + idle))
- # Updating rrd database
- rrdtool update $V_RRD/web/httpd.rrd N:$a
- fi
- # Updating rrd graph
- rrdtool graph $V_RRD/web/httpd.png \
- --imgformat PNG \
- --height="120" \
- --width="440" \
- --start "$rrd_start" \
- --end "$rrd_end" \
- --title "HTTPD Usage" \
- --vertical-label "Connections" \
- --x-grid "$rrd_grid" \
- -c "BACK#484439" \
- -c "SHADEA#484439" \
- -c "SHADEB#484439" \
- -c "FONT#DDDDDD" \
- -c "CANVAS#202020" \
- -c "GRID#666666" \
- -c "MGRID#AAAAAA" \
- -c "FRAME#202020" \
- -c "ARROW#FFFFFF" \
- DEF:a=$V_RRD/web/httpd.rrd:A:AVERAGE \
- COMMENT:'\r' \
- LINE1:a#fefda0:"Connections " \
- GPRINT:a:'LAST:Current\:''%8.0lf' \
- GPRINT:a:'MIN:Min\:''%8.0lf' \
- GPRINT:a:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
- #----------------------------------------------------------#
- # Vesta #
- #----------------------------------------------------------#
- if [ "$result" -ne 0 ]; then
- exit $E_RRD_FAILED
- fi
- exit $OK
|