RRD custom time interval support

This commit is contained in:
Serghey Rodin 2011-10-18 12:51:59 +03:00
commit e48992ccfc
10 changed files with 301 additions and 156 deletions

66
bin/v_upd_sys_rrd Executable file
View file

@ -0,0 +1,66 @@
#!/bin/bash
# info: updating system rrd charts
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Importing system enviroment as we run this script
# mostly by cron wich do not read it by itself
source /etc/profile.d/vesta.sh
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared_func.sh
# Another workaround for cron enviroment
PATH="$PATH:$V_BIN"
export PATH
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Updateing system stats
$V_BIN/v_upd_sys_rrd_la
$V_BIN/v_upd_sys_rrd_net
$V_BIN/v_upd_sys_rrd_mem
$V_BIN/v_upd_sys_rrd_ssh
# Updating web stats
if [ "$WEB_SYSTEM" = 'apache' ]; then
$V_BIN/v_upd_sys_rrd_httpd
fi
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
$V_BIN/v_upd_sys_rrd_nginx
fi
# Updating ftp stats
if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
$V_BIN/v_upd_sys_rrd_ftp
fi
# Updating db stats
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
for type in ${DB_SYSTEM//,/ }; do
# Switching on db type
case $type in
mysql) $V_BIN/v_upd_sys_rrd_mysql ;;
pgsql) $V_BIN/v_upd_sys_rrd_pgsql ;;
esac
done
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit $OK

View file

@ -5,6 +5,11 @@
# 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
@ -35,22 +40,25 @@ if [ ! -e "$V_RRD/ftp/ftp.rrd" ]; then
fi
# Parsing data
a=0
a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody| grep -v root|wc -l)
if [ -z "$1" ]; then
a=0
a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\
grep -v root|wc -l)
# Updating rrd database
rrdtool update $V_RRD/ftp/ftp.rrd N:$a
# Updating rrd database
rrdtool update $V_RRD/ftp/ftp.rrd N:$a
fi
# Updating daily graph
# Updating rrd graph
rrdtool graph $V_RRD/ftp/ftp.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start -1d \
--end now \
--start "$rrd_start" \
--end "$rrd_end" \
--title "$(echo $FTP_SYSTEM|tr '[a-z]' '[A-Z]') Usage" \
--vertical-label "Connections" \
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
--x-grid "$rrd_grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -65,14 +73,15 @@ rrdtool graph $V_RRD/ftp/ftp.png \
LINE1:a#fefda0:"Users " \
GPRINT:a:'LAST:Current\:''%8.0lf' \
GPRINT:a:'MIN:Min\:''%8.0lf' \
GPRINT:a:'MAX:Max\:''%8.0lf\j' > /dev/null
GPRINT:a:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# No Logging
#log_event 'system' "$V_EVENT"
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
fi
exit $OK

View file

@ -5,6 +5,11 @@
# 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
@ -37,29 +42,31 @@ if [ ! -e "$V_RRD/web/httpd.rrd" ]; then
fi
# Parsing data
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))
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
# Updating rrd database
rrdtool update $V_RRD/web/httpd.rrd N:$a
fi
# Updating daily graph
# Updating rrd graph
rrdtool graph $V_RRD/web/httpd.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start -1d \
--end now \
--start "$rrd_start" \
--end "$rrd_end" \
--title "HTTPD Usage" \
--vertical-label "Connections" \
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
--x-grid "$rrd_grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -74,14 +81,15 @@ rrdtool graph $V_RRD/web/httpd.png \
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
GPRINT:a:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# No Logging
#log_event 'system' "$V_EVENT"
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
fi
exit $OK

View file

