100-monitor_database_size.inc.php reports 0 used space

Discussion in 'General' started by Roberto Altravia, Oct 8, 2018.

  1. Roberto Altravia

    Roberto Altravia New Member

    Hello,
    I have a test database called c0freenet with a 25MB quota. I filled it with more than 30MB of data.
    Now on the ISPConfig 3.1 home page I have always "Used Space" 0 under Database quota (Quota is 25 MB)

    If I run /usr/local/ispconfig/server/cron.sh by hand, 100-monitor_database_size.inc.php says:
    database c0freenet size does not exceed quota: 26214400 (quota) > 0 (used)

    But that's not true. I checked the library and internally it runs a mysql query:
    SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='c0freenet';
    that returns about 40MB:
    +-------------------------------+
    | SUM(data_length+index_length) |
    +-------------------------------+
    | 41324160 |
    +-------------------------------+


    Any clue on how to fix this ? I installed ispconfig3-stable-3.1-e2465bd7a2d324259c3c1dae00dfca8c2535edcc

    Thank you,
    Roberto
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    When did you install the ISPConfig git-stable version? If it was not installed in the past few days, try to make an update to the current git-stable version to see if that solves the issue.
     
  3. Roberto Altravia

    Roberto Altravia New Member

    I installed it yesterday ... do I need to update ? Can you outline the procedure to do so ?

    Thank you,
    Roberto
     
  4. Jesse Norell

    Jesse Norell Well-Known Member

    That is the latest stable-3.1.

    Is this a single server or multi-server install? If multi-server, make sure all your servers are on that same version.

    Check that the password in /usr/local/ispconfig/server/lib/mysql_clientdb.conf works (run 'mysql -u root -p -h localhost mysql' and paste that password).
     
  5. Roberto Altravia

    Roberto Altravia New Member

    Hello,
    this is a single Ubuntu 14.04 installation.
    I checked mysql_clientdb.conf and the username and password is correct. mysql logins just fine
     
  6. Roberto Altravia

    Roberto Altravia New Member

  7. till

    till Super Moderator Staff Member ISPConfig Developer

    The archive you downloaded is the latest git-stable version, as @Jesse Norell pointed out already in post #4.
     
  8. Jesse Norell

    Jesse Norell Well-Known Member

    It is a development version of the stable-3.1 branch, a git branch of the current stable version, 3.1. At some point in the future that branch will become the next stable release (3.1.14). Not to be confused with the master branch, which is development branch for the next version of ispconfig, eg. 3.2. Not many features make it into 3.1, it's mostly for bugfixes, and the particular ispconfig3-stable-3.1-e2465bd7a2d324259c3c1dae00dfca8c2535edcc which you installed is a few bugfixes/changes ahead of the most recent stable release, 3.1.13.
     
  9. Jesse Norell

    Jesse Norell Well-Known Member

    I'm using the same version on debian 9 and database quotas are working there; I don't have ubuntu 14.04 to test offhand. Maybe do a quick checksum and make sure you see the same:
    Code:
    # md5sum /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php /usr/local/ispconfig/server/lib/classes/cron.d/100-monitor_database_size.inc.php 
    5ccae058c2273791dcd0d382c410968b  /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php
    f0515547b8b650221ba09fb70c7555a8  /usr/local/ispconfig/server/lib/classes/cron.d/100-monitor_database_size.inc.php
    Beyond that, it sounds like getDatabaseSize() is returning 0, so I'd try adding some debugging lines to the getDatabaseSize() function in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php and see what you might find, eg. start with:
    Code:
            public function getDatabaseSize($database_name) {
                    global $app;
    
                    require_once 'lib/mysql_clientdb.conf';
    
    $app->log("getDatabaseSize(): running query: " .
        "SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".$this->escape($database_name)."'");
                    $result = $this->_query("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".$this->escape($database_name)."'"); 
                    if(!$result) { 
                            $this->_sqlerror('Unable to determine the size of database ' . $database_name); 
                            return; 
                    } 
    $app->log("getDatabaseSize(): got result"); 
                    $database_size = $result->getAsRow(); 
                    $result->free(); 
    $app->log("getDatabaseSize(): \$database_size[0] is: " . $database_size[0]);
            return $database_size[0] ? $database_size[0] : 0;
            }
    
    You may have to similarly debug db_result::getAsResult() (same file), or 100-monitor_database_size.inc.php .. something must be different in your setup, though I don't know what offhand.
     
  10. Roberto Altravia

    Roberto Altravia New Member

    Hi Jesse,
    the md5s are the same.

    I modified db_mysql.inc.php as you said, but running cron.sh by hand doesn't output anything new:
    # /usr/local/ispconfig/server/cron.sh
    database c0xx1 size does not exceed quota: 26214400 (quota) > 0 (used)
    database c2xx2 size does not exceed quota: 104857600 (quota) > 0 (used)
    database c3xx3 size does not exceed quota: 104857600 (quota) > 0 (used)
    /usr/bin/fail2ban-client
    /sbin/iptables
    /sbin/ip6tables

    I tried looking on /var/log/ispconfig/ispconfig.log but it's empty .. is this normal ?
    On System -> Server Config I have log level set to Errors

    as a note, there is no getAsResult() in db_mysql.inc.php
    # grep -i getasresult db_mysql.inc.php
    returns nothing

    That's my first ispconfig installation, so I still miss pieces here and there
    Let me know,
    Thank you,
    Roberto
     
    Last edited: Oct 11, 2018
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    Yes, that's normal when no errors occurred.
     
  12. Jesse Norell

    Jesse Norell Well-Known Member

    IIRC the log messages would end up in cron.log, not ispconfig.log, and not on the cli. Also make sure you edited /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php, not the identical file under /usr/local/ispconfig/interface/....

    My mistake, it is getAsRow().
     
  13. Roberto Altravia

    Roberto Altravia New Member

    I edited classes/db_mysql.inc.php but
    On cron.log I have only this:
    Fri Oct 12 11:10:01 CEST 2018 database c0xxx size does not exceed quota: 26214400 (quota) > 0 (used)
    Fri Oct 12 11:10:01 CEST 2018 database c2xxx size does not exceed quota: 104857600 (quota) > 0 (used)
    Fri Oct 12 11:10:01 CEST 2018 database c3xxx size does not exceed quota: 104857600 (quota) > 0 (used)
    Fri Oct 12 11:10:01 CEST 2018 database c4xxx size does not exceed quota: 104857600 (quota) > 0 (used)
    Fri Oct 12 11:10:01 CEST 2018 finished.
    Fri Oct 12 11:10:01 CEST 2018 /usr/bin/fail2ban-client
    Fri Oct 12 11:10:01 CEST 2018 /sbin/iptables
    Fri Oct 12 11:10:01 CEST 2018 /sbin/ip6tables
    Fri Oct 12 11:11:01 CEST 2018
    Fri Oct 12 11:11:01 CEST 2018
    Fri Oct 12 11:11:01 CEST 2018 finished.

    I changed to log level -> Debug in the web panel. Let's see
     
  14. Roberto Altravia

    Roberto Altravia New Member

    Even with loglevel Debug I don't see any "getDatabaseSize(): running query"
    I have a lot of lines in both cron.log and ispconfig.log but not those

    Any clue ?
    --
    Roberto
     
  15. Jesse Norell

    Jesse Norell Well-Known Member

    As for debug messages, it looks like from the cron you have to use "print", it seems $app is not setup the same when running a cronjob. As for the issue, I actually can reproduce it (I verified the system where I thought it was working had a different db_mysql.inc.php, and the one with the right version wasn't working anymore); try this:
    Code:
            public function getDatabaseSize($database_name) {
                    global $app, $conf;
                    static $db=null;
    
                    if ( ! $db ) {
                            $clientdb_host     = ($conf['db_host']) ? $conf['db_host'] : NULL;
                            $clientdb_user     = ($conf['db_user']) ? $conf['db_user'] : NULL;
                            $clientdb_password = ($conf['db_password']) ? $conf['db_password'] : NULL;
                            $clientdb_port     = ((int)$conf['db_port']) ? (int)$conf['db_port'] : NULL;
                            $clientdb_flags    = ($conf['db_flags'] !== NULL) ? $conf['db_flags'] : NULL;
    
                            require_once 'lib/mysql_clientdb.conf';
    
                            $db = new db($clientdb_host, $clientdb_user, $clientdb_password, NULL, $clientdb_port, $clientdb_flags);
                    }
    
                    $result = $db->_query("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".$db->escape($database_name)."'");
                    if(!$result) {
                            $db->_sqlerror('Unable to determine the size of database ' . $database_name);
                            return;
                    }
                    $database_size = $result->getAsRow();
                    $result->free();
                    return $database_size[0] ? $database_size[0] : 0;
            }
    
     
    till likes this.
  16. Roberto Altravia

    Roberto Altravia New Member

Share This Page