function _prod_check_dbstatus_mysql in Production check & Production monitor 6
Same name and namespace in other branches
- 7 includes/prod_check.admin.inc \_prod_check_dbstatus_mysql()
Helper function to return MySQL status info.
1 call to _prod_check_dbstatus_mysql()
- prod_check_dbstatus in includes/
prod_check.admin.inc - Database status page.
File
- includes/
prod_check.admin.inc, line 811
Code
function _prod_check_dbstatus_mysql($db_type, $db_name, $details) {
// Set title & version.
// mysql_get_server_info() or mysqli_get_server_info()
$server = call_user_func($db_type . '_get_server_info');
$title = t('Running @db @version', array(
'@db' => 'MySQL',
'@version' => $server,
));
// Get basic status.
// mysql_stat or mysqli_stat()
$status = call_user_func($db_type . '_stat');
if (is_array($status)) {
$status = implode("<br />\n", $status);
}
else {
$status = str_replace(' ', "<br />\n", $status);
}
// Get additional status.
// mysql_get_client_info() or mysqli_get_client_info()
$client_info = call_user_func($db_type . '_get_client_info');
// mysql_get_host_info() or mysqli_get_host_info()
$host_info = call_user_func($db_type . '_get_host_info');
// mysql_get_host_info() or mysqli_get_host_info()
$protocol_version = call_user_func($db_type . '_get_proto_info');
$additional = "Client version: {$client_info}<br />\n";
$additional .= "Host info: {$host_info}<br />\n";
$additional .= "Protocol version: {$protocol_version}<br />\n";
$additional .= t('For a summary, check the Drupal core <a href="!link">sql status page</a>.', array(
'!link' => url('admin/reports/status/sql'),
)) . "<br /><br />\n";
$status = $additional . $status;
// Get detailed status.
$rows = array();
try {
$result = db_query('SHOW STATUS');
while ($row = db_fetch_object($result)) {
$rows[] = array(
$row->Variable_name,
$row->Value,
);
}
} catch (Exception $e) {
}
if ($rows) {
$details['status'] = array(
'title' => t('Detailed status'),
'header' => array(
t('Variable'),
t('Value'),
),
'rows' => $rows,
);
}
// Get all tables.
$rows = array();
try {
$result = db_query('SHOW TABLES FROM %s', $db_name);
$property = 'Tables_in_' . $db_name;
while ($row = db_fetch_object($result)) {
$rows[] = array(
$row->{$property},
);
}
} catch (Exception $e) {
}
if ($rows) {
$details['tables'] = array(
'title' => t('Tables for active database %name', array(
'%name' => $db_name,
)),
'header' => array(
t('Table'),
),
'rows' => $rows,
);
}
// Get all databases.
$rows = array();
try {
$result = db_query('SHOW DATABASES');
while ($row = db_fetch_object($result)) {
$rows[] = array(
$row->Database,
);
}
} catch (Exception $e) {
}
if ($rows) {
$details['databases'] = array(
'title' => t('Available databases'),
'header' => array(
t('Database'),
),
'rows' => $rows,
);
}
return theme('prod_check_dbstatus', $title, $status, $details);
}