<%doc> Table Information <%attr> title => 'Table Information' section => 'Reports' <%init> my $DEBUG = 0; my $netdot; <%perl> my (@headers, @rows) = (); @headers = ( 'Table', 'Rows', 'Data Length', 'Index Length', 'Max Data Length', 'Data Free', 'Create Time', 'Update Time', 'Comment' ); my $dbh = Netdot::Model->db_Main; my $q = $dbh->prepare("SHOW TABLE STATUS"); $q->execute(); my $data_sum; my $index_sum; my $free_sum; my $data_data_sum; my $data_index_sum; my $data_free_sum; my $history_data_sum; my $history_index_sum; my $history_free_sum; while ( my ($name, $engine, $version, $row_format, $rows, $avg_row_len, $data_len, $max_data_len, $index_len, $data_free, $auto_increment, $create_time, $update_time, $check_time, $collation, $checksum, $create_options, $comment) = $q->fetchrow_array() ) { my @row = (); push( @row, $name ); push( @row, $rows ); push( @row, $ui->format_size($data_len) ); push( @row, $ui->format_size($index_len) ); push( @row, $ui->format_size($max_data_len) ); push( @row, $ui->format_size($data_free) ); push( @row, $create_time ); push( @row, $update_time ); push( @row, $comment ); push( @rows, \@row ); $data_sum += $data_len; $index_sum += $index_len; $free_sum += $data_free; if( substr($name, -8) eq "_history" ) { $history_data_sum += $data_len; $history_index_sum += $index_len; $history_free_sum += $data_free; } else { $data_data_sum += $data_len; $data_index_sum += $index_len; $data_free_sum += $data_free; } } { my @row = (); push( @row, "Total Size:" ); push( @row, " " ); push( @row, "".$ui->format_size($data_sum)."" ); push( @row, "".$ui->format_size($index_sum)."" ); push( @row, " " ); push( @row, "".$ui->format_size($free_sum)."" ); push( @row, " " ); push( @row, " " ); push( @row, " " ); push( @rows, \@row ); } { my @row = (); push( @row, "Size of Data:" ); push( @row, " " ); push( @row, $ui->format_size($data_data_sum) ); push( @row, $ui->format_size($data_index_sum) ); push( @row, " " ); push( @row, $ui->format_size($data_free_sum) ); push( @row, " " ); push( @row, " " ); push( @row, " " ); push( @rows, \@row ); } { my @row = (); push( @row, "Size of History:" ); push( @row, " " ); push( @row, $ui->format_size($history_data_sum) ); push( @row, $ui->format_size($history_index_sum) ); push( @row, " " ); push( @row, $ui->format_size($history_free_sum) ); push( @row, " " ); push( @row, " " ); push( @row, " " ); push( @rows, \@row ); }
Table Information
<& //generic/data_table.mhtml, field_headers=>\@headers, data=>\@rows &>