time period support for rrd

This commit is contained in:
Serghey Rodin 2011-12-15 00:19:04 +02:00
commit 0a0dc0a638
10 changed files with 167 additions and 104 deletions

View file

@ -19,29 +19,32 @@ source $V_FUNC/shared.func
PATH="$PATH:$V_BIN" PATH="$PATH:$V_BIN"
export PATH export PATH
# Argument defenition
period=$1
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Updateing system stats # Updateing system stats
$V_BIN/v_upd_sys_rrd_la $V_BIN/v_upd_sys_rrd_la $period
$V_BIN/v_upd_sys_rrd_net $V_BIN/v_upd_sys_rrd_net $period
$V_BIN/v_upd_sys_rrd_mem $V_BIN/v_upd_sys_rrd_mem $period
$V_BIN/v_upd_sys_rrd_ssh $V_BIN/v_upd_sys_rrd_ssh $period
# Updating web stats # Updating web stats
if [ "$WEB_SYSTEM" = 'apache' ]; then if [ "$WEB_SYSTEM" = 'apache' ]; then
$V_BIN/v_upd_sys_rrd_httpd $V_BIN/v_upd_sys_rrd_httpd $period
fi fi
if [ "$PROXY_SYSTEM" = 'nginx' ]; then if [ "$PROXY_SYSTEM" = 'nginx' ]; then
$V_BIN/v_upd_sys_rrd_nginx $V_BIN/v_upd_sys_rrd_nginx $period
fi fi
# Updating ftp stats # Updating ftp stats
if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
$V_BIN/v_upd_sys_rrd_ftp $V_BIN/v_upd_sys_rrd_ftp $period
fi fi
# Updating db stats # Updating db stats
@ -49,8 +52,8 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
for type in ${DB_SYSTEM//,/ }; do for type in ${DB_SYSTEM//,/ }; do
# Switching on db type # Switching on db type
case $type in case $type in
mysql) $V_BIN/v_upd_sys_rrd_mysql ;; mysql) $V_BIN/v_upd_sys_rrd_mysql $period ;;
pgsql) $V_BIN/v_upd_sys_rrd_pgsql ;; pgsql) $V_BIN/v_upd_sys_rrd_pgsql $period ;;
esac esac
done done
fi fi

View file

@ -6,9 +6,8 @@
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
rrd_start=${1--1d} update=$1
rrd_end=${2-now} period=${1-daily}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
@ -19,6 +18,15 @@ source $V_CONF/vesta.conf
# Action # # 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_FAILED ;;
esac
# Checking directory # Checking directory
if [ ! -d "$V_RRD/ftp" ]; then if [ ! -d "$V_RRD/ftp" ]; then
mkdir $V_RRD/ftp mkdir $V_RRD/ftp
@ -40,7 +48,7 @@ if [ ! -e "$V_RRD/ftp/ftp.rrd" ]; then
fi fi
# Parsing data # Parsing data
if [ -z "$1" ]; then if [ -z "$update" ]; then
a=0 a=0
a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\ a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\
grep -v root|wc -l) grep -v root|wc -l)
@ -50,15 +58,15 @@ if [ -z "$1" ]; then
fi fi
# Updating rrd graph # Updating rrd graph
rrdtool graph $V_RRD/ftp/ftp.png \ rrdtool graph $V_RRD/ftp/$period-ftp.png \
--imgformat PNG \ --imgformat PNG \
--height="120" \ --height="120" \
--width="440" \ --width="440" \
--start "$rrd_start" \ --start "$start" \
--end "$rrd_end" \ --end "$end" \
--title "$(echo $FTP_SYSTEM|tr '[a-z]' '[A-Z]') Usage" \ --title "$(echo $FTP_SYSTEM|tr '[a-z]' '[A-Z]') Usage ($period)" \
--vertical-label "Connections" \ --vertical-label "Connections" \
--x-grid "$rrd_grid" \ --x-grid "$grid" \
-c "BACK#484439" \ -c "BACK#484439" \
-c "SHADEA#484439" \ -c "SHADEA#484439" \
-c "SHADEB#484439" \ -c "SHADEB#484439" \

View file

