From 6d8ffc1ab9fccafbe186313b0178c8b425237a29 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Sun, 17 Feb 2013 13:00:13 +0200 Subject: [PATCH] reset bw counter on the start of the month --- bin/v-update-user-stats | 2 +- bin/v-update-web-domain-traff | 5 +++++ bin/v-update-web-domains-traff | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/v-update-user-stats b/bin/v-update-user-stats index 366c4a5cd..e1416538d 100755 --- a/bin/v-update-user-stats +++ b/bin/v-update-user-stats @@ -65,7 +65,7 @@ TOTAL_U_CRON_JOBS=0 TOTAL_U_BACKUPS=0 # Updating user stats -for user in $user_list; do +for user in $user_list; do USER_DATA=$VESTA/data/users/$user source $USER_DATA/user.conf next_month=$(date +'%m/01/%y' -d '+ 1 month') diff --git a/bin/v-update-web-domain-traff b/bin/v-update-web-domain-traff index 6792cc37d..6afe9e101 100755 --- a/bin/v-update-web-domain-traff +++ b/bin/v-update-web-domain-traff @@ -61,6 +61,11 @@ echo > $log_file # Vesta # #----------------------------------------------------------# +# Reset counter on the start of the month +if [ "$(date +%d)" = '01' ]; then + update_object_value 'web' 'DOMAIN' "$domain" '$U_BANDWIDTH' '0' +fi + # Parsing old value get_domain_values 'web' diff --git a/bin/v-update-web-domains-traff b/bin/v-update-web-domains-traff index a330d36f0..0e03ed68e 100755 --- a/bin/v-update-web-domains-traff +++ b/bin/v-update-web-domains-traff @@ -33,6 +33,11 @@ is_object_valid 'user' 'USER' "$user" "$user" #----------------------------------------------------------# for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do + # Reset BW counter on the start of the month + if [ "$(date +%d)" = '01' ]; then + update_object_value 'web' 'DOMAIN' "$domain" '$U_BANDWIDTH' '0' + fi + log_file="/var/log/httpd/domains/$domain.bytes" bytes=0