mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-21 05:44:07 -07:00
debian/ubuntu rrd for apache
This commit is contained in:
parent
2737f52fa1
commit
69cf021fc7
1 changed files with 103 additions and 0 deletions
103
bin/v-update-sys-rrd-apache2
Executable file
103
bin/v-update-sys-rrd-apache2
Executable file
|
@ -0,0 +1,103 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: update apach2 rrd
|
||||||
|
# options: PERIOD
|
||||||
|
#
|
||||||
|
# The function is for updating apache rrd database and graphic.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
period=${1-daily}
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Switching on time period
|
||||||
|
case $period in
|
||||||
|
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
|
||||||
|
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
|
||||||
|
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
|
||||||
|
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
|
||||||
|
*) exit $E_RRD ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
# Checking directory
|
||||||
|
if [ ! -d "$RRD/web" ]; then
|
||||||
|
mkdir $RRD/web
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checking database
|
||||||
|
if [ ! -e "$RRD/web/apache2.rrd" ]; then
|
||||||
|
# Adding database
|
||||||
|
rrdtool create $RRD/web/apache2.rrd --step $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 [ "$period" = 'daily' ]; then
|
||||||
|
server_status=$(wget -qO- http://localhost:8081/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 $RRD/web/apache2.rrd N:$a
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Updating rrd graph
|
||||||
|
rrdtool graph $RRD/web/$period-apache2.png \
|
||||||
|
--imgformat PNG \
|
||||||
|
--height="120" \
|
||||||
|
--width="440" \
|
||||||
|
--start "$start" \
|
||||||
|
--end "$end" \
|
||||||
|
--vertical-label "Connections" \
|
||||||
|
--x-grid "$grid" \
|
||||||
|
-c "BACK#7a766d" \
|
||||||
|
-c "SHADEA#7a766d" \
|
||||||
|
-c "SHADEB#7a766d" \
|
||||||
|
-c "FONT#FFFFFF" \
|
||||||
|
-c "CANVAS#302c2d" \
|
||||||
|
-c "GRID#666666" \
|
||||||
|
-c "MGRID#AAAAAA" \
|
||||||
|
-c "FRAME#302c2d" \
|
||||||
|
-c "ARROW#FFFFFF" \
|
||||||
|
DEF:a=$RRD/web/apache2.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; result=$?
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [ "$result" -ne 0 ]; then
|
||||||
|
exit $E_RRD
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit
|
Loading…
Add table
Add a link
Reference in a new issue