function fs_get_database_size() { $fsdb =& fs_get_db_conn(); $res = $fsdb->get_results("SHOW TABLE STATUS"); if ($res === false) { return fs_db_error(); } $dbsize = 0; $tables = fs_get_tables_list(); foreach ($res as $table) { if (in_array($table->Name, $tables)) { $dbsize += $table->Data_length + $table->Index_length; } } return $dbsize; }
function fs_systest_database_test() { require_once FS_ABS_PATH . '/php/db-common.php'; $db = fs_get_db_status(); $errors = array(); if ($db['status'] == FS_DB_NOT_CONFIGURED) { $errors[] = fs_systest_error("fatal", "Database is not configured"); } else { // database is configured, we can do some serious tests. $mysql_version = fs_mysql_version(); if (!fs_mysql_newer_than("4.0.17")) { $errors[] = fs_systest_error("fatal", "Your MySQL database version is <b>{$mysql_version}</b>, FireStats requires <b>4.0.17</b> or newer"); } else { if (!fs_mysql_newer_than("4.1.14")) { $errors[] = fs_systest_error("warning", "Your MySQL database version is <b>{$mysql_version}</b>, Some features of FireStats reqruires <b>4.1.14</b> or newer"); } } if ($db['status'] != FS_DB_VALID && $db['status'] != FS_DB_NOT_CONFIGURED) { $errors[] = fs_systest_error("fatal", fs_get_database_status_message($db)); } else { $fsdb =& fs_get_db_conn(); $tables = fs_get_tables_list(); $except = array(fs_pending_date_table()); // don't check this one for InnoDB. $res = $fsdb->get_results("SHOW TABLE STATUS"); if ($res === false) { $errors[] = fs_systest_error("fatal", "Error querying database"); } else { $bad_tables = ""; $found = array(); foreach ($res as $t) { if (in_array($t->Name, $tables) === true) { $found[$t->Name] = true; if (in_array($t->Name, $except) === false) { if (isset($t->Engine) && $t->Engine != "InnoDB" || isset($t->Type) && $t->Type != "InnoDB") { if ($bad_tables == "") { $bad_tables .= $t->Name; } else { $bad_tables .= ", " . $t->Name; } } } } } foreach ($tables as $t) { if (!(isset($found[$t]) && $found[$t])) { $errors[] = fs_systest_error("fatal", "missing table <b>{$t}</b>"); } } if ($bad_tables != "") { $errors[] = fs_systest_error("fatal", "Some of your tables are not using the InnoDB engine, which is required by FireStats. wierd things may happen <b>({$bad_tables})</b>"); } } } } return $errors; }