@ -5,6 +5,11 @@
# 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
@ -35,23 +40,25 @@ if [ ! -e "$V_RRD/la/la.rrd" ]; then
fi
# Parsing data
loadavg=$(cat /proc/loadavg )
la=$(echo "$loadavg"|cut -f 2 -d ' ')
pr=$(echo "$loadavg"|cut -f 4 -d ' '|cut -f 2 -d /)
if [ -z "$1" ]; then
loadavg=$(cat /proc/loadavg )
la=$(echo "$loadavg"|cut -f 2 -d ' ')
pr=$(echo "$loadavg"|cut -f 4 -d ' '|cut -f 2 -d /)
# Updating rrd database
rrdtool update $V_RRD/la/la.rrd N:${la//./}:$pr
# Updating rrd database
rrdtool update $V_RRD/la/la.rrd N:${la//./}:$pr
fi
# Updating daily graph
# Updating graph
rrdtool graph $V_RRD/la/la.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start -1d \
--end now \
--start "$rrd_start" \
--end "$rrd_end" \
--title "Load Average" \
--vertical-label "Points" \
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
--x-grid "$rrd_grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -71,14 +78,15 @@ rrdtool graph $V_RRD/la/la.png \
LINE1:pr#1c74cd:"Procs # " \
GPRINT:pr:'LAST:Current\:''%8.0lf' \
GPRINT:pr:'MIN:Min\:''%8.0lf' \
GPRINT:pr:'MAX:Max\:''%8.0lf\j' >/dev/null
GPRINT:pr:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# No Logging
#log_event 'system' "$V_EVENT"
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
fi
exit $OK

View file

@ -5,6 +5,11 @@
# 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
@ -35,23 +40,25 @@ if [ ! -e "$V_RRD/mem/mem.rrd" ]; then
fi
# Parsing data
mem=$(free -m)
ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1)
swap=$(echo "$mem" |awk '{print $3}'|tail -n1)
if [ -z "$1" ]; then
mem=$(free -m)
ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1)
swap=$(echo "$mem" |awk '{print $3}'|tail -n1)
# Updating rrd
rrdtool update $V_RRD/mem/mem.rrd N:$ram:$swap
# Updating rrd
rrdtool update $V_RRD/mem/mem.rrd N:$ram:$swap
fi
# Updating daily graph
# Updating rrd graph
rrdtool graph $V_RRD/mem/mem.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start -1d \
--end now \
--start "$rrd_start" \
--end "$rrd_end" \
--title "Memory Usage" \
--vertical-label "Mbytes" \
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
--x-grid "$rrd_grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -71,14 +78,15 @@ rrdtool graph $V_RRD/mem/mem.png \
LINE1:swap#f57900:"SWAP" \
GPRINT:swap:'LAST:Current\:''%8.0lf' \
GPRINT:swap:'MIN:Min\:''%8.0lf' \
GPRINT:swap:'MAX:Max\:''%8.0lf\j' > /dev/null
GPRINT:swap:'MAX:Max\:''%8.0lf\j' >/dev/null 2> /dev/null; result=$?
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# No Logging
#log_event 'system' "$V_EVENT"
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
fi
exit $OK

View file

