Database size Widget

Add the following code to your widget code:

function fileSizeInfo($filesize) {
    $bytes = array('KB', 'KB', 'MB', 'GB', 'TB');

    if ($filesize < 1024) 
        $filesize = 1;

    for ($i = 0; $filesize > 1024; $i++) 
        $filesize /= 1024;

    $dbSizeInfo['size'] = round($filesize, 3);
    $dbSizeInfo['type'] = $bytes[$i];

    return $dbSizeInfo;
}

function databaseSize() {
    global $wpdb;
    $dbsize = 0;

    $rows = $wpdb->get_results("SHOW table STATUS");

    foreach($rows as $row) 
        $dbsize += $row->Data_length + $row->Index_length;

    return fileSizeInfo($dbsize); 
}

$dbSize = databaseSize();

echo "<b>Database size</b> = {$dbSize['size']} {$dbSize['type']}";