|
|
@@ -1,6 +1,6 @@
|
|
|
#!/bin/bash
|
|
|
# info: update system rrd charts
|
|
|
-# options: period
|
|
|
+# options: none
|
|
|
#
|
|
|
# The script is wrapper for all rrd functions. It updates all
|
|
|
# v_update_sys_rrd_* at once.
|
|
|
@@ -22,9 +22,6 @@ source $VESTA/func/shared.sh
|
|
|
PATH="$PATH:$BIN"
|
|
|
export PATH
|
|
|
|
|
|
-# Argument defenition
|
|
|
-period=$1
|
|
|
-
|
|
|
# Checking rrddir
|
|
|
if [ ! -d "$RRD" ]; then
|
|
|
mkdir -p $RRD
|
|
|
@@ -35,38 +32,101 @@ fi
|
|
|
# Action #
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
-# Updateing system stats
|
|
|
-$BIN/v_update_sys_rrd_la $period
|
|
|
-$BIN/v_update_sys_rrd_net $period
|
|
|
-$BIN/v_update_sys_rrd_mem $period
|
|
|
-$BIN/v_update_sys_rrd_ssh $period
|
|
|
-
|
|
|
-# Updating web stats
|
|
|
-if [ "$WEB_SYSTEM" = 'apache' ]; then
|
|
|
- $BIN/v_update_sys_rrd_httpd $period
|
|
|
+# Checking daily period
|
|
|
+if [ -e "$RRD/daily.rrd" ]; then
|
|
|
+ mtime=$(stat -c "%Y" $RRD/daily.rrd)
|
|
|
+ ctime=$(date +%s)
|
|
|
+ dtime=$((ctime - mtime))
|
|
|
+ # Update every 5 minute
|
|
|
+ if [ "$dtime" -gt '290' ]; then
|
|
|
+ touch $RRD/daily.rrd
|
|
|
+ periods="$periods daily"
|
|
|
+ fi
|
|
|
+else
|
|
|
+ touch $RRD/daily.rrd
|
|
|
+ periods="$periods daily"
|
|
|
fi
|
|
|
|
|
|
-if [ "$PROXY_SYSTEM" = 'nginx' ]; then
|
|
|
- $BIN/v_update_sys_rrd_nginx $period
|
|
|
+# Checking weekly period
|
|
|
+if [ -e "$RRD/weekly.rrd" ]; then
|
|
|
+ mtime=$(stat -c "%Y" $RRD/weekly.rrd)
|
|
|
+ ctime=$(date +%s)
|
|
|
+ dtime=$((ctime - mtime))
|
|
|
+ # Update every hour
|
|
|
+ if [ "$dtime" -gt '3590' ]; then
|
|
|
+ touch $RRD/weekly.rrd
|
|
|
+ periods="$periods weekly"
|
|
|
+ fi
|
|
|
+else
|
|
|
+ touch $RRD/weekly.rrd
|
|
|
+ periods="$periods weekly"
|
|
|
fi
|
|
|
|
|
|
-# Updating ftp stats
|
|
|
-if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
|
|
|
- $BIN/v_update_sys_rrd_ftp $period
|
|
|
+# Checking monthly period
|
|
|
+if [ -e "$RRD/monthly.rrd" ]; then
|
|
|
+ mtime=$(stat -c "%Y" $RRD/monthly.rrd)
|
|
|
+ ctime=$(date +%s)
|
|
|
+ dtime=$((ctime - mtime))
|
|
|
+ # Update every 6 hours
|
|
|
+ if [ "$dtime" -gt '21590' ]; then
|
|
|
+ touch $RRD/monthly.rrd
|
|
|
+ periods="$periods monthly"
|
|
|
+ fi
|
|
|
+else
|
|
|
+ touch $RRD/monthly.rrd
|
|
|
+ periods="$periods monthly"
|
|
|
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) $BIN/v_update_sys_rrd_mysql $period ;;
|
|
|
- pgsql) $BIN/v_update_sys_rrd_pgsql $period ;;
|
|
|
- esac
|
|
|
- done
|
|
|
+# Checking yearly period
|
|
|
+if [ -e "$RRD/yearly.rrd" ]; then
|
|
|
+ mtime=$(stat -c "%Y" $RRD/yearly.rrd)
|
|
|
+ ctime=$(date +%s)
|
|
|
+ dtime=$((ctime - mtime))
|
|
|
+ # Update every 12 hours
|
|
|
+ if [ "$dtime" -gt '43190' ]; then
|
|
|
+ touch $RRD/yearly.rrd
|
|
|
+ periods="$periods yearly"
|
|
|
+ fi
|
|
|
+else
|
|
|
+ touch $RRD/yearly.rrd
|
|
|
+ periods="$periods yearly"
|
|
|
fi
|
|
|
|
|
|
|
|
|
+# Updateing system stats
|
|
|
+for period in $periods; do
|
|
|
+
|
|
|
+ $BIN/v_update_sys_rrd_la $period
|
|
|
+ $BIN/v_update_sys_rrd_net $period
|
|
|
+ $BIN/v_update_sys_rrd_mem $period
|
|
|
+ $BIN/v_update_sys_rrd_ssh $period
|
|
|
+
|
|
|
+ # Updating web stats
|
|
|
+ if [ "$WEB_SYSTEM" = 'apache' ]; then
|
|
|
+ $BIN/v_update_sys_rrd_httpd $period
|
|
|
+ fi
|
|
|
+
|
|
|
+ if [ "$PROXY_SYSTEM" = 'nginx' ]; then
|
|
|
+ $BIN/v_update_sys_rrd_nginx $period
|
|
|
+ fi
|
|
|
+
|
|
|
+ # Updating ftp stats
|
|
|
+ if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
|
|
|
+ $BIN/v_update_sys_rrd_ftp $period
|
|
|
+ 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) $BIN/v_update_sys_rrd_mysql $period ;;
|
|
|
+ pgsql) $BIN/v_update_sys_rrd_pgsql $period ;;
|
|
|
+ esac
|
|
|
+ done
|
|
|
+ fi
|
|
|
+done
|
|
|
+
|
|
|
#----------------------------------------------------------#
|
|
|
# Vesta #
|
|
|
#----------------------------------------------------------#
|