@ -6,21 +6,27 @@
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
rrd_start=${1--1d} update=$1
rrd_end=${2-now} period=${1-daily}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # 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_FAILED ;;
esac
# Checking directory # Checking directory
if [ ! -d "$V_RRD/web" ]; then if [ ! -d "$V_RRD/web" ]; then
mkdir $V_RRD/web mkdir $V_RRD/web
@ -42,9 +48,8 @@ if [ ! -e "$V_RRD/web/httpd.rrd" ]; then
fi fi
# Parsing data # Parsing data
if [ -z "$1" ]; then if [ -z "$update" ]; then
web_port=$(get_config_value '$WEB_PORT') server_status=$(wget -qO- http://localhost:$WEB_PORT/server-status |\
server_status=$(wget -qO- http://localhost:$web_port/server-status |\
grep 'currently being processed'| \ grep 'currently being processed'| \
cut -f 2 -d '>' |\ cut -f 2 -d '>' |\
sed 's/requests currently being processed, //' | \ sed 's/requests currently being processed, //' | \
@ -58,15 +63,15 @@ if [ -z "$1" ]; then
fi fi
# Updating rrd graph # Updating rrd graph
rrdtool graph $V_RRD/web/httpd.png \ rrdtool graph $V_RRD/web/$period-httpd.png \
--imgformat PNG \ --imgformat PNG \
--height="120" \ --height="120" \
--width="440" \ --width="440" \
--start "$rrd_start" \ --start "$start" \
--end "$rrd_end" \ --end "$end" \
--title "HTTPD Usage" \ --title "HTTPD Usage ($period)" \
--vertical-label "Connections" \ --vertical-label "Connections" \
--x-grid "$rrd_grid" \ --x-grid "$grid" \
-c "BACK#484439" \ -c "BACK#484439" \
-c "SHADEA#484439" \ -c "SHADEA#484439" \
-c "SHADEB#484439" \ -c "SHADEB#484439" \

View file

@ -6,19 +6,26 @@
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
rrd_start=${1--1d} update=$1
rrd_end=${2-now} period=${1-daily}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # 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_FAILED ;;
esac
# Checking directory # Checking directory
if [ ! -d "$V_RRD/la" ]; then if [ ! -d "$V_RRD/la" ]; then
mkdir $V_RRD/la mkdir $V_RRD/la
@ -41,7 +48,7 @@ if [ ! -e "$V_RRD/la/la.rrd" ]; then
fi fi
# Parsing data # Parsing data
if [ -z "$1" ]; then if [ -z "$update" ]; then
loadavg=$(cat /proc/loadavg ) loadavg=$(cat /proc/loadavg )
la=$(echo "$loadavg"|cut -f 2 -d ' ') la=$(echo "$loadavg"|cut -f 2 -d ' ')
pr=$(echo "$loadavg"|cut -f 4 -d ' '|cut -f 2 -d /) pr=$(echo "$loadavg"|cut -f 4 -d ' '|cut -f 2 -d /)
@ -51,15 +58,15 @@ if [ -z "$1" ]; then
fi fi
# Updating graph # Updating graph
rrdtool graph $V_RRD/la/la.png \ rrdtool graph $V_RRD/la/$period-la.png \
--imgformat PNG \ --imgformat PNG \
--height="120" \ --height="120" \
--width="440" \ --width="440" \
--start "$rrd_start" \ --start "$start" \
--end "$rrd_end" \ --end "$end" \
--title "Load Average" \ --title "Load Average ($period)" \
--vertical-label "Points" \ --vertical-label "Points" \
--x-grid "$rrd_grid" \ --x-grid "$grid" \
-c "BACK#484439" \ -c "BACK#484439" \
-c "SHADEA#484439" \ -c "SHADEA#484439" \
-c "SHADEB#484439" \ -c "SHADEB#484439" \

View file

@ -6,19 +6,26 @@
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
rrd_start=${1--1d} update=$1
rrd_end=${2-now} period=${1-daily}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # 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_FAILED ;;
esac
# Checking directory # Checking directory
if [ ! -d "$V_RRD/mem" ]; then if [ ! -d "$V_RRD/mem" ]; then
mkdir $V_RRD/mem mkdir $V_RRD/mem
@ -41,7 +48,7 @@ if [ ! -e "$V_RRD/mem/mem.rrd" ]; then
fi fi
# Parsing data # Parsing data
if [ -z "$1" ]; then if [ -z "$update" ]; then
mem=$(free -m) mem=$(free -m)
ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1) ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1)
swap=$(echo "$mem" |awk '{print $3}'|tail -n1) swap=$(echo "$mem" |awk '{print $3}'|tail -n1)
@ -51,15 +58,15 @@ if [ -z "$1" ]; then
fi fi
# Updating rrd graph # Updating rrd graph
rrdtool graph $V_RRD/mem/mem.png \ rrdtool graph $V_RRD/mem/$period-mem.png \
--imgformat PNG \ --imgformat PNG \
--height="120" \ --height="120" \
--width="440" \ --width="440" \
--start "$rrd_start" \ --start "$start" \
--end "$rrd_end" \ --end "$end" \
--title "Memory Usage" \ --title "Memory Usage ($period)" \
--vertical-label "Mbytes" \ --vertical-label "Mbytes" \
--x-grid "$rrd_grid" \ --x-grid "$grid" \
-c "BACK#484439" \ -c "BACK#484439" \
-c "SHADEA#484439" \ -c "SHADEA#484439" \
-c "SHADEB#484439" \ -c "SHADEB#484439" \

View file

@ -6,21 +6,27 @@
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
rrd_start=${1--1d} update=$1
rrd_end=${2-now} period=${1-daily}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/db.func
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # 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_FAILED ;;
esac
# Checking directory # Checking directory
if [ ! -d "$V_RRD/db" ]; then if [ ! -d "$V_RRD/db" ]; then
mkdir $V_RRD/db mkdir $V_RRD/db
@ -58,7 +64,7 @@ for host in $hosts; do
RRA:MAX:0.5:288:797 RRA:MAX:0.5:288:797
fi fi
if [ -z "$1" ]; then if [ -z "$update" ]; then
# Defining host credentials # Defining host credentials
host_str=$(grep "HOST='$host'" $conf) host_str=$(grep "HOST='$host'" $conf)
for key in $host_str; do for key in $host_str; do
@ -89,15 +95,15 @@ for host in $hosts; do
fi fi
# Updating daily graph # Updating daily graph
rrdtool graph $V_RRD/db/mysql_$host.png \ rrdtool graph $V_RRD/db/$period-mysql_$host.png \
--imgformat PNG \ --imgformat PNG \
--height="120" \ --height="120" \
--width="440" \ --width="440" \
--start "$rrd_start" \ --start "$start" \
--end "$rrd_end" \ --end "$end" \
--title "MySQL Usage on $host" \ --title "MySQL Usage on $host ($period)" \
--vertical-label "Queries" \ --vertical-label "Queries" \
--x-grid "$rrd_grid" \ --x-grid "$grid" \
-c "BACK#484439" \ -c "BACK#484439" \
-c "SHADEA#484439" \ -c "SHADEA#484439" \
-c "SHADEB#484439" \ -c "SHADEB#484439" \

View file

@ -6,19 +6,26 @@
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
rrd_start=${1--1d} update=$1
rrd_end=${2-now} period=${1-daily}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # 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_FAILED ;;
esac
# Checking directory # Checking directory
if [ ! -d "$V_RRD/net" ]; then if [ ! -d "$V_RRD/net" ]; then
mkdir $V_RRD/net mkdir $V_RRD/net
@ -50,7 +57,7 @@ for iface in $ifaces; do
fi fi
# Parsing device stats # Parsing device stats
if [ -z "$1" ]; then if [ -z "$update" ]; then
raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /") raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /")
rx=$(echo "$raw_iface" |awk '{print $2}') rx=$(echo "$raw_iface" |awk '{print $2}')
tx=$(echo "$raw_iface" |awk '{print $10}') tx=$(echo "$raw_iface" |awk '{print $10}')
@ -60,15 +67,15 @@ for iface in $ifaces; do
fi fi
# Updating rrd graph # Updating rrd graph
rrdtool graph $V_RRD/net/$iface.png \ rrdtool graph $V_RRD/net/$period-$iface.png \
--imgformat PNG \ --imgformat PNG \
--height="120" \ --height="120" \
--width="440" \ --width="440" \
--start "$rrd_start" \ --start "$start" \
--end "$rrd_end" \ --end "$end" \
--title "Bandwidth Usage $iface" \ --title "Bandwidth Usage $iface ($period)" \
--vertical-label "KBytes" \ --vertical-label "KBytes" \
--x-grid "$rrd_grid" \ --x-grid "$grid" \
-c "BACK#484439" \ -c "BACK#484439" \
-c "SHADEA#484439" \ -c "SHADEA#484439" \
-c "SHADEB#484439" \ -c "SHADEB#484439" \

View file

