Skip to content

Commit 23b28a7

Browse files
committed
RRD graph for Exim
1 parent 2e77a53 commit 23b28a7

File tree

3 files changed

+108
-4
lines changed

3 files changed

+108
-4
lines changed

bin/v-list-sys-rrd

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ json_list_rrd() {
3737
[ "$type" = 'ssh' ]; then
3838
title="$(echo $rrd| tr '[:lower:]' '[:upper:]') Usage"
3939
fi
40+
if [ "$type" = 'mail' ]; then
41+
title="Exim Usage"
42+
fi
4043
if [ "$type" = 'db' ]; then
4144
db_type=$(echo $rrd|cut -f 1 -d _ |sed -e 's/mysql/MySQL/g' \
4245
-e 's/pgsql/PostgreSQL/g' )
@@ -84,14 +87,14 @@ if [ -n "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
8487
rrd_types="$rrd_types web"
8588
fi
8689

90+
if [ -n "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
91+
rrd_types="$rrd_types mail"
92+
fi
93+
8794
if [ -n "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
8895
rrd_types="$rrd_types db"
8996
fi
9097

91-
#if [ -n "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
92-
# rrd_types="$rrd_types mail"
93-
#fi
94-
9598
if [ -n "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
9699
rrd_types="$rrd_types ftp"
97100
fi

bin/v-update-sys-rrd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ for period in $periods; do
110110
$BIN/v-update-sys-rrd-$PROXY_SYSTEM $period >/dev/null 2>&1
111111
fi
112112

113+
# Updating mail stats
114+
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
115+
$BIN/v-update-sys-rrd-mail $period >/dev/null 2>&1
116+
fi
117+
113118
# Updating ftp stats
114119
if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
115120
$BIN/v-update-sys-rrd-ftp $period >/dev/null 2>&1

bin/v-update-sys-rrd-mail

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
# info: update mail rrd
3+
# options: PERIOD
4+
#
5+
# The function is for updating mail rrd database and graphic.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
period=${1-daily}
14+
15+
# Includes
16+
source $VESTA/func/main.sh
17+
source $VESTA/conf/vesta.conf
18+
19+
20+
#----------------------------------------------------------#
21+
# Action #
22+
#----------------------------------------------------------#
23+
24+
# Switching on time period
25+
case $period in
26+
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
27+
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
28+
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
29+
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
30+
*) exit $E_RRD ;;
31+
esac
32+
33+
# Checking directory
34+
if [ ! -d "$RRD/mail" ]; then
35+
mkdir $RRD/mail
36+
fi
37+
38+
# Checking database
39+
if [ ! -e "$RRD/mail/mail.rrd" ]; then
40+
# Adding database
41+
rrdtool create $RRD/mail/mail.rrd --step $RRD_STEP \
42+
DS:A:GAUGE:600:U:U \
43+
RRA:AVERAGE:0.5:1:600 \
44+
RRA:AVERAGE:0.5:6:700 \
45+
RRA:AVERAGE:0.5:24:775 \
46+
RRA:AVERAGE:0.5:288:797 \
47+
RRA:MAX:0.5:1:600 \
48+
RRA:MAX:0.5:6:700 \
49+
RRA:MAX:0.5:24:775 \
50+
RRA:MAX:0.5:288:797
51+
fi
52+
53+
# Parsing data
54+
if [ "$period" = 'daily' ]; then
55+
a=0
56+
a=$(exim -bpc)
57+
58+
# Updating rrd database
59+
rrdtool update $RRD/mail/mail.rrd N:$a
60+
fi
61+
62+
# Updating daily graph
63+
rrdtool graph $RRD/mail/$period-mail.png \
64+
--imgformat PNG \
65+
--height="120" \
66+
--width="440" \
67+
--start "$start" \
68+
--end "$end" \
69+
--vertical-label "Queue Size" \
70+
--x-grid "$grid" \
71+
-c "BACK#7a766d" \
72+
-c "SHADEA#7a766d" \
73+
-c "SHADEB#7a766d" \
74+
-c "FONT#FFFFFF" \
75+
-c "CANVAS#302c2d" \
76+
-c "GRID#666666" \
77+
-c "MGRID#AAAAAA" \
78+
-c "FRAME#302c2d" \
79+
-c "ARROW#FFFFFF" \
80+
DEF:a=$RRD/mail/mail.rrd:A:AVERAGE \
81+
COMMENT:'\r' \
82+
LINE1:a#fefda0:"Emails " \
83+
GPRINT:a:'LAST:Current\:''%8.0lf' \
84+
GPRINT:a:'MIN:Min\:''%8.0lf' \
85+
GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$?
86+
87+
88+
#----------------------------------------------------------#
89+
# Vesta #
90+
#----------------------------------------------------------#
91+
92+
if [ "$result" -ne 0 ]; then
93+
exit $E_RRD
94+
fi
95+
96+
exit

0 commit comments

Comments
 (0)