| 1 | package Disk::SmartTools; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use Dev::Util::Syntax; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use Dev::Util::Const; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use Dev::Util::OS qw(:all); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use Dev::Util::File qw(file_readable dir_suffix_slash); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use IPC::Cmd qw[can_run run]; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | 11 | ▶ | use YAML::PP; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | 11 | our $VERSION = version->declare("v3.4.0"); | |||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | 11 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||
| 15 | get_disk_prefix | ||||||||||||||||||||||||||||||||||
| 16 | os_disks | ||||||||||||||||||||||||||||||||||
| 17 | get_smart_cmd | ||||||||||||||||||||||||||||||||||
| 18 | get_smart_cmd_version | ||||||||||||||||||||||||||||||||||
| 19 | get_raid_cmd | ||||||||||||||||||||||||||||||||||
| 20 | get_raid_flag | ||||||||||||||||||||||||||||||||||
| 21 | get_softraidtool_cmd | ||||||||||||||||||||||||||||||||||
| 22 | get_diskutil_cmd | ||||||||||||||||||||||||||||||||||
| 23 | get_physical_disks | ||||||||||||||||||||||||||||||||||
| 24 | get_smart_disks | ||||||||||||||||||||||||||||||||||
| 25 | is_drive_smart | ||||||||||||||||||||||||||||||||||
| 26 | smart_on_for | ||||||||||||||||||||||||||||||||||
| 27 | smart_test_for | ||||||||||||||||||||||||||||||||||
| 28 | selftest_history_for | ||||||||||||||||||||||||||||||||||
| 29 | smart_cmd_for | ||||||||||||||||||||||||||||||||||
| 30 | load_local_config | ||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | 11 | our %EXPORT_TAGS = ( all => \@EXPORT_OK ); | |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | sub get_disk_prefix { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_disk_prefix: called CC=5 SCAR=28.4
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 36 | 3 | ▶ | if ( is_linux() ) { | ||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||
| 37 | 3 | return '/dev/sd'; | |||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||
| 39 | elsif ( is_mac() ) { | ||||||||||||||||||||||||||||||||||
| 40 | 0 | return '/dev/disk'; | |||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||
| 42 | elsif ( is_freebsd() ) { | ||||||||||||||||||||||||||||||||||
| 43 | 0 | return '/dev/da'; | |||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||
| 45 | elsif ( is_openbsd() ) { | ||||||||||||||||||||||||||||||||||
| 46 | 0 | return '/dev/sd'; | |||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||
| 48 | else { | ||||||||||||||||||||||||||||||||||
| 49 | 0 | croak "Operating System not supported.\n"; | |||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | sub os_disks { | ||||||||||||||||||||||||||||||||
|
Subroutine
os_disks: called CC=5 SCAR=24.7
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 54 | 1 | my $disk_prefix = get_disk_prefix(); | |||||||||||||||||||||||||||||||||
| 55 | 1 | my @disks; | |||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | if ( is_linux() ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 57 | 1 | @disks = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); | |||||||||||||||||||||||||||||||||
| 58 | 1 | return map { $disk_prefix . $_ } @disks; | |||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||
| 60 | ▶ | elsif ( is_mac() || is_freebsd() || is_openbsd() ) { | |||||||||||||||||||||||||||||||||
|
Condition0%0/6
is_mac() or is_freebsd() or is_openbsd()
is_mac() or is_freebsd()
MC/DC0%0/3
is_mac() or is_freebsd() or is_openbsd()
is_mac()
is_freebsd()
is_openbsd()
Truth table0%0/4
A or B or C
A= is_mac()B= is_freebsd()C= is_openbsd()
| |||||||||||||||||||||||||||||||||||
| 61 | 0 | @disks = qw(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15); | |||||||||||||||||||||||||||||||||
| 62 | 0 | return map { $disk_prefix . $_ } @disks; | |||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||||||||
| 65 | 0 | carp "Operating System not supported.\n"; | |||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | 2 | ▶ | sub get_smart_cmd { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_smart_cmd: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 70 | 2 | ▶ | my $cmd_path = can_run('smartctl') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 71 | or croak "smartctl command not found.\n"; | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | 0 | return $cmd_path; | |||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub get_smart_cmd_version { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_smart_cmd_version: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 77 | 0 | my $smart_cmd = get_smart_cmd(); | |||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||
| 79 | 0 | my $version; | |||||||||||||||||||||||||||||||||
| 80 | 0 | $smart_cmd .= ' --version'; | |||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($smart_cmd) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 82 | 0 | my $buf; | |||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 84 | scalar run( | ||||||||||||||||||||||||||||||||||
| 85 | command => $smart_cmd, | ||||||||||||||||||||||||||||||||||
| 86 | verbose => 0, | ||||||||||||||||||||||||||||||||||
| 87 | buffer => \$buf, | ||||||||||||||||||||||||||||||||||
| 88 | timeout => 10 | ||||||||||||||||||||||||||||||||||
| 89 | ) | ||||||||||||||||||||||||||||||||||
| 90 | ) | ||||||||||||||||||||||||||||||||||
| 91 | { | ||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ( $buf =~ m|^smartctl\s+(\d+\.\d+)| ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 93 | 0 | $version = $1; | |||||||||||||||||||||||||||||||||
| 94 | 0 | return $version; | |||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||
| 98 | 0 | return; | |||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||
| 101 | 1 | ▶ | sub get_raid_cmd { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_raid_cmd: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 102 | my $cmd_path = can_run('lspci') | ||||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | or do { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 104 | ## carp "lspci command not found.\n"; | ||||||||||||||||||||||||||||||||||
| 105 | 1 | return; | |||||||||||||||||||||||||||||||||
| 106 | }; | ||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||
| 108 | 0 | my $raid_cmd = "$cmd_path -nnd ::0104"; | |||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||
| 110 | 0 | return $raid_cmd; | |||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | # 03:00.0 RAID bus controller [0104]: Broadcom / LSI MegaRAID SAS 2108 [Liberator] [1000:0079] (rev 04) | ||||||||||||||||||||||||||||||||||
| 113 | # 06:00.0 RAID bus controller [0104]: HighPoint Technologies, Inc. RocketRAID 2722 [1103:2722] (rev c3) | ||||||||||||||||||||||||||||||||||
| 114 | # /usr/sbin/smartctl --health /dev/sda -d hpt,1/1/1 | ||||||||||||||||||||||||||||||||||
| 115 | # /usr/sbin/smartctl --health /dev/sdc -d sat+megaraid,00 | ||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub get_raid_flag { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_raid_flag: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 119 | 0 | my $raid_cmd = get_raid_cmd(); | |||||||||||||||||||||||||||||||||
| 120 | 0 | my $buf; | |||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if ( defined $raid_cmd ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 123 | 0 | scalar run( | |||||||||||||||||||||||||||||||||
| 124 | command => $raid_cmd, | ||||||||||||||||||||||||||||||||||
| 125 | verbose => 0, | ||||||||||||||||||||||||||||||||||
| 126 | buffer => \$buf, | ||||||||||||||||||||||||||||||||||
| 127 | timeout => 10, | ||||||||||||||||||||||||||||||||||
| 128 | ); | ||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ( $buf =~ m{ HighPoint }i ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 131 | 0 | return ' -d hpt,'; | |||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ( $buf =~ m{ MegaRAID }i ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 135 | 0 | return ' -d sat+megaraid,'; | |||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||
| 138 | 0 | return; | |||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub get_softraidtool_cmd { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_softraidtool_cmd: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 142 | my $cmd_path = can_run('softraidtool') | ||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 144 | ## carp "softraidtool command not found.\n"; | ||||||||||||||||||||||||||||||||||
| 145 | 0 | return; | |||||||||||||||||||||||||||||||||
| 146 | }; | ||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||
| 148 | 0 | return $cmd_path; | |||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub get_diskutil_cmd { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_diskutil_cmd: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 152 | my $cmd_path = can_run('diskutil') | ||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 154 | ## carp "diskutil command not found.\n"; | ||||||||||||||||||||||||||||||||||
| 155 | 0 | return; | |||||||||||||||||||||||||||||||||
| 156 | }; | ||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | 0 | return $cmd_path; | |||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub get_physical_disks { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_physical_disks: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 162 | 0 | my $diskutil_cmd = get_diskutil_cmd(); | |||||||||||||||||||||||||||||||||
| 163 | 0 | my @disks; | |||||||||||||||||||||||||||||||||
| 164 | 0 | Readonly my $PHYSICAL_DISK => qr{^(/dev/disk\d+)}i; | |||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||
| 166 | 0 | $diskutil_cmd .= ' list physical'; | |||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if ($diskutil_cmd) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 168 | 0 | my $buf; | |||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 170 | scalar run( | ||||||||||||||||||||||||||||||||||
| 171 | command => $diskutil_cmd, | ||||||||||||||||||||||||||||||||||
| 172 | verbose => 0, | ||||||||||||||||||||||||||||||||||
| 173 | buffer => \$buf, | ||||||||||||||||||||||||||||||||||
| 174 | timeout => 10 | ||||||||||||||||||||||||||||||||||
| 175 | ) | ||||||||||||||||||||||||||||||||||
| 176 | ) | ||||||||||||||||||||||||||||||||||
| 177 | { | ||||||||||||||||||||||||||||||||||
| 178 | 0 | foreach my $line ( split( /\n/, $buf ) ) { | |||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ( $line =~ $PHYSICAL_DISK ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 180 | 0 | my $disk = $1; | |||||||||||||||||||||||||||||||||
| 181 | 0 | push @disks, $disk; | |||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||
| 183 | } #foreach | ||||||||||||||||||||||||||||||||||
| 184 | } #if run | ||||||||||||||||||||||||||||||||||
| 185 | 0 | return @disks; | |||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||
| 187 | 0 | return; | |||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub get_smart_disks { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_smart_disks: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 192 | 0 | my (@disks) = @_; | |||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||
| 194 | 0 | my @smart_disks = grep { is_drive_smart($_) } @disks; | |||||||||||||||||||||||||||||||||
| 195 | 0 | return @smart_disks; | |||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||
| 198 | 1 | ▶ | sub is_drive_smart { | ||||||||||||||||||||||||||||||||
|
Subroutine
is_drive_smart: called CC=8 SCAR=35.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 199 | 1 | my ($disk) = @_; | |||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||
| 201 | 1 | ▶ | return 0 unless ( defined $disk ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||
| 203 | 1 | Readonly my $IS_AVAILABLE_re => qr{SMART support is: Available}i; | |||||||||||||||||||||||||||||||||
| 204 | 1 | Readonly my $START_OF_INFO_re => qr{START OF INFORMATION SECTION}i; | |||||||||||||||||||||||||||||||||
| 205 | 1 | Readonly my $OP_NOT_SUPPORTED_re => qr{Operation not supported by device}i; | |||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||
| 207 | 1 | my $smart_cmd = get_smart_cmd(); | |||||||||||||||||||||||||||||||||
| 208 | 0 | $smart_cmd .= ' --info ' . $disk; | |||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ($smart_cmd) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 210 | 0 | my $buf; | |||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 212 | scalar run( | ||||||||||||||||||||||||||||||||||
| 213 | command => $smart_cmd, | ||||||||||||||||||||||||||||||||||
| 214 | verbose => 0, | ||||||||||||||||||||||||||||||||||
| 215 | buffer => \$buf, | ||||||||||||||||||||||||||||||||||
| 216 | timeout => 10 | ||||||||||||||||||||||||||||||||||
| 217 | ) | ||||||||||||||||||||||||||||||||||
| 218 | ) | ||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||
| 220 | 0 | foreach my $line ( split( /\n/, $buf ) ) { | |||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ( ( $line =~ $IS_AVAILABLE_re ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$line =~ /$IS_AVAILABLE_re/u or $line =~ /$START_OF_INFO_re/u
MC/DC0%0/2
$line =~ /$IS_AVAILABLE_re/u or $line =~ /$START_OF_INFO_re/u
$line =~ /$IS_AVAILABLE_re/u
$line =~ /$START_OF_INFO_re/u
Truth table0%0/3
A or B
A= $line =~ /$IS_AVAILABLE_re/uB= $line =~ /$START_OF_INFO_re/u
| |||||||||||||||||||||||||||||||||||
| 222 | || ( $line =~ $START_OF_INFO_re ) ) | ||||||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||||
| 224 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | if ( $line =~ $OP_NOT_SUPPORTED_re ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 227 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||
| 229 | } #foreach | ||||||||||||||||||||||||||||||||||
| 230 | } #if run | ||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||
| 232 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||
| 235 | # args: $cmd_path, $disk | ||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub smart_on_for { | ||||||||||||||||||||||||||||||||
|
Subroutine
smart_on_for: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 237 | 0 | my ($arg_ref) = @_; | |||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||
| 239 | 0 | my $cmd = $arg_ref->{ cmd_path } . ' --smart=on ' . $arg_ref->{ disk }; | |||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | unless ( ipc_run_e( { cmd => $cmd, timeout => 10 } ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 241 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||
| 243 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | sub smart_test_for { | ||||||||||||||||||||||||||||||||
|
Subroutine
smart_test_for: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 247 | 0 | my ($arg_ref) = @_; | |||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||
| 249 | my $cmd | ||||||||||||||||||||||||||||||||||
| 250 | = $arg_ref->{ cmd_path } | ||||||||||||||||||||||||||||||||||
| 251 | . ' --test=' | ||||||||||||||||||||||||||||||||||
| 252 | . $arg_ref->{ test_type } . ' ' | ||||||||||||||||||||||||||||||||||
| 253 | 0 | . $arg_ref->{ disk }; | |||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | unless ( ipc_run_e( { cmd => $cmd, timeout => 10 } ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 256 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||
| 258 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub selftest_history_for { | ||||||||||||||||||||||||||||||||
|
Subroutine
selftest_history_for: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 262 | 0 | my ($arg_ref) = @_; | |||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | $arg_ref->{ debug } ||= 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg_ref->{"debug"} ||= 0
MC/DC0%0/1
$arg_ref->{"debug"} ||= 0
$arg_ref->{"debug"}
Truth table0%0/2
A
A= $arg_ref->{"debug"}
| |||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||
| 265 | 0 | my $cmd = $arg_ref->{ cmd_path } . ' -l selftest ' . $arg_ref->{ disk }; | |||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if ( my @buf = ipc_run_c( { cmd => $cmd, debug => $arg_ref->{ debug } } ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 268 | 0 | return \@buf; | |||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||
| 270 | 0 | return; | |||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | sub smart_cmd_for { | ||||||||||||||||||||||||||||||||
|
Subroutine
smart_cmd_for: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 274 | 0 | my ($arg_ref) = @_; | |||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | $arg_ref->{ debug } ||= 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg_ref->{"debug"} ||= 0
MC/DC0%0/1
$arg_ref->{"debug"} ||= 0
$arg_ref->{"debug"}
Truth table0%0/2
A
A= $arg_ref->{"debug"}
| |||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||
| 277 | my $cmd | ||||||||||||||||||||||||||||||||||
| 278 | 0 | = $arg_ref->{ cmd_path } . $arg_ref->{ cmd_type } . $arg_ref->{ disk }; | |||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ( my @buf = ipc_run_c( { cmd => $cmd, debug => $arg_ref->{ debug } } ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 281 | 0 | return \@buf; | |||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||
| 283 | 0 | return; | |||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||
| 286 | 3 | ▶ | sub load_local_config { | ||||||||||||||||||||||||||||||||
|
Subroutine
load_local_config: called CC=5 SCAR=17.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 287 | 3 | ▶ | my $hostname = shift || $EMPTY_STR; | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
shift() || $Disk::SmartTools::EMPTY_STR
MC/DC0%0/2
shift() || $Disk::SmartTools::EMPTY_STR
shift()
$Disk::SmartTools::EMPTY_STR
Truth table33%1/3
A || B
A= shift()B= $Disk::SmartTools::EMPTY_STR
| |||||||||||||||||||||||||||||||||||
| 288 | 3 | my $filename = dir_suffix_slash( $ENV{ HOME } ) . '.smarttoolsrc.yml'; | |||||||||||||||||||||||||||||||||
| 289 | 3 | my $local_config_ref = {}; | |||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | if ( !file_readable($filename) ) { return; } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||
| 293 | 3 | my $ypp = YAML::PP->new; | |||||||||||||||||||||||||||||||||
| 294 | 3 | my $host_configs_ref = $ypp->load_file($filename); | |||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||
| 296 | 3 | ▶ | if ( defined $host_configs_ref->{ $hostname } ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 297 | 3 | foreach my $key ( keys %{ $host_configs_ref->{ $hostname } } ) { | |||||||||||||||||||||||||||||||||
| 298 | 11 | $local_config_ref->{ $key } = $host_configs_ref->{ $hostname }->{ $key }; | |||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||
| 301 | 3 | return $local_config_ref; | |||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||
| 304 | 11 | 1; # End of Disk::SmartTools | |||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||
| 306 | =pod | ||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||
| 308 | =encoding utf-8 | ||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||
| 310 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||
| 312 | Disk::SmartTools - Provide tools to work with disks via S.M.A.R.T. | ||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||
| 314 | =head1 VERSION | ||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||
| 316 | Version v3.4.0 | ||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||
| 318 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||
| 320 | Provides disk related functions. | ||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||
| 322 | use Disk::SmartTools; | ||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||
| 324 | my $cmd_path = get_smart_cmd(); | ||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||
| 327 | ... | ||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||
| 329 | =head1 EXPORT | ||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||
| 331 | get_disk_prefix | ||||||||||||||||||||||||||||||||||
| 332 | os_disks | ||||||||||||||||||||||||||||||||||
| 333 | get_smart_cmd | ||||||||||||||||||||||||||||||||||
| 334 | get_smart_cmd_version | ||||||||||||||||||||||||||||||||||
| 335 | get_raid_cmd | ||||||||||||||||||||||||||||||||||
| 336 | get_raid_flag | ||||||||||||||||||||||||||||||||||
| 337 | get_diskutil_cmd | ||||||||||||||||||||||||||||||||||
| 338 | get_physical_disks | ||||||||||||||||||||||||||||||||||
| 339 | get_smart_disks | ||||||||||||||||||||||||||||||||||
| 340 | is_drive_smart | ||||||||||||||||||||||||||||||||||
| 341 | get_softraidtool_cmd | ||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||
| 343 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||
| 345 | =head2 B<get_disk_prefix()> | ||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||
| 347 | Returns the proper disk prefix depending on the OS: C</dev/sd> for linux, C</dev/disk> for macOS. | ||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||
| 349 | my $disk_prefix = get_disk_prefix(); | ||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||
| 351 | =head2 B<os_disks()> | ||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||
| 353 | Returns a list of possible disks based on OS, prefixed by get_disk_prefix(). | ||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||
| 355 | I<Should parse diskutil on macs and lsblk on linux for more accuracy.> | ||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||
| 357 | my @disks = os_disks(); | ||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||
| 359 | =head2 B<get_smart_cmd()> | ||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||
| 361 | Find the path to smartctl or quit. | ||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||
| 363 | my $smart_cmd = get_smart_cmd(); | ||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||
| 365 | =head2 B<get_smart_cmd_version()> | ||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||
| 367 | Find the version of smartctl or return undef. | ||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||
| 369 | my $smart_cmd_version = get_smart_cmd_version(); | ||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||
| 371 | =head2 B<get_raid_cmd()> | ||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||
| 373 | Find the path to lspci or return undef. | ||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||
| 375 | my $raid_cmd = get_raid_cmd(); | ||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||
| 377 | =head2 B<get_raid_flag()> | ||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||
| 379 | Find the raid flag for use with the current RAID. Currently supports Highpoint and MegaRAID controllers. | ||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||
| 381 | my $raid_flag = get_raid_flag(); | ||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||
| 383 | =head2 B<get_softraidtool_cmd()> | ||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||
| 385 | Find the path to softraidtool or return undef. | ||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||
| 387 | my $softraid_cmd = get_softraidtool_cmd(); | ||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||
| 389 | =head2 B<get_diskutil_cmd()> | ||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||
| 391 | On MacOS, find the path to diskutil or return undef. | ||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||
| 393 | my $diskutil_cmd = get_diskutil_cmd(); | ||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||
| 395 | =head2 B<get_physical_disks()> | ||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||
| 397 | On MacOS, find the physical disks (not synthesized or disk image) | ||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||
| 399 | my @disks = get_physical_disks(); | ||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||
| 401 | =head2 B<get_smart_disks(@disks)> | ||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||
| 403 | Given a list of disks, find all disks that support SMART and return as a list | ||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||
| 405 | my @smart_disks = get_smart_disks(@disks); | ||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||
| 407 | =head2 B<is_drive_smart($disk)> | ||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||
| 409 | Test if a disk supports SMART | ||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||
| 411 | my $drive_is_smart = is_drive_smart($disk); | ||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||
| 413 | =head2 B<smart_on_for($disk)> | ||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||
| 415 | Test is SMART is enabled for a disk | ||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||
| 417 | my $smart_enabled = smart_on_for($disk); | ||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||
| 419 | =head2 B<smart_test_for> | ||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||
| 421 | Run smart test on a disk, specify test_type (short, long) | ||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||
| 423 | $smart_test_started = smart_test_for($disk); | ||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||
| 425 | =head2 B<selftest_history_for> | ||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||
| 427 | Show the self-test history for a disk | ||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||
| 429 | selftest_history_for($disk); | ||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||
| 431 | =head2 B<smart_cmd_for> | ||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||
| 433 | Run a smart command for a disk | ||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||
| 435 | my $return_buffer_ref | ||||||||||||||||||||||||||||||||||
| 436 | = smart_cmd_for( | ||||||||||||||||||||||||||||||||||
| 437 | { cmd_path => $cmd_path, | ||||||||||||||||||||||||||||||||||
| 438 | cmd_type => $cmd_type, | ||||||||||||||||||||||||||||||||||
| 439 | disk => $current_disk | ||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||
| 441 | ); | ||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||
| 443 | =head2 B<load_local_config(HOSTNAME)> | ||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||
| 445 | Load host local disk configuration from F<$HOME/.smarttools.yml> if it exists. | ||||||||||||||||||||||||||||||||||
| 446 | This allows for manual configuration in the case where the automatic detection | ||||||||||||||||||||||||||||||||||
| 447 | of disks is not precise. | ||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||
| 449 | C<HOSTNAME> host name specified in configuration file. | ||||||||||||||||||||||||||||||||||
| 450 | Allows a single configuration file to be deployed with multiple host's configurations. | ||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||
| 452 | my $local_config_ref = load_local_config($hostname); | ||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||
| 454 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||
| 456 | Two example programs demonstrate how the `Disk::SmartTools` modules can be used. | ||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||
| 458 | =head2 smart_show.pl | ||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||
| 460 | Display SMART information on disks. | ||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||
| 462 | $ smart_show.pl | ||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||
| 464 | Asks for the type of SMART information to display then reports for each | ||||||||||||||||||||||||||||||||||
| 465 | physical disk in the system. | ||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||
| 467 | Display SMART information | ||||||||||||||||||||||||||||||||||
| 468 | -------------------------- | ||||||||||||||||||||||||||||||||||
| 469 | Choose attribute to display: | ||||||||||||||||||||||||||||||||||
| 470 | a. All SMART Info | ||||||||||||||||||||||||||||||||||
| 471 | b. Info | ||||||||||||||||||||||||||||||||||
| 472 | c. Overall-Health | ||||||||||||||||||||||||||||||||||
| 473 | d. SelfTest History | ||||||||||||||||||||||||||||||||||
| 474 | e. Error Log | ||||||||||||||||||||||||||||||||||
| 475 | f. Temperature Graph | ||||||||||||||||||||||||||||||||||
| 476 | g. Power_On_Hours | ||||||||||||||||||||||||||||||||||
| 477 | h. Power_Cycle_Count | ||||||||||||||||||||||||||||||||||
| 478 | i. Temperature_Celsius | ||||||||||||||||||||||||||||||||||
| 479 | j. Reallocated_Sector_Ct | ||||||||||||||||||||||||||||||||||
| 480 | k. Offline_Uncorrectable | ||||||||||||||||||||||||||||||||||
| 481 | l. Raw_Read_Error_Rate | ||||||||||||||||||||||||||||||||||
| 482 | m. Seek_Error_Rate | ||||||||||||||||||||||||||||||||||
| 483 | n. Reported_Uncorrect | ||||||||||||||||||||||||||||||||||
| 484 | o. Command_Timeout | ||||||||||||||||||||||||||||||||||
| 485 | p. Current_Pending_Sector | ||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||
| 487 | B<Must be run as root.> | ||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||
| 489 | =head2 smart_run_tests.pl | ||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||
| 491 | Runs a SMART test on all disks. Typically run as a crontab. | ||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||
| 493 | $ smart_run_tests.pl <args> | ||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||
| 495 | --test_type : Length of SMART test, short (default) or long | ||||||||||||||||||||||||||||||||||
| 496 | --dry_run : Don't actually perform SMART test | ||||||||||||||||||||||||||||||||||
| 497 | --debug : Turn debugging on | ||||||||||||||||||||||||||||||||||
| 498 | --verbose : Generate debugging info on stderr | ||||||||||||||||||||||||||||||||||
| 499 | --silent : Do not print report on stdout | ||||||||||||||||||||||||||||||||||
| 500 | --help : This helpful information. | ||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||
| 502 | B<Must be run as root.> | ||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||
| 504 | =head3 Crontabs | ||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||
| 506 | Usually run as a crontab. Note the C<--long> option is safe to run everyday, it | ||||||||||||||||||||||||||||||||||
| 507 | will only run the long test on (up to) one disk a day. By hashing the day of | ||||||||||||||||||||||||||||||||||
| 508 | the month with the disk index it will run once a month for each disk. | ||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||
| 510 | =over 4 | ||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||
| 512 | =item 30 5 * * * : S.M.A.R.T. disk checks - short ; /var/root/bin/smart_run_tests.pl | ||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||
| 514 | Z<> | ||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||
| 516 | =item 4 6 * * * : S.M.A.R.T. disk checks - long ; /var/root/bin/smart_run_tests.pl --test_type=long | ||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||
| 518 | =back | ||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||
| 520 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||
| 522 | Matt Martini, C<< <matt at imaginarywave.com> >> | ||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||
| 524 | =head1 BUGS | ||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||
| 526 | Please report any bugs or feature requests to C<bug-disk-smarttools at rt.cpan.org>, or through | ||||||||||||||||||||||||||||||||||
| 527 | the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Disk-SmartTools>. I will be notified, and then you'll | ||||||||||||||||||||||||||||||||||
| 528 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||
| 530 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||
| 532 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||
| 534 | perldoc Disk::SmartTools | ||||||||||||||||||||||||||||||||||
| 535 | perldoc smart_show.pl | ||||||||||||||||||||||||||||||||||
| 536 | perldoc smart_run_test.pl | ||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||
| 538 | You can also look for information at: | ||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||
| 540 | =over 4 | ||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||
| 542 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||
| 544 | L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Disk-SmartTools> | ||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||
| 546 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||
| 548 | L<https://cpanratings.perl.org/d/Disk-SmartTools> | ||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||
| 550 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||
| 552 | L<https://metacpan.org/release/Disk-SmartTools> | ||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||
| 554 | =back | ||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||
| 556 | =head1 ACKNOWLEDGMENTS | ||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||
| 558 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||
| 560 | This software is Copyright © 2024-2025 by Matt Martini. | ||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||
| 562 | This is free software, licensed under: | ||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||
| 564 | The GNU General Public License, Version 3, June 2007 | ||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||
| 566 | =cut | ||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||
| 568 | __END__ | ||||||||||||||||||||||||||||||||||