@ -6,19 +6,26 @@
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
rrd_start=${1--1d} update=$1
rrd_end=${2-now} period=${1-daily}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # 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_FAILED ;;
esac
# Checking directory # Checking directory
if [ ! -d "$V_RRD/web" ]; then if [ ! -d "$V_RRD/web" ]; then
mkdir $V_RRD/web mkdir $V_RRD/web
@ -40,7 +47,7 @@ if [ ! -e "$V_RRD/web/nginx.rrd" ]; then
fi fi
# Parsing data # Parsing data
if [ -z "$1" ]; then if [ -z "$update" ]; then
a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ') a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ')
# Updating rrd database # Updating rrd database
@ -48,15 +55,15 @@ if [ -z "$1" ]; then
fi fi
# Updating rrd graph # Updating rrd graph
rrdtool graph $V_RRD/web/nginx.png \ rrdtool graph $V_RRD/web/$period-nginx.png \
--imgformat PNG \ --imgformat PNG \
--height="120" \ --height="120" \
--width="440" \ --width="440" \
--start "$rrd_start" \ --start "$start" \
--end "$rrd_end" \ --end "$end" \
--title "NGINX Usage" \ --title "NGINX Usage ($period)" \
--vertical-label "Connections" \ --vertical-label "Connections" \
--x-grid "$rrd_grid" \ --x-grid "$grid" \
-c "BACK#484439" \ -c "BACK#484439" \
-c "SHADEA#484439" \ -c "SHADEA#484439" \
-c "SHADEB#484439" \ -c "SHADEB#484439" \

View file

@ -6,21 +6,27 @@
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
rrd_start=${1--1d} update=$1
rrd_end=${2-now} period=${1-daily}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/db.func
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # 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_FAILED ;;
esac
# Checking directory # Checking directory
if [ ! -d "$V_RRD/db" ]; then if [ ! -d "$V_RRD/db" ]; then
mkdir $V_RRD/db mkdir $V_RRD/db
@ -58,7 +64,7 @@ for host in $hosts; do
RRA:MAX:0.5:288:797 RRA:MAX:0.5:288:797
fi fi
if [ -z "$1" ]; then if [ -z "$update" ]; then
# Defining host credentials # Defining host credentials
host_str=$(grep "HOST='$host'" $conf) host_str=$(grep "HOST='$host'" $conf)
for key in $host_str; do for key in $host_str; do
@ -95,15 +101,15 @@ for host in $hosts; do
fi fi
# Updating rrd graph # Updating rrd graph
rrdtool graph $V_RRD/db/pgsql_$host.png \ rrdtool graph $V_RRD/db/$period-pgsql_$host.png \
--imgformat PNG \ --imgformat PNG \
--height="120" \ --height="120" \
--width="440" \ --width="440" \
--start "$rrd_start" \ --start "$start" \
--end "$rrd_end" \ --end "$end" \
--title "PostgreSQL Usage on $host" \ --title "PostgreSQL Usage on $host ($period)" \
--vertical-label "Queries" \ --vertical-label "Queries" \
--x-grid "$rrd_grid" \ --x-grid "$grid" \
-c "BACK#484439" \ -c "BACK#484439" \
-c "SHADEA#484439" \ -c "SHADEA#484439" \
-c "SHADEB#484439" \ -c "SHADEB#484439" \

View file

@ -6,19 +6,26 @@
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
rrd_start=${1--1d} update=$1
rrd_end=${2-now} period=${1-daily}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # 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_FAILED ;;
esac
# Checking directory # Checking directory
if [ ! -d "$V_RRD/ssh" ]; then if [ ! -d "$V_RRD/ssh" ]; then
mkdir $V_RRD/ssh mkdir $V_RRD/ssh
@ -40,7 +47,7 @@ if [ ! -e "$V_RRD/ssh/ssh.rrd" ]; then
fi fi
# Parsing data # Parsing data
if [ -z "$1" ]; then if [ -z "$update" ]; then
a=0 a=0
a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l) a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l)
@ -49,15 +56,15 @@ if [ -z "$1" ]; then
fi fi
# Updating daily graph # Updating daily graph
rrdtool graph $V_RRD/ssh/ssh.png \ rrdtool graph $V_RRD/ssh/$period-ssh.png \
--imgformat PNG \ --imgformat PNG \
--height="120" \ --height="120" \
--width="440" \ --width="440" \
--start "$rrd_start" \ --start "$start" \
--end "$rrd_end" \ --end "$end" \
--title "SSH Usage" \ --title "SSH Usage" \
--vertical-label "Connections" \ --vertical-label "Connections ($period)" \
--x-grid "$rrd_grid" \ --x-grid "$grid" \
-c "BACK#484439" \ -c "BACK#484439" \
-c "SHADEA#484439" \ -c "SHADEA#484439" \
-c "SHADEB#484439" \ -c "SHADEB#484439" \