Skip to content

Commit 0a0dc0a

Browse files
committed
time period support for rrd
1 parent b76e4ae commit 0a0dc0a

File tree

10 files changed

+167
-104
lines changed

10 files changed

+167
-104
lines changed

bin/v_upd_sys_rrd

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,41 @@ source $V_FUNC/shared.func
1919
PATH="$PATH:$V_BIN"
2020
export PATH
2121

22+
# Argument defenition
23+
period=$1
24+
2225

2326
#----------------------------------------------------------#
2427
# Action #
2528
#----------------------------------------------------------#
2629

2730
# Updateing system stats
28-
$V_BIN/v_upd_sys_rrd_la
29-
$V_BIN/v_upd_sys_rrd_net
30-
$V_BIN/v_upd_sys_rrd_mem
31-
$V_BIN/v_upd_sys_rrd_ssh
31+
$V_BIN/v_upd_sys_rrd_la $period
32+
$V_BIN/v_upd_sys_rrd_net $period
33+
$V_BIN/v_upd_sys_rrd_mem $period
34+
$V_BIN/v_upd_sys_rrd_ssh $period
3235

3336
# Updating web stats
3437
if [ "$WEB_SYSTEM" = 'apache' ]; then
35-
$V_BIN/v_upd_sys_rrd_httpd
38+
$V_BIN/v_upd_sys_rrd_httpd $period
3639
fi
3740

3841
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
39-
$V_BIN/v_upd_sys_rrd_nginx
42+
$V_BIN/v_upd_sys_rrd_nginx $period
4043
fi
4144

4245
# Updating ftp stats
4346
if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
44-
$V_BIN/v_upd_sys_rrd_ftp
47+
$V_BIN/v_upd_sys_rrd_ftp $period
4548
fi
4649

4750
# Updating db stats
4851
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
4952
for type in ${DB_SYSTEM//,/ }; do
5053
# Switching on db type
5154
case $type in
52-
mysql) $V_BIN/v_upd_sys_rrd_mysql ;;
53-
pgsql) $V_BIN/v_upd_sys_rrd_pgsql ;;
55+
mysql) $V_BIN/v_upd_sys_rrd_mysql $period ;;
56+
pgsql) $V_BIN/v_upd_sys_rrd_pgsql $period ;;
5457
esac
5558
done
5659
fi

bin/v_upd_sys_rrd_ftp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
#----------------------------------------------------------#
77

88
# Argument defenition
9-
rrd_start=${1--1d}
10-
rrd_end=${2-now}
11-
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
9+
update=$1
10+
period=${1-daily}
1211

1312
# Importing variables
1413
source $VESTA/conf/vars.conf
@@ -19,6 +18,15 @@ source $V_CONF/vesta.conf
1918
# Action #
2019
#----------------------------------------------------------#
2120

21+
# Switching on time period
22+
case $period in
23+
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
24+
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
25+
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
26+
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
27+
*) exit $E_RRD_FAILED ;;
28+
esac
29+
2230
# Checking directory
2331
if [ ! -d "$V_RRD/ftp" ]; then
2432
mkdir $V_RRD/ftp
@@ -40,7 +48,7 @@ if [ ! -e "$V_RRD/ftp/ftp.rrd" ]; then
4048
fi
4149

4250
# Parsing data
43-
if [ -z "$1" ]; then
51+
if [ -z "$update" ]; then
4452
a=0
4553
a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\
4654
grep -v root|wc -l)
@@ -50,15 +58,15 @@ if [ -z "$1" ]; then
5058
fi
5159

5260
# Updating rrd graph
53-
rrdtool graph $V_RRD/ftp/ftp.png \
61+
rrdtool graph $V_RRD/ftp/$period-ftp.png \
5462
--imgformat PNG \
5563
--height="120" \
5664
--width="440" \
57-
--start "$rrd_start" \
58-
--end "$rrd_end" \
59-
--title "$(echo $FTP_SYSTEM|tr '[a-z]' '[A-Z]') Usage" \
65+
--start "$start" \
66+
--end "$end" \
67+
--title "$(echo $FTP_SYSTEM|tr '[a-z]' '[A-Z]') Usage ($period)" \
6068
--vertical-label "Connections" \
61-
--x-grid "$rrd_grid" \
69+
--x-grid "$grid" \
6270
-c "BACK#484439" \
6371
-c "SHADEA#484439" \
6472
-c "SHADEB#484439" \

