diff --git a/html/ops/dbinfo.php b/html/ops/dbinfo.php new file mode 100644 index 0000000000..078dee8060 --- /dev/null +++ b/html/ops/dbinfo.php @@ -0,0 +1,103 @@ +"); + +db_init(); + +admin_page_head("BOINC Database Info"); + +// if you have other db's just add more get_db_info lines +get_db_info($db_name); + +admin_page_tail(); + +function get_db_info($mydb) +{ + // Carl grabbed this from the mysql.com boards http://dev.mysql.com/doc/refman/5.0/en/show-table-status.html + + $MB = 1048576; + $KB = 1024; + + echo "
Database | $mydb |
---|
Table | Data Size | Index Size | Total size | Total Rows | Avg. Size per Row | "; + + $result = mysql_query("SHOW TABLE STATUS FROM $mydb"); + +/* SQL output + + mysql> show table status from qcnalpha; + +| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | + +*/ + + $gdata = 0; + $gindex = 0; + $gtotal = 0; + $grows = 0; + + while($myarr = mysql_fetch_assoc($result)) { + $total = $myarr["Data_length"]+$myarr["Index_length"]; + + // sum grand totals + $gdata += $myarr["Data_length"]; + $gindex += $myarr["Index_length"]; + $gtotal += $total; + $grows += $myarr["Rows"]; + + + echo "
---|---|---|---|---|---|
";
+ echo $myarr["Name"] . " | ";
+
+ echo ""; + if ( $myarr["Data_length"] < $KB) { + echo " " . $myarr["Data_length"]; + } elseif ( ($myarr["Data_length"] > $KB) && ($myarr["Data_length"] < $MB) ) { + printf("%.0fK",($myarr["Data_length"] / $KB) ); + } elseif ( $myarr["Data_length"] >= $MB) { + printf("%.2fMB",($myarr["Data_length"] / $MB) ); + } + echo " | ";
+
+ if ( $myarr["Index_length"] < $KB) {
+ echo " ".$myarr["Index_length"];
+ } elseif ( ($myarr["Index_length"] > $KB) && ($myarr["Index_length"] < $MB) ) {
+ printf("%.0fK",($myarr["Index_length"] / $KB) );
+ } elseif ( $myarr["Index_length"] >= $MB) {
+ printf("%.2fMB",($myarr["Index_length"] / $MB) );
+ }
+ echo " | ";
+
+ if ( $total < $KB) {
+ echo " ".$total;
+ } elseif ( ($total > $KB) && ($total < $MB) ) {
+ printf("%.0fK",($total / $KB) );
+ } elseif ( $total >= $MB) {
+ printf("%.2fMB",($total / $MB) );
+ }
+ echo " | "; + + echo " + " . $myarr["Rows"]." | + ".$myarr["Avg_row_length"]." |
Totals: | "; + printf("%.2fMB", $gdata); + echo " | "; + printf("%.2fMB", $gindex); + echo " | "; + printf("%.2fMB", $gtotal); + echo " | + " . $grows . " |