We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Databases size not updated.
Databases size not updated.
Hello,
I've VestaCP installed on a CentOS 7 server.
I realized that, since the last Vesta update, the size of databases is always zero, Vesta seems not update the sizes.
Anyone else with this problem?
Thanks.
I've VestaCP installed on a CentOS 7 server.
I realized that, since the last Vesta update, the size of databases is always zero, Vesta seems not update the sizes.
Anyone else with this problem?
Thanks.
Re: Databases size not updated.
Try to "Update counters"
Re: Databases size not updated.
Hi skurudo,skurudo wrote:Try to "Update counters"
Yes, I've tried that in the past, with no success.
The problem remains and I've also the problem in other two servers.
Re: Databases size not updated.
Not a solution, but an alternative ... from the mysql command line you can get a database's size with
SELECT table_schema 'Database Name', SUM( data_length + index_length)/1024/1024 'Database Size (MB)' FROM information_schema.TABLES where table_schema = 'name_of_your_database';"
Assuming you don't need to pass user, password, host information etc to mysql, you could use that in a script like this
SELECT table_schema 'Database Name', SUM( data_length + index_length)/1024/1024 'Database Size (MB)' FROM information_schema.TABLES where table_schema = 'name_of_your_database';"
Assuming you don't need to pass user, password, host information etc to mysql, you could use that in a script like this
Code: Select all
#!/bin/bash
DBNAME=your_db_name
mysql -e "SELECT table_schema 'Database Name', SUM( data_length + index_length)/1024/1024 'Database Size (MB)' FROM information_schema.TABLES where table_schema = '$DBNAME';"
Re: Databases size not updated.
OK, slightly better script which takes db name as an input. :-) Slow day at work ...
Code: Select all
#!/bin/bash
if [ -z "$1" ]
then
echo "No database name supplied. Here is a list of them:"
mysql -sN -e "SHOW DATABASES;"
read -p "Please enter a Database Name: " DBNAME
else
DBNAME=$1
fi
DBSIZE=$(mysql -sN -e "SELECT SUM( data_length + index_length)/1024/1024 FROM information_schema.TABLES where table_schema = '$DBNAME';")
echo $DBNAME is $DBSIZE Mb
Re: Databases size not updated.
Went hunting in the code and found a function in $VESTA/func/db.sh
Seems that swapping the double quotes around Size to single quotes allows the database size calculation to work. i.e. \"Size\" -> \'Size\'
Code: Select all
get_mysql_disk_usage() {
mysql_connect $HOST
query="SELECT SUM( data_length + index_length ) / 1024 / 1024 \"Size\"
FROM information_schema.TABLES WHERE table_schema='$database'"
usage=$(mysql_query "$query" |tail -n1)
if [ "$usage" == '' ] || [ "$usage" == 'NULL' ] || [ "${usage:0:1}" -eq '0' ]; then
usage=1
fi
export LC_ALL=C
usage=$(printf "%0.f\n" $usage)
}
Re: Databases size not updated.
Thanks @plutocrat!!plutocrat wrote:Not a solution, but an alternative ... from the mysql command line you can get a database's size with