bin/v_upd_sys_rrd_httpd

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@
66
#----------------------------------------------------------#
77

88
# Argument defenition
9-
rrd_start=${1--1d}
10-
rrd_end=${2-now}
11-
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
9+
update=$1
10+
period=${1-daily}
1211

1312
# Importing variables
1413
source $VESTA/conf/vars.conf
15-
source $V_CONF/vesta.conf
16-
source $V_FUNC/shared.func
17-
source $V_FUNC/domain.func
1814

1915

2016
#----------------------------------------------------------#
2117
# Action #
2218
#----------------------------------------------------------#
2319

20+
# Switching on time period
21+
case $period in
22+
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
23+
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
24+
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
25+
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
26+
*) exit $E_RRD_FAILED ;;
27+
esac
28+
29+
2430
# Checking directory
2531
if [ ! -d "$V_RRD/web" ]; then
2632
mkdir $V_RRD/web
@@ -42,9 +48,8 @@ if [ ! -e "$V_RRD/web/httpd.rrd" ]; then
4248
fi
4349

4450
# Parsing data
45-
if [ -z "$1" ]; then
46-
web_port=$(get_config_value '$WEB_PORT')
47-
server_status=$(wget -qO- http://localhost:$web_port/server-status |\
51+
if [ -z "$update" ]; then
52+
server_status=$(wget -qO- http://localhost:$WEB_PORT/server-status |\
4853
grep 'currently being processed'| \
4954
cut -f 2 -d '>' |\
5055
sed 's/requests currently being processed, //' | \
@@ -58,15 +63,15 @@ if [ -z "$1" ]; then
5863
fi
5964

6065
# Updating rrd graph
61-
rrdtool graph $V_RRD/web/httpd.png \
66+
rrdtool graph $V_RRD/web/$period-httpd.png \
6267
--imgformat PNG \
6368
--height="120" \
6469
--width="440" \
65-
--start "$rrd_start" \
66-
--end "$rrd_end" \
67-
--title "HTTPD Usage" \
70+
--start "$start" \
71+
--end "$end" \
72+
--title "HTTPD Usage ($period)" \
6873
--vertical-label "Connections" \
69-
--x-grid "$rrd_grid" \
74+
--x-grid "$grid" \
7075
-c "BACK#484439" \
7176
-c "SHADEA#484439" \
7277
-c "SHADEB#484439" \

bin/v_upd_sys_rrd_la

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,26 @@
66
#----------------------------------------------------------#
77

88
# Argument defenition
9-
rrd_start=${1--1d}
10-
rrd_end=${2-now}
11-
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
9+
update=$1
10+
period=${1-daily}
1211

1312
# Importing variables
1413
source $VESTA/conf/vars.conf
15-
source $V_CONF/vesta.conf
1614

1715

1816
#----------------------------------------------------------#
1917
# Action #
2018
#----------------------------------------------------------#
2119

20+
# Switching on time period
21+
case $period in
22+
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
23+
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
24+
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
25+
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
26+
*) exit $E_RRD_FAILED ;;
27+
esac
28+
2229
# Checking directory
2330
if [ ! -d "$V_RRD/la" ]; then
2431
mkdir $V_RRD/la
@@ -41,7 +48,7 @@ if [ ! -e "$V_RRD/la/la.rrd" ]; then
4148
fi
4249

4350
# Parsing data
44-
if [ -z "$1" ]; then
51+
if [ -z "$update" ]; then
4552
loadavg=$(cat /proc/loadavg )
4653
la=$(echo "$loadavg"|cut -f 2 -d ' ')
4754
pr=$(echo "$loadavg"|cut -f 4 -d ' '|cut -f 2 -d /)
@@ -51,15 +58,15 @@ if [ -z "$1" ]; then
5158
fi
5259

5360
# Updating graph
54-
rrdtool graph $V_RRD/la/la.png \
61+
rrdtool graph $V_RRD/la/$period-la.png \
5562
--imgformat PNG \
5663
--height="120" \
5764
--width="440" \
58-
--start "$rrd_start" \
59-
--end "$rrd_end" \
60-
--title "Load Average" \
65+
--start "$start" \
66+
--end "$end" \
67+
--title "Load Average ($period)" \
6168
--vertical-label "Points" \
62-
--x-grid "$rrd_grid" \
69+
--x-grid "$grid" \
6370
-c "BACK#484439" \
6471
-c "SHADEA#484439" \
6572
-c "SHADEB#484439" \

bin/v_upd_sys_rrd_mem

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,26 @@
66
#----------------------------------------------------------#
77

88
# Argument defenition
9-
rrd_start=${1--1d}
10-
rrd_end=${2-now}
11-
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
9+
update=$1
10+
period=${1-daily}
1211

1312
# Importing variables
1413
source $VESTA/conf/vars.conf
15-
source $V_CONF/vesta.conf
1614

1715

1816
#----------------------------------------------------------#
1917
# Action #
2018
#----------------------------------------------------------#
2119

20+
# Switching on time period
21+
case $period in
22+
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
23+
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
24+
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
25+
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
26+
*) exit $E_RRD_FAILED ;;
27+
esac
28+
2229
# Checking directory
2330
if [ ! -d "$V_RRD/mem" ]; then
2431
mkdir $V_RRD/mem
@@ -41,7 +48,7 @@ if [ ! -e "$V_RRD/mem/mem.rrd" ]; then
4148
fi
4249

