#!/usr/local/bin/perl # Show details of a disk, and slices on it use strict; use warnings; no warnings 'redefine'; no warnings 'uninitialized'; require './bsdfdisk-lib.pl'; our (%in, %text, $module_name); &ReadParse(); my $extwidth = 100; # Get the disk my @disks = &list_disks_partitions(); my ($disk) = grep { $_->{'device'} eq $in{'device'} } @disks; $disk || &error($text{'disk_egone'}); # Cache commonly used values my $device = $disk->{'device'}; my $device_url = &urlize($device); my $desc = $disk->{'desc'}; # Prefer total blocks from gpart header when available my $base_device = $disk->{'device'}; $base_device =~ s{^/dev/}{}; my $disk_structure = &get_disk_structure($base_device); my $disk_blocks = ($disk_structure && $disk_structure->{'total_blocks'}) ? $disk_structure->{'total_blocks'} : ($disk->{'blocks'} || 1000000); # Precompute a scale factor for extent image widths my $scale = $extwidth / ($disk_blocks || 1); &ui_print_header($disk->{'desc'}, $text{'disk_title'}, ""); # Debug toggle bar print "
Command: $cmd\nOutput:\n$out\n"; print "
Disk Structure:\n";
foreach my $key (sort keys %$disk_structure) {
if ($key eq 'entries') {
print "entries: [\n";
foreach my $entry (@{$disk_structure->{'entries'}}) {
print " {\n";
foreach my $k (sort keys %$entry) {
print " $k: $entry->{$k}\n";
}
print " },\n";
}
print "]\n";
} else {
print "$key: $disk_structure->{$key}\n";
}
}
print "";
print "Raw GEOM output:\n";
print &html_escape(&backquote_command("geom disk list " . "e_path($device) . " 2>/dev/null"));
print "";
print "";
my $cmd = "zpool status 2>&1";
my $out = &backquote_command($cmd);
print "Command: $cmd\nOutput:\n$out\n";
print "";
print "Partition Details Mapping:\n";
foreach my $pnum (sort { $a <=> $b } keys %part_details) {
print " $pnum: {\n";
foreach my $k (sort keys %{$part_details{$pnum}}) {
print " $k: $part_details{$pnum}->{$k}\n";
}
print " },\n";
}
print "";
print "$text{'disk_none'}
\n"; } } print &ui_links_row(\@links); # Show SMART status link if available if (&has_command("smartctl")) { print &ui_hr(); print &ui_buttons_start(); print &ui_buttons_row("smart.cgi", $text{'disk_smart'}, $text{'disk_smartdesc'}, &ui_hidden("device", $device)); print &ui_buttons_end(); } # Debug: ZFS cache detail if ($in{'debug'}) { print "Pools: " . join(", ", keys %$zfs_pools) . "\n\nDevices:\n";
foreach my $device_id (sort keys %$zfs_devices) {
next if $device_id =~ /^_debug_/;
my $device_info = $zfs_devices->{$device_id};
print "$device_id => Pool: $device_info->{'pool'}, Type: $device_info->{'vdev_type'}, Mirrored: " .
($device_info->{'is_mirrored'} ? "Yes" : "No") . ", RAIDZ: " .
($device_info->{'is_raidz'} ? "Yes (Level: $device_info->{'raidz_level'})" : "No") .
", Single: " . ($device_info->{'is_single'} ? "Yes" : "No") .
", Striped: " . ($device_info->{'is_striped'} ? "Yes" : "No") . "\n";
}
print "";
print "