Skip to content

Storage Module

The Storage module performs continuous analysis of the integrity and performance of hard disk drives (HDDs) and solid-state drives (SSDs), collecting S.M.A.R.T. information to identify signs of wear, imminent failures and device degradation

Lists all storage devices detected on the system.

Return:
Array of strings with the device paths

{ "/dev/sda", "/dev/sdb" }

Example:

local devices = storage.list_devices()
for _, dev in ipairs(devices) do
print(dev)
end

Returns general disk information.

Parameters:

path (string): Device path (e.g. "/dev/sda")

Return:

Table with the fields:

FieldTypeDescription
device_modelstringDisk model
model_familystringModel family (ATA only)
serial_numberstringSerial number
firmware_versionstringFirmware version
user_capacitystringTotal capacity
rotation_ratestringRPM (ATA only)
form_factorstringPhysical form factor (ATA only)
interfacestringInterface speed (ATA only)
protocolstring”ATA”, “NVMe” or “SCSI”
smart_supporttableS.M.A.R.T. support information
logical_block_sizenumberLogical block size
physical_block_sizenumberPhysical block size
nvme_versionstringNVMe version (NVMe only)

Example usage:

local info = storage.info("/dev/sda")
print(info.device_model, info.serial_number)

Returns the disk’s overall health status (S.M.A.R.T. overall-health).

Parameters:

path (string): Device path

Return:

Table with the fields:

FieldTypeDescription
passedbooleantrue if the disk passed the S.M.A.R.T. test
statusstring”PASSED” or “FAILED”
messagestringDescriptive status message

Example usage:

local h = storage.health("/dev/sda")
if h.passed then
print("Disco saudavel")
else
print("FALHA: " .. h.message)
end

Returns all the disk’s S.M.A.R.T. attributes.

Parameters:

path (string): Device path

Return:

Array of objects, each with the fields:

FieldTypeDescription
idnumberAttribute ID
namestringAttribute name (e.g.: “Temperature_Celsius”)
valuenumberNormalized value
worstnumberWorst value recorded
threshnumberFailure threshold
rawnumberRaw value (raw)
when_failedstringFailure indication
flagsstringAttribute flags

Example usage:

local attrs = storage.attributes("/dev/sda")
for _, a in ipairs(attrs) do
print(a.id, a.name, a.raw)
end

Returns a specific S.M.A.R.T. attribute by name.

Parameters:

ParameterTypeDescription
pathstringDevice path
attr_namestringAttribute name (e.g.: “Temperature_Celsius”)

Return:

The attribute object if found, nil otherwise

Example usage:

local attr = storage.attribute("/dev/sda", "Power_On_Hours")
if attr then
print("Horas ligadas:", attr.raw)
end

Returns the current disk temperature in Celsius.

Parameters:

path (string): Device path

Return:

Temperature in degrees Celsius, or nil if unavailable

Example usage:

local temp = storage.temperature("/dev/sda")
if temp then
print("Temperatura:", temp, "C")
end

Returns a summary of the disk’s error log.

Parameters:

path (string): Device path

Return:

Table or nil with the fields (varies by protocol):

FieldTypeDescription
ATA
countnumberNumber of recorded errors
logged_errorsnumberLogged errors
NVMe
sizenumberLog size
readnumberEntries read
unreadnumberUnread entries

Example usage:

local log = storage.error_log("/dev/nvme0")
if log then
print("Erros nao lidos:", log.unread)
end

Returns the result of the last disk self-test.

Parameters:

path (string): Device path

Return:

Table or nil with the fields (varies by protocol):

FieldDescription
ATAReturns the latest test from the self-tests table
NVMecurrent_self_test_operation (string): Current operation

Example usage:

local test = storage.self_test("/dev/sda")
if test then
print("Status:", test.status)
end