@ -5,6 +5,11 @@
# 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_FUNC/shared_func.sh
@ -51,43 +56,46 @@ for host in $hosts; do
RRA:MAX:0.5:288:797
fi
# Defining host credentials
host_str=$(grep "HOST='$host'" $conf)
for key in $host_str; do
eval ${key%%=*}=${key#*=}
done
sql="mysql -h $HOST -u $USER -p$PASSWORD -P$PORT -e"
if [ -z "$1" ]; then
# Defining host credentials
host_str=$(grep "HOST='$host'" $conf)
for key in $host_str; do
eval ${key%%=*}=${key#*=}
done
sql="mysql -h $HOST -u $USER -p$PASSWORD -P$PORT -e"
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]
then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
fi
# Parsing data
status=$($sql "SHOW GLOBAL STATUS" 2>/dev/null); code="$?"
if [ '0' -ne "$code" ]; then
active=0
slow=0
else
active=$(echo "$status"|grep 'Queries'|cut -f 2)
slow=$(echo "$status"|grep 'Slow_queries'|cut -f 2)
fi
# Updating rrd
rrdtool update $V_RRD/db/mysql_$host.rrd N:$active:$slow
fi
# Parsing data
status=$($sql "SHOW GLOBAL STATUS" 2>/dev/null); code="$?"
if [ '0' -ne "$code" ]; then
active=0
slow=0
else
active=$(echo "$status"|grep 'Queries'|cut -f 2)
slow=$(echo "$status"|grep 'Slow_queries'|cut -f 2)
fi
# Updating rrd
rrdtool update $V_RRD/db/mysql_$host.rrd N:$active:$slow
# Updating daily graph
rrdtool graph $V_RRD/db/mysql_$host.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start -1d \
--end now \
--start "$rrd_start" \
--end "$rrd_end" \
--title "MySQL Usage on $host" \
--vertical-label "Queries" \
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
--x-grid "$rrd_grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -104,18 +112,20 @@ for host in $hosts; do
GPRINT:a:'LAST: Current\:''%8.0lf' \
GPRINT:a:'MIN: Min\:''%8.0lf' \
GPRINT:a:'MAX: Max\:''%8.0lf\j' \
AREA:s#f57900:"Slow " \
AREA:s#f57900:"Slow " \
GPRINT:s:'LAST:Current\:''%8.0lf' \
GPRINT:s:'MIN:Min\:''%8.0lf' \
GPRINT:s:'MAX:Max\:''%8.0lf\j' > /dev/null
GPRINT:s:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
fi
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# No Logging
#log_event 'system' "$V_EVENT"
exit $OK

View file

@ -5,6 +5,11 @@
# 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
@ -44,23 +49,25 @@ for iface in $ifaces; do
fi
# Parsing device stats
raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /")
rx=$(echo "$raw_iface" |awk '{print $2}')
tx=$(echo "$raw_iface" |awk '{print $10}')
if [ -z "$1" ]; then
raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /")
rx=$(echo "$raw_iface" |awk '{print $2}')
tx=$(echo "$raw_iface" |awk '{print $10}')
# Updating rrd database
rrdtool update $V_RRD/net/$iface.rrd N:$rx:$tx
# Updating rrd database
rrdtool update $V_RRD/net/$iface.rrd N:$rx:$tx
fi
# Updating daily graph
# Updating rrd graph
rrdtool graph $V_RRD/net/$iface.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start -1d \
--end now \
--start "$rrd_start" \
--end "$rrd_end" \
--title "Bandwidth Usage $iface" \
--vertical-label "KBytes" \
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
--x-grid "$rrd_grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -82,7 +89,12 @@ for iface in $ifaces; do
LINE1:out#1c74cd:"Output (tx)" \
GPRINT:out:'LAST:Current\:''%8.0lf' \
GPRINT:out:'MIN:Min\:''%8.0lf' \
GPRINT:out:'MAX:Max\:''%8.0lf\j' > /dev/null
GPRINT:out:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
fi
done
@ -90,7 +102,4 @@ done
# Vesta #
#----------------------------------------------------------#
# No Logging
#log_event 'system' "$V_EVENT"
exit $OK

View file

@ -5,6 +5,11 @@
# 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
@ -34,21 +39,23 @@ if [ ! -e "$V_RRD/web/nginx.rrd" ]; then
fi
# Parsing data
a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ')
if [ -z "$1" ]; then
a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ')
# Updating rrd database
rrdtool update $V_RRD/web/nginx.rrd N:$a
# Updating rrd database
rrdtool update $V_RRD/web/nginx.rrd N:$a
fi
# Updating daily graph
# Updating rrd graph
rrdtool graph $V_RRD/web/nginx.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start -1d \
--end now \
--start "$rrd_start" \
--end "$rrd_end" \
--title "NGINX Usage" \
--vertical-label "Connections" \
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
--x-grid "$rrd_grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -63,14 +70,15 @@ rrdtool graph $V_RRD/web/nginx.png \
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
GPRINT:a:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# No Logging
#log_event 'system' "$V_EVENT"
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
fi
exit $OK

View file

@ -5,6 +5,11 @@
# 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_FUNC/shared_func.sh
@ -51,48 +56,52 @@ for host in $hosts; do
RRA:MAX:0.5:288:797
fi
# Defining host credentials
host_str=$(grep "HOST='$host'" $conf)
for key in $host_str; do
eval ${key%%=*}=${key#*=}
done
if [ -z "$1" ]; then
# Defining host credentials
host_str=$(grep "HOST='$host'" $conf)
for key in $host_str; do
eval ${key%%=*}=${key#*=}
done
export PGPASSWORD="$PASSWORD"
sql="psql -h $HOST -U $USER -p $PORT -c"
export PGPASSWORD="$PASSWORD"
sql="psql -h $HOST -U $USER -p $PORT -c"
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]
then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
fi
# Parsing data
q='SELECT SUM(xact_commit + xact_rollback), SUM(numbackends)
FROM pg_stat_database;'
status=$($sql plsql -d postgres -c "$q" 2>/dev/null); code="$?"
if [ '0' -ne "$code" ]; then
active=0
slow=0
else
active=$(echo "$status"|head -n 3|tail -n 1|awk '{print $3}')
trans=$(echo "$status"|head -n 3 |tail -n 1|awk '{print $1}')
fi
# Updating rrd
export PGPASSWORD='pgsql'
rrdtool update $V_RRD/db/pgsql_$host.rrd N:$active:$trans
fi
# Parsing data
q='select sum(xact_commit + xact_rollback), sum(numbackends) from pg_stat_database;'
status=$($sql plsql -d postgres -c "$q" 2>/dev/null); code="$?"
if [ '0' -ne "$code" ]; then
active=0
slow=0
else
active=$(echo "$status"|head -n 3|tail -n 1|awk '{print $3}')
trans=$(echo "$status"|head -n 3 |tail -n 1|awk '{print $1}')
fi
# Updating rrd
export PGPASSWORD='pgsql'
rrdtool update $V_RRD/db/pgsql_$host.rrd N:$active:$trans
# Updating daily graph
# Updating rrd graph
rrdtool graph $V_RRD/db/pgsql_$host.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start -1d \
--end now \
--start "$rrd_start" \
--end "$rrd_end" \
--title "PostgreSQL Usage on $host" \
--vertical-label "Queries" \
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
--x-grid "$rrd_grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -106,21 +115,23 @@ for host in $hosts; do
DEF:t=$V_RRD/db/pgsql_$host.rrd:T:AVERAGE \
COMMENT:'\r' \
LINE1:a#fefda0:"Queries "\
GPRINT:a:'LAST: Current conn\:''%8.0lf' \
GPRINT:a:'LAST: Current\:''%8.0lf' \
GPRINT:a:'MIN: Min\:''%8.0lf' \
GPRINT:a:'MAX: Max\:''%8.0lf\j' \
LINE2:t#f57900:"Transactions" \
GPRINT:t:'LAST:Transactions\:''%8.0lf' \
GPRINT:t:'LAST:Current\:''%8.0lf' \
GPRINT:t:'MIN:Min\:''%8.0lf' \
GPRINT:t:'MAX:Max\:''%8.0lf\j' > /dev/null
GPRINT:t:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
fi
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# No Logging
#log_event 'system' "$V_EVENT"
exit $OK

View file

@ -5,6 +5,11 @@
# 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
@ -35,22 +40,24 @@ if [ ! -e "$V_RRD/ssh/ssh.rrd" ]; then
fi
# Parsing data
a=0
a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l)
if [ -z "$1" ]; then
a=0
a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l)
# Updating rrd database
rrdtool update $V_RRD/ssh/ssh.rrd N:$a
# Updating rrd database
rrdtool update $V_RRD/ssh/ssh.rrd N:$a
fi
# Updating daily graph
rrdtool graph $V_RRD/ssh/ssh.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start -1d \
--end now \
--start "$rrd_start" \
--end "$rrd_end" \
--title "SSH Usage" \
--vertical-label "Connections" \
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
--x-grid "$rrd_grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -65,14 +72,15 @@ rrdtool graph $V_RRD/ssh/ssh.png \
LINE1:a#fefda0:"Users " \
GPRINT:a:'LAST:Current\:''%8.0lf' \
GPRINT:a:'MIN:Min\:''%8.0lf' \
GPRINT:a:'MAX:Max\:''%8.0lf\j' > /dev/null
GPRINT:a:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# No Logging
#log_event 'system' "$V_EVENT"
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
fi
exit $OK