File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed
Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # info: update IP usage counters
3+ # options: IP
4+ #
5+ # Function updates usage U_WEB_ADOMAINS and U_SYS_USERS counters.
6+
7+
8+ # ----------------------------------------------------------#
9+ # Variable&Function #
10+ # ----------------------------------------------------------#
11+
12+ # Argument defenition
13+ ip=$1
14+
15+ # Includes
16+ source $VESTA /conf/vesta.conf
17+ source $VESTA /func/main.sh
18+ source $VESTA /func/ip.sh
19+
20+
21+ # ----------------------------------------------------------#
22+ # Verifications #
23+ # ----------------------------------------------------------#
24+
25+ check_args ' 0' " $# " ' IP'
26+ if [ ! -z " $ip " ]; then
27+ validate_format ' ip'
28+ is_ip_valid
29+ fi
30+
31+
32+ # ----------------------------------------------------------#
33+ # Action #
34+ # ----------------------------------------------------------#
35+
36+ # Creating user_list
37+ if [ -z " $ip " ]; then
38+ ip_list=$( ls $VESTA /data/ips)
39+ else
40+ ip_list=" $ip "
41+ fi
42+
43+ # Updating user stats
44+ for ip in $ip_list ; do
45+
46+ # Calculate usage
47+ ip_usage=$( grep -H $ip $VESTA /data/users/* /web.conf)
48+ web_domains=$( echo " $ip_usage " | wc -l)
49+ sys_users=$( echo " $ip_usage " | cut -f7 -d/ | sort -u | \
50+ tr ' \n' ' ,' | sed -e " s/,$//g" )
51+
52+ # Update counters
53+ update_ip_value ' $U_WEB_DOMAINS' " $web_domains "
54+ update_ip_value ' $U_SYS_USERS' " $sys_users "
55+ done
56+
57+
58+ # ----------------------------------------------------------#
59+ # Vesta #
60+ # ----------------------------------------------------------#
61+
62+ # Logging
63+ log_event " $OK " " $EVENT "
64+
65+ exit
You can’t perform that action at this time.
0 commit comments