4350
# Parsing data
44-
if [ -z "$1" ]; then
51+
if [ -z "$update" ]; then
4552
mem=$(free -m)
4653
ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1)
4754
swap=$(echo "$mem" |awk '{print $3}'|tail -n1)
@@ -51,15 +58,15 @@ if [ -z "$1" ]; then
5158
fi
5259

5360
# Updating rrd graph
54-
rrdtool graph $V_RRD/mem/mem.png \
61+
rrdtool graph $V_RRD/mem/$period-mem.png \
5562
--imgformat PNG \
5663
--height="120" \
5764
--width="440" \
58-
--start "$rrd_start" \
59-
--end "$rrd_end" \
60-
--title "Memory Usage" \
65+
--start "$start" \
66+
--end "$end" \
67+
--title "Memory Usage ($period)" \
6168
--vertical-label "Mbytes" \
62-
--x-grid "$rrd_grid" \
69+
--x-grid "$grid" \
6370
-c "BACK#484439" \
6471
-c "SHADEA#484439" \
6572
-c "SHADEB#484439" \

bin/v_upd_sys_rrd_mysql

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@
66
#----------------------------------------------------------#
77

88
# Argument defenition
9-
rrd_start=${1--1d}
10-
rrd_end=${2-now}
11-
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
9+
update=$1
10+
period=${1-daily}
1211

1312
# Importing variables
1413
source $VESTA/conf/vars.conf
15-
source $V_CONF/vesta.conf
1614
source $V_FUNC/shared.func
17-
source $V_FUNC/db.func
1815

1916

2017
#----------------------------------------------------------#
2118
# Action #
2219
#----------------------------------------------------------#
2320

21+
# Switching on time period
22+
case $period in
23+
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
24+
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
25+
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
26+
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
27+
*) exit $E_RRD_FAILED ;;
28+
esac
29+
2430
# Checking directory
2531
if [ ! -d "$V_RRD/db" ]; then
2632
mkdir $V_RRD/db
@@ -58,7 +64,7 @@ for host in $hosts; do
5864
RRA:MAX:0.5:288:797
5965
fi
6066

61-
if [ -z "$1" ]; then
67+
if [ -z "$update" ]; then
6268
# Defining host credentials
6369
host_str=$(grep "HOST='$host'" $conf)
6470
for key in $host_str; do
@@ -89,15 +95,15 @@ for host in $hosts; do
8995
fi
9096

9197
# Updating daily graph
92-
rrdtool graph $V_RRD/db/mysql_$host.png \
98+
rrdtool graph $V_RRD/db/$period-mysql_$host.png \
9399
--imgformat PNG \
94100
--height="120" \
95101
--width="440" \
96-
--start "$rrd_start" \
97-
--end "$rrd_end" \
98-
--title "MySQL Usage on $host" \
102+
--start "$start" \
103+
--end "$end" \
104+
--title "MySQL Usage on $host ($period)" \
99105
--vertical-label "Queries" \
100-
--x-grid "$rrd_grid" \
106+
--x-grid "$grid" \
101107
-c "BACK#484439" \
102108
-c "SHADEA#484439" \
103109
-c "SHADEB#484439" \

0 commit comments

Comments
 (0)