NAME
Monitoring::Sneck::Checks::smart - checks disk health through smartctl
VERSION
Version 0.0.1
SYNOPSIS
smart|perl:smart
smart_no_usb|perl:smart -e '^/dev/sd[f-z]'
smart_raid|perl:smart -d /dev/bus/0,megaraid,0 -d /dev/bus/0,megaraid,1
smart_hot|perl:smart --temp-warning 50 --temp-critical 60
DESCRIPTION
Checks disks through smartctl -j -a -n standby, which needs to be smartmontools 7.0 or newer for its JSON output. Without --device, the disks are those smartctl --scan-open finds.
- CRITICAL :: The disk failing its SMART health check. A ATA attribute failing now. A NVMe critical warning other than temperature. Bad sectors or media errors over --critical. Wear or temperature over their critical.
- WARNING :: Bad sectors or media errors over --warning. The last ATA self test failing. The NVMe temperature warning. Wear or temperature over their warning.
- UNKNOWN :: smartctl not being there, a disk that can not be opened, or smartctl not returning JSON.
- OK :: Everything else, including disks in standby, which are left asleep, disks without SMART, and finding no disks, so the same check can go everywhere.
Bad sectors and media errors are added up for --warning and --critical, from...
- ATA :: Reallocated_Sector_Ct (5), Current_Pending_Sector (197), and Offline_Uncorrectable (198).
- NVMe :: Media errors.
- SCSI :: The grown defect list and uncorrected read, write, and verify errors.
Wear is the NVMe percentage used, or the SCSI percentage used endurance indicator. ATA disks have none that is not vendor specific.
A line for each disk follows the status line, with its model, serial, temperature, wear, and counts.
This needs root, to open the disks.
OPTIONS
- -d, --device :: A disk to check instead of scanning, such as /dev/sda. A smartctl device type may follow after a comma, such as /dev/bus/0,megaraid,0 or /dev/sda,sat. May be given more than once.
- -e, --exclude :: A regex for scanned disks to skip, matched against the name, such as ^/dev/sdf. May be given more than once.
- -w, --warning :: Range for bad sectors and media errors. Default :: 0
- -c, --critical :: Range for bad sectors and media errors.
- --wear-warning :: Range for wear, in percent. Default :: 80
- --wear-critical :: Range for wear, in percent. Default :: 90
- --temp-warning :: Range for temperature, in Celsius.
- --temp-critical :: Range for temperature, in Celsius.
METHODS
check
Does the check.
device_status
Runs smartctl -j -a -n standby on a disk and works out how it is.
- smartctl :: The path to smartctl.
- device :: Hash ref of name, such as /dev/sda, type, a smartctl device type or undef, and open_error, what smartctl --scan-open said when it could not open it, if it could not.
Returns the code, what to say about the disk in the status line, undef if it is fine, and the line about it for after the status line, undef if smartctl said nothing useful.
my ( $code, $says, $detail ) = $check->device_status( '/usr/sbin/smartctl', { name => '/dev/sdb' } );
# ( 1, 'sdb 8 pending, 2 reallocated', 'sdb WDC WD40EFRX-68N32N0, S/N WD-WCC7K0000001, 36 C, ...' )