mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 04:50:47 -07:00
RRD custom time interval support
This commit is contained in:
parent
a45bf7e4bd
commit
e48992ccfc
10 changed files with 301 additions and 156 deletions
66
bin/v_upd_sys_rrd
Executable file
66
bin/v_upd_sys_rrd
Executable 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
|
|
@ -5,6 +5,11 @@
|
||||||
# Variable&Function #
|
# 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
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_CONF/vesta.conf
|
source $V_CONF/vesta.conf
|
||||||
|
@ -35,22 +40,25 @@ if [ ! -e "$V_RRD/ftp/ftp.rrd" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parsing data
|
# Parsing data
|
||||||
a=0
|
if [ -z "$1" ]; then
|
||||||
a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody| grep -v root|wc -l)
|
a=0
|
||||||
|
a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\
|
||||||
|
grep -v root|wc -l)
|
||||||
|
|
||||||
# Updating rrd database
|
# Updating rrd database
|
||||||
rrdtool update $V_RRD/ftp/ftp.rrd N:$a
|
rrdtool update $V_RRD/ftp/ftp.rrd N:$a
|
||||||
|
fi
|
||||||
|
|
||||||
# Updating daily graph
|
# Updating rrd graph
|
||||||
rrdtool graph $V_RRD/ftp/ftp.png \
|
rrdtool graph $V_RRD/ftp/ftp.png \
|
||||||
--imgformat PNG \
|
--imgformat PNG \
|
||||||
--height="120" \
|
--height="120" \
|
||||||
--width="440" \
|
--width="440" \
|
||||||
--start -1d \
|
--start "$rrd_start" \
|
||||||
--end now \
|
--end "$rrd_end" \
|
||||||
--title "$(echo $FTP_SYSTEM|tr '[a-z]' '[A-Z]') Usage" \
|
--title "$(echo $FTP_SYSTEM|tr '[a-z]' '[A-Z]') Usage" \
|
||||||
--vertical-label "Connections" \
|
--vertical-label "Connections" \
|
||||||
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
|
--x-grid "$rrd_grid" \
|
||||||
-c "BACK#484439" \
|
-c "BACK#484439" \
|
||||||
-c "SHADEA#484439" \
|
-c "SHADEA#484439" \
|
||||||
-c "SHADEB#484439" \
|
-c "SHADEB#484439" \
|
||||||
|
@ -65,14 +73,15 @@ rrdtool graph $V_RRD/ftp/ftp.png \
|
||||||
LINE1:a#fefda0:"Users " \
|
LINE1:a#fefda0:"Users " \
|
||||||
GPRINT:a:'LAST:Current\:''%8.0lf' \
|
GPRINT:a:'LAST:Current\:''%8.0lf' \
|
||||||
GPRINT:a:'MIN:Min\:''%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 #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# No Logging
|
if [ "$result" -ne 0 ]; then
|
||||||
#log_event 'system' "$V_EVENT"
|
exit $E_RRD_FAILED
|
||||||
|
fi
|
||||||
|
|
||||||
exit $OK
|
exit $OK
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
# Variable&Function #
|
# 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
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_CONF/vesta.conf
|
source $V_CONF/vesta.conf
|
||||||
|
@ -37,29 +42,31 @@ if [ ! -e "$V_RRD/web/httpd.rrd" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parsing data
|
# Parsing data
|
||||||
web_port=$(get_config_value '$WEB_PORT')
|
if [ -z "$1" ]; then
|
||||||
server_status=$(wget -qO- http://localhost:$web_port/server-status |\
|
web_port=$(get_config_value '$WEB_PORT')
|
||||||
grep 'currently being processed'| \
|
server_status=$(wget -qO- http://localhost:$web_port/server-status |\
|
||||||
cut -f 2 -d '>' |\
|
grep 'currently being processed'| \
|
||||||
sed 's/requests currently being processed, //' | \
|
cut -f 2 -d '>' |\
|
||||||
cut -f 1,2 -d ' ')
|
sed 's/requests currently being processed, //' | \
|
||||||
active=$(echo "$server_status"|cut -f 1 -d ' ')
|
cut -f 1,2 -d ' ')
|
||||||
idle=$(echo "$server_status"|cut -f 1 -d ' ')
|
active=$(echo "$server_status"|cut -f 1 -d ' ')
|
||||||
a=$((active + idle))
|
idle=$(echo "$server_status"|cut -f 1 -d ' ')
|
||||||
|
a=$((active + idle))
|
||||||
|
|
||||||
# Updating rrd database
|
# Updating rrd database
|
||||||
rrdtool update $V_RRD/web/httpd.rrd N:$a
|
rrdtool update $V_RRD/web/httpd.rrd N:$a
|
||||||
|
fi
|
||||||
|
|
||||||
# Updating daily graph
|
# Updating rrd graph
|
||||||
rrdtool graph $V_RRD/web/httpd.png \
|
rrdtool graph $V_RRD/web/httpd.png \
|
||||||
--imgformat PNG \
|
--imgformat PNG \
|
||||||
--height="120" \
|
--height="120" \
|
||||||
--width="440" \
|
--width="440" \
|
||||||
--start -1d \
|
--start "$rrd_start" \
|
||||||
--end now \
|
--end "$rrd_end" \
|
||||||
--title "HTTPD Usage" \
|
--title "HTTPD Usage" \
|
||||||
--vertical-label "Connections" \
|
--vertical-label "Connections" \
|
||||||
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
|
--x-grid "$rrd_grid" \
|
||||||
-c "BACK#484439" \
|
-c "BACK#484439" \
|
||||||
-c "SHADEA#484439" \
|
-c "SHADEA#484439" \
|
||||||
-c "SHADEB#484439" \
|
-c "SHADEB#484439" \
|
||||||
|
@ -74,14 +81,15 @@ rrdtool graph $V_RRD/web/httpd.png \
|
||||||
LINE1:a#fefda0:"Connections " \
|
LINE1:a#fefda0:"Connections " \
|
||||||
GPRINT:a:'LAST:Current\:''%8.0lf' \
|
GPRINT:a:'LAST:Current\:''%8.0lf' \
|
||||||
GPRINT:a:'MIN:Min\:''%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 #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# No Logging
|
if [ "$result" -ne 0 ]; then
|
||||||
#log_event 'system' "$V_EVENT"
|
exit $E_RRD_FAILED
|
||||||
|
fi
|
||||||
|
|
||||||
exit $OK
|
exit $OK
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
# Variable&Function #
|
# 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
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
|
||||||
|
@ -35,23 +40,25 @@ if [ ! -e "$V_RRD/la/la.rrd" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parsing data
|
# Parsing data
|
||||||
loadavg=$(cat /proc/loadavg )
|
if [ -z "$1" ]; then
|
||||||
la=$(echo "$loadavg"|cut -f 2 -d ' ')
|
loadavg=$(cat /proc/loadavg )
|
||||||
pr=$(echo "$loadavg"|cut -f 4 -d ' '|cut -f 2 -d /)
|
la=$(echo "$loadavg"|cut -f 2 -d ' ')
|
||||||
|
pr=$(echo "$loadavg"|cut -f 4 -d ' '|cut -f 2 -d /)
|
||||||
|
|
||||||
# Updating rrd database
|
# Updating rrd database
|
||||||
rrdtool update $V_RRD/la/la.rrd N:${la//./}:$pr
|
rrdtool update $V_RRD/la/la.rrd N:${la//./}:$pr
|
||||||
|
fi
|
||||||
|
|
||||||
# Updating daily graph
|
# Updating graph
|
||||||
rrdtool graph $V_RRD/la/la.png \
|
rrdtool graph $V_RRD/la/la.png \
|
||||||
--imgformat PNG \
|
--imgformat PNG \
|
||||||
--height="120" \
|
--height="120" \
|
||||||
--width="440" \
|
--width="440" \
|
||||||
--start -1d \
|
--start "$rrd_start" \
|
||||||
--end now \
|
--end "$rrd_end" \
|
||||||
--title "Load Average" \
|
--title "Load Average" \
|
||||||
--vertical-label "Points" \
|
--vertical-label "Points" \
|
||||||
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
|
--x-grid "$rrd_grid" \
|
||||||
-c "BACK#484439" \
|
-c "BACK#484439" \
|
||||||
-c "SHADEA#484439" \
|
-c "SHADEA#484439" \
|
||||||
-c "SHADEB#484439" \
|
-c "SHADEB#484439" \
|
||||||
|
@ -71,14 +78,15 @@ rrdtool graph $V_RRD/la/la.png \
|
||||||
LINE1:pr#1c74cd:"Procs # " \
|
LINE1:pr#1c74cd:"Procs # " \
|
||||||
GPRINT:pr:'LAST:Current\:''%8.0lf' \
|
GPRINT:pr:'LAST:Current\:''%8.0lf' \
|
||||||
GPRINT:pr:'MIN:Min\:''%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 #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# No Logging
|
if [ "$result" -ne 0 ]; then
|
||||||
#log_event 'system' "$V_EVENT"
|
exit $E_RRD_FAILED
|
||||||
|
fi
|
||||||
|
|
||||||
exit $OK
|
exit $OK
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
# Variable&Function #
|
# 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
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
|
||||||
|
@ -35,23 +40,25 @@ if [ ! -e "$V_RRD/mem/mem.rrd" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parsing data
|
# Parsing data
|
||||||
mem=$(free -m)
|
if [ -z "$1" ]; then
|
||||||
ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1)
|
mem=$(free -m)
|
||||||
swap=$(echo "$mem" |awk '{print $3}'|tail -n1)
|
ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1)
|
||||||
|
swap=$(echo "$mem" |awk '{print $3}'|tail -n1)
|
||||||
|
|
||||||
# Updating rrd
|
# Updating rrd
|
||||||
rrdtool update $V_RRD/mem/mem.rrd N:$ram:$swap
|
rrdtool update $V_RRD/mem/mem.rrd N:$ram:$swap
|
||||||
|
fi
|
||||||
|
|
||||||
# Updating daily graph
|
# Updating rrd graph
|
||||||
rrdtool graph $V_RRD/mem/mem.png \
|
rrdtool graph $V_RRD/mem/mem.png \
|
||||||
--imgformat PNG \
|
--imgformat PNG \
|
||||||
--height="120" \
|
--height="120" \
|
||||||
--width="440" \
|
--width="440" \
|
||||||
--start -1d \
|
--start "$rrd_start" \
|
||||||
--end now \
|
--end "$rrd_end" \
|
||||||
--title "Memory Usage" \
|
--title "Memory Usage" \
|
||||||
--vertical-label "Mbytes" \
|
--vertical-label "Mbytes" \
|
||||||
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
|
--x-grid "$rrd_grid" \
|
||||||
-c "BACK#484439" \
|
-c "BACK#484439" \
|
||||||
-c "SHADEA#484439" \
|
-c "SHADEA#484439" \
|
||||||
-c "SHADEB#484439" \
|
-c "SHADEB#484439" \
|
||||||
|
@ -71,14 +78,15 @@ rrdtool graph $V_RRD/mem/mem.png \
|
||||||
LINE1:swap#f57900:"SWAP" \
|
LINE1:swap#f57900:"SWAP" \
|
||||||
GPRINT:swap:'LAST:Current\:''%8.0lf' \
|
GPRINT:swap:'LAST:Current\:''%8.0lf' \
|
||||||
GPRINT:swap:'MIN:Min\:''%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 #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# No Logging
|
if [ "$result" -ne 0 ]; then
|
||||||
#log_event 'system' "$V_EVENT"
|
exit $E_RRD_FAILED
|
||||||
|
fi
|
||||||
|
|
||||||
exit $OK
|
exit $OK
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
# Variable&Function #
|
# 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
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
|
@ -51,43 +56,46 @@ for host in $hosts; do
|
||||||
RRA:MAX:0.5:288:797
|
RRA:MAX:0.5:288:797
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Defining host credentials
|
if [ -z "$1" ]; then
|
||||||
host_str=$(grep "HOST='$host'" $conf)
|
# Defining host credentials
|
||||||
for key in $host_str; do
|
host_str=$(grep "HOST='$host'" $conf)
|
||||||
eval ${key%%=*}=${key#*=}
|
for key in $host_str; do
|
||||||
done
|
eval ${key%%=*}=${key#*=}
|
||||||
sql="mysql -h $HOST -u $USER -p$PASSWORD -P$PORT -e"
|
done
|
||||||
|
sql="mysql -h $HOST -u $USER -p$PASSWORD -P$PORT -e"
|
||||||
|
|
||||||
# Checking empty vars
|
# Checking empty vars
|
||||||
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
|
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]
|
||||||
echo "Error: config is broken"
|
then
|
||||||
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
|
echo "Error: config is broken"
|
||||||
exit $E_PARSE_ERROR
|
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
|
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
|
# Updating daily graph
|
||||||
rrdtool graph $V_RRD/db/mysql_$host.png \
|
rrdtool graph $V_RRD/db/mysql_$host.png \
|
||||||
--imgformat PNG \
|
--imgformat PNG \
|
||||||
--height="120" \
|
--height="120" \
|
||||||
--width="440" \
|
--width="440" \
|
||||||
--start -1d \
|
--start "$rrd_start" \
|
||||||
--end now \
|
--end "$rrd_end" \
|
||||||
--title "MySQL Usage on $host" \
|
--title "MySQL Usage on $host" \
|
||||||
--vertical-label "Queries" \
|
--vertical-label "Queries" \
|
||||||
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
|
--x-grid "$rrd_grid" \
|
||||||
-c "BACK#484439" \
|
-c "BACK#484439" \
|
||||||
-c "SHADEA#484439" \
|
-c "SHADEA#484439" \
|
||||||
-c "SHADEB#484439" \
|
-c "SHADEB#484439" \
|
||||||
|
@ -104,18 +112,20 @@ for host in $hosts; do
|
||||||
GPRINT:a:'LAST: Current\:''%8.0lf' \
|
GPRINT:a:'LAST: Current\:''%8.0lf' \
|
||||||
GPRINT:a:'MIN: Min\:''%8.0lf' \
|
GPRINT:a:'MIN: Min\:''%8.0lf' \
|
||||||
GPRINT:a:'MAX: Max\:''%8.0lf\j' \
|
GPRINT:a:'MAX: Max\:''%8.0lf\j' \
|
||||||
AREA:s#f57900:"Slow " \
|
AREA:s#f57900:"Slow " \
|
||||||
GPRINT:s:'LAST:Current\:''%8.0lf' \
|
GPRINT:s:'LAST:Current\:''%8.0lf' \
|
||||||
GPRINT:s:'MIN:Min\:''%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
|
done
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# No Logging
|
|
||||||
#log_event 'system' "$V_EVENT"
|
|
||||||
|
|
||||||
exit $OK
|
exit $OK
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
# Variable&Function #
|
# 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
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
|
||||||
|
@ -44,23 +49,25 @@ for iface in $ifaces; do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parsing device stats
|
# Parsing device stats
|
||||||
raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /")
|
if [ -z "$1" ]; then
|
||||||
rx=$(echo "$raw_iface" |awk '{print $2}')
|
raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /")
|
||||||
tx=$(echo "$raw_iface" |awk '{print $10}')
|
rx=$(echo "$raw_iface" |awk '{print $2}')
|
||||||
|
tx=$(echo "$raw_iface" |awk '{print $10}')
|
||||||
|
|
||||||
# Updating rrd database
|
# Updating rrd database
|
||||||
rrdtool update $V_RRD/net/$iface.rrd N:$rx:$tx
|
rrdtool update $V_RRD/net/$iface.rrd N:$rx:$tx
|
||||||
|
fi
|
||||||
|
|
||||||
# Updating daily graph
|
# Updating rrd graph
|
||||||
rrdtool graph $V_RRD/net/$iface.png \
|
rrdtool graph $V_RRD/net/$iface.png \
|
||||||
--imgformat PNG \
|
--imgformat PNG \
|
||||||
--height="120" \
|
--height="120" \
|
||||||
--width="440" \
|
--width="440" \
|
||||||
--start -1d \
|
--start "$rrd_start" \
|
||||||
--end now \
|
--end "$rrd_end" \
|
||||||
--title "Bandwidth Usage $iface" \
|
--title "Bandwidth Usage $iface" \
|
||||||
--vertical-label "KBytes" \
|
--vertical-label "KBytes" \
|
||||||
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
|
--x-grid "$rrd_grid" \
|
||||||
-c "BACK#484439" \
|
-c "BACK#484439" \
|
||||||
-c "SHADEA#484439" \
|
-c "SHADEA#484439" \
|
||||||
-c "SHADEB#484439" \
|
-c "SHADEB#484439" \
|
||||||
|
@ -82,7 +89,12 @@ for iface in $ifaces; do
|
||||||
LINE1:out#1c74cd:"Output (tx)" \
|
LINE1:out#1c74cd:"Output (tx)" \
|
||||||
GPRINT:out:'LAST:Current\:''%8.0lf' \
|
GPRINT:out:'LAST:Current\:''%8.0lf' \
|
||||||
GPRINT:out:'MIN:Min\:''%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
|
done
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,7 +102,4 @@ done
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# No Logging
|
|
||||||
#log_event 'system' "$V_EVENT"
|
|
||||||
|
|
||||||
exit $OK
|
exit $OK
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
# Variable&Function #
|
# 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
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
|
||||||
|
@ -34,21 +39,23 @@ if [ ! -e "$V_RRD/web/nginx.rrd" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parsing data
|
# 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
|
# Updating rrd database
|
||||||
rrdtool update $V_RRD/web/nginx.rrd N:$a
|
rrdtool update $V_RRD/web/nginx.rrd N:$a
|
||||||
|
fi
|
||||||
|
|
||||||
# Updating daily graph
|
# Updating rrd graph
|
||||||
rrdtool graph $V_RRD/web/nginx.png \
|
rrdtool graph $V_RRD/web/nginx.png \
|
||||||
--imgformat PNG \
|
--imgformat PNG \
|
||||||
--height="120" \
|
--height="120" \
|
||||||
--width="440" \
|
--width="440" \
|
||||||
--start -1d \
|
--start "$rrd_start" \
|
||||||
--end now \
|
--end "$rrd_end" \
|
||||||
--title "NGINX Usage" \
|
--title "NGINX Usage" \
|
||||||
--vertical-label "Connections" \
|
--vertical-label "Connections" \
|
||||||
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
|
--x-grid "$rrd_grid" \
|
||||||
-c "BACK#484439" \
|
-c "BACK#484439" \
|
||||||
-c "SHADEA#484439" \
|
-c "SHADEA#484439" \
|
||||||
-c "SHADEB#484439" \
|
-c "SHADEB#484439" \
|
||||||
|
@ -63,14 +70,15 @@ rrdtool graph $V_RRD/web/nginx.png \
|
||||||
LINE1:a#fefda0:"Connections " \
|
LINE1:a#fefda0:"Connections " \
|
||||||
GPRINT:a:'LAST:Current\:''%8.0lf' \
|
GPRINT:a:'LAST:Current\:''%8.0lf' \
|
||||||
GPRINT:a:'MIN:Min\:''%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 #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# No Logging
|
if [ "$result" -ne 0 ]; then
|
||||||
#log_event 'system' "$V_EVENT"
|
exit $E_RRD_FAILED
|
||||||
|
fi
|
||||||
|
|
||||||
exit $OK
|
exit $OK
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
# Variable&Function #
|
# 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
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
|
@ -51,48 +56,52 @@ for host in $hosts; do
|
||||||
RRA:MAX:0.5:288:797
|
RRA:MAX:0.5:288:797
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Defining host credentials
|
if [ -z "$1" ]; then
|
||||||
host_str=$(grep "HOST='$host'" $conf)
|
# Defining host credentials
|
||||||
for key in $host_str; do
|
host_str=$(grep "HOST='$host'" $conf)
|
||||||
eval ${key%%=*}=${key#*=}
|
for key in $host_str; do
|
||||||
done
|
eval ${key%%=*}=${key#*=}
|
||||||
|
done
|
||||||
|
|
||||||
export PGPASSWORD="$PASSWORD"
|
export PGPASSWORD="$PASSWORD"
|
||||||
sql="psql -h $HOST -U $USER -p $PORT -c"
|
sql="psql -h $HOST -U $USER -p $PORT -c"
|
||||||
|
|
||||||
# Checking empty vars
|
# Checking empty vars
|
||||||
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
|
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]
|
||||||
echo "Error: config is broken"
|
then
|
||||||
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
|
echo "Error: config is broken"
|
||||||
exit $E_PARSE_ERROR
|
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
|
fi
|
||||||
|
|
||||||
|
# Updating rrd graph
|
||||||
# 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
|
|
||||||
rrdtool graph $V_RRD/db/pgsql_$host.png \
|
rrdtool graph $V_RRD/db/pgsql_$host.png \
|
||||||
--imgformat PNG \
|
--imgformat PNG \
|
||||||
--height="120" \
|
--height="120" \
|
||||||
--width="440" \
|
--width="440" \
|
||||||
--start -1d \
|
--start "$rrd_start" \
|
||||||
--end now \
|
--end "$rrd_end" \
|
||||||
--title "PostgreSQL Usage on $host" \
|
--title "PostgreSQL Usage on $host" \
|
||||||
--vertical-label "Queries" \
|
--vertical-label "Queries" \
|
||||||
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
|
--x-grid "$rrd_grid" \
|
||||||
-c "BACK#484439" \
|
-c "BACK#484439" \
|
||||||
-c "SHADEA#484439" \
|
-c "SHADEA#484439" \
|
||||||
-c "SHADEB#484439" \
|
-c "SHADEB#484439" \
|
||||||
|
@ -106,21 +115,23 @@ for host in $hosts; do
|
||||||
DEF:t=$V_RRD/db/pgsql_$host.rrd:T:AVERAGE \
|
DEF:t=$V_RRD/db/pgsql_$host.rrd:T:AVERAGE \
|
||||||
COMMENT:'\r' \
|
COMMENT:'\r' \
|
||||||
LINE1:a#fefda0:"Queries "\
|
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:'MIN: Min\:''%8.0lf' \
|
||||||
GPRINT:a:'MAX: Max\:''%8.0lf\j' \
|
GPRINT:a:'MAX: Max\:''%8.0lf\j' \
|
||||||
LINE2:t#f57900:"Transactions" \
|
LINE2:t#f57900:"Transactions" \
|
||||||
GPRINT:t:'LAST:Transactions\:''%8.0lf' \
|
GPRINT:t:'LAST:Current\:''%8.0lf' \
|
||||||
GPRINT:t:'MIN:Min\:''%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
|
done
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# No Logging
|
|
||||||
#log_event 'system' "$V_EVENT"
|
|
||||||
|
|
||||||
exit $OK
|
exit $OK
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
# Variable&Function #
|
# 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
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_CONF/vesta.conf
|
source $V_CONF/vesta.conf
|
||||||
|
@ -35,22 +40,24 @@ if [ ! -e "$V_RRD/ssh/ssh.rrd" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parsing data
|
# Parsing data
|
||||||
a=0
|
if [ -z "$1" ]; then
|
||||||
a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l)
|
a=0
|
||||||
|
a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l)
|
||||||
|
|
||||||
# Updating rrd database
|
# Updating rrd database
|
||||||
rrdtool update $V_RRD/ssh/ssh.rrd N:$a
|
rrdtool update $V_RRD/ssh/ssh.rrd N:$a
|
||||||
|
fi
|
||||||
|
|
||||||
# Updating daily graph
|
# Updating daily graph
|
||||||
rrdtool graph $V_RRD/ssh/ssh.png \
|
rrdtool graph $V_RRD/ssh/ssh.png \
|
||||||
--imgformat PNG \
|
--imgformat PNG \
|
||||||
--height="120" \
|
--height="120" \
|
||||||
--width="440" \
|
--width="440" \
|
||||||
--start -1d \
|
--start "$rrd_start" \
|
||||||
--end now \
|
--end "$rrd_end" \
|
||||||
--title "SSH Usage" \
|
--title "SSH Usage" \
|
||||||
--vertical-label "Connections" \
|
--vertical-label "Connections" \
|
||||||
--x-grid MINUTE:30:HOUR:1:HOUR:4:0:%H:%M\
|
--x-grid "$rrd_grid" \
|
||||||
-c "BACK#484439" \
|
-c "BACK#484439" \
|
||||||
-c "SHADEA#484439" \
|
-c "SHADEA#484439" \
|
||||||
-c "SHADEB#484439" \
|
-c "SHADEB#484439" \
|
||||||
|
@ -65,14 +72,15 @@ rrdtool graph $V_RRD/ssh/ssh.png \
|
||||||
LINE1:a#fefda0:"Users " \
|
LINE1:a#fefda0:"Users " \
|
||||||
GPRINT:a:'LAST:Current\:''%8.0lf' \
|
GPRINT:a:'LAST:Current\:''%8.0lf' \
|
||||||
GPRINT:a:'MIN:Min\:''%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 #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# No Logging
|
if [ "$result" -ne 0 ]; then
|
||||||
#log_event 'system' "$V_EVENT"
|
exit $E_RRD_FAILED
|
||||||
|
fi
|
||||||
|
|
||||||
exit $OK
|
exit $OK
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue