• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Script to show stats from smartctl for a pool

zfs123

n00b
Joined
Jul 3, 2012
Messages
20
Just something I whipped together to get some information from my new drives. It's basically just a perl reformat of smartctl output:

Code:
root@WKMMG3:~# ./nsdisks.pl mp2
Pool Name: mp2
DISK    VDEV     MODEL               FIRMWARE    PORC    LCC     TEMP
============================================================================
c6t6d0  raidz1-0 HD204UI             1AQ10001    0       49      21
c7t2d0  raidz1-0 WD20EARX-00PASB0    51.0AB51    12      539     23
c6t7d0  raidz1-0 HD204UI             1AQ10001    0       50      22
c7t4d0  raidz1-0 WD20EARX-00PASB0    51.0AB51    161     25599   23
c7t0d0  raidz1-0 ST32000542AS        CC95                        26
c6t4d0  raidz1-1 HD204UI             1AQ10001    0       50      21
c7t7d0  raidz1-1 WD20EARX-00PASB0    51.0AB51    12      521     23
c6t0d0  raidz1-1 HD204UI             1AQ10001    0       52      21
c7t6d0  raidz1-1 WD20EARX-00PASB0    51.0AB51    12      513     23
c6t2d0  raidz1-1 HD204UI             1AQ10001    0       52      22

And here's the code, any comments/suggestions welcome:

Code:
#!/usr/bin/perl

my $pool = shift || die "please specify pool name\n";
my $ZCMD = "/usr/sbin/zpool status $pool";
my $CMD = "/usr/sbin/smartctl -d sat,12 -a /dev/rdsk/";

my @Disk_List = ();

my @result = `$ZCMD 2>&1`;

foreach (@result) {

        chop;

        my $l = $_;

        next if(!($l =~ /^\t/));
        next if($l =~ /^\tNAME/);
        next if($l =~ /^\t${pool}\s/);
        next if(!($l));

        $l =~ s/\t  //;
        $l =~ s/^\s+//;
        $l =~ s/\s+/ /g;

        my ($disk, $status, $read, $write, $chksum) = split('\s', $l);

        if($disk =~ /c[0-9]t[0-9]d[0-9]/) {     # wont work with ctd's higher than 9
                $l = "$vdev" . "_" . "$disk";
                push(@Disk_List, $l);
        }
        else {
                $vdev = $disk;
        }
}

print "Pool Name: $pool\n";
printf("%-8s%-9s%-20s%-12s%-8s%-8s%s\n", "DISK", "VDEV", "MODEL", "FIRMWARE", "PORC", "LCC", "TEMP");
print "============================================================================\n";

foreach $line (@Disk_List) {

  my ($vdev, $disk) = split('_', $line);
  #my $porc, $temp, $lcc, $firm, $model = "";
  my $porc = "";
  my $temp = "";
  my $lcc = "";
  my $firm = "";
  my $model = "";

  my $tcmd = "$CMD" . "$disk";
  my @result = `$tcmd 2>&1`;

  printf("%-8s%-9s", $disk, $vdev);

  foreach (@result) {
        chop;
        $l = $_;
        $l =~ s/^\s+//;

        my @arr = split /\s+/, $l;

        if($l =~ /Firmware Version/) {
                my $fw = $l;
                $fw =~ s/^.*\s+//;
                $firm = $fw;
        }
        elsif($l =~ /Device Model/) {
                my $fw = $l;
                $fw =~ s/^.*\s+//;
                $model = $fw;
        }
        elsif($l =~ /Power-Off_Retract_Count/) {
                $porc = $arr[9];
        }
        elsif($l =~ /Load_Cycle_Count/) {
                $lcc = $arr[9];
        }
        elsif($l =~ /Temperature_Celsius/) {
                $temp = $arr[9];
        }
  }

  printf("%-20s", $model);
  printf("%-12s", $firm);
  printf("%-8s", $porc);
  printf("%-8s", $lcc);
  printf("%-8s", $temp);
  print "\n";
}
 
Back
Top