=head1 NAME Disk::SMART - Provides an interface to smartctl to return disk stats and to run tests. =head1 SYNOPSIS Disk::SMART is an object oriented module that provides an interface to get SMART disk info from a device as well as initiate testing. use Disk::SMART; my $smart = Disk::SMART->new('/dev/sda', '/dev/sdb'); my $disk_health = $smart->get_disk_health('/dev/sda'); =head1 CONSTRUCTOR =head2 B Instantiates the Disk::SMART object C - Device identifier of a single SSD / Hard Drive, or a list. If no devices are supplied then it runs get_disk_list() which will return an array of detected sdX and hdX devices. my $smart = Disk::SMART->new(); my $smart = Disk::SMART->new( '/dev/sda', '/dev/sdb' ); my @disks = $smart->get_disk_list(); Returns C object if smartctl is available and can poll the given device(s). =head1 USER METHODS =head2 B Returns hash of the SMART disk attributes and values C - Device identifier of a single SSD / Hard Drive my %disk_attributes = $smart->get_disk_attributes('/dev/sda'); =head2 B Returns scalar of any listed errors C - Device identifier of a single SSD/ Hard Drive my $disk_errors = $smart->get_disk_errors('/dev/sda'); =head2 B Returns the health of the disk. Output is "PASSED", "FAILED", or "N/A". If the device has positive values for the attributes listed below then the status will output that information. Eg. "FAILED - Reported_Uncorrectable_Errors = 1" The attributes are: 5 - Reallocated_Sector_Count 187 - Reported_Uncorrectable_Errors 188 - Command_Timeout 197 - Current_Pending_Sector_Count 198 - Offline_Uncorrectable If Reported_Uncorrectable_Errors is greater than 0 then the drive should be replaced immediately. This list is taken from a study shown at https://www.backblaze.com/blog/hard-drive-smart-stats/ C - Device identifier of a single SSD / Hard Drive my $disk_health = $smart->get_disk_health('/dev/sda'); =head2 B Returns list of detected hda and sda devices. This method can be called manually if unsure what devices are present. $smart->get_disk_list; =head2 B Returns the model of the device. eg. "ST3250410AS". C - Device identifier of a single SSD / Hard Drive my $disk_model = $smart->get_disk_model('/dev/sda'); =head2 B Returns an array with the temperature of the device in Celsius and Farenheit, or N/A. C - Device identifier of a single SSD / Hard Drive my ($temp_c, $temp_f) = $smart->get_disk_temp('/dev/sda'); =head2 B Runs the SMART short self test and returns the result. C - Device identifier of SSD/ Hard Drive $smart->run_short_test('/dev/sda'); =head2 B Updates the SMART output and attributes for each device. Returns undef. C - Device identifier of a single SSD / Hard Drive or a list of devices. If none are specified then get_disk_list() is called to detect devices. $smart->update_data('/dev/sda'); =head1 COMPATIBILITY This module should run on any UNIX like OS with Perl 5.10+ and the smartctl progam installed from the smartmontools package. =head1 AUTHOR Paul Trost =head1 LICENSE AND COPYRIGHT Copyright 2015 by Paul Trost This script is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2, or at your option any later version.