Simplified smartd configuration management with Puppet.
include smartdand confgure e-mail nofifications for all disks:
smartd::defaults: '-a -m root@domain.org'this would generate a smartd.conf based on smartd::disks (by default $facts['disks'] is used):
DEFAULT -a -m root@domain.org
/dev/sda -d ata
/dev/sdb -d ata
Main class smartd supports following attributes:
defaultsShared configuration directives can be specified e.g. common email-m root@my.org. Accepts string or an array or strings.disksFact or Hash containing devices declarationrulesAppliedsmartdoptions to disks definition.devicescanWhen enabled will automatically detect all matching devices (restricted byoptions). Default:falseoptionsDEVICESCAN options, e.g.-d removablewill ignore errors on removable devices. Requiresdevicescan: true. Accepts string or an array or strings.
By default Puppet built-in $facts['disks'] is used (accessible also via facter -y disks), e.g.:
nvme0n1:
model: "SAMSUNG MZQL2960HCJR-00A07"
serial: "S64FNE0R503522"
size: 894.25 GiB
size_bytes: 960197124096
type: ssdthat can be used to generate configuration (at least simple list of devices). Though any other fact or hardcoded hash of disks might be used.
The rules parameter can be used to define e.g. model/vendor specific rules that might be generalized.
smartd::rules:
- attr: model # attr value match disk attributes, e.g. vendor, type, etc. might be used
match: SAMSUNG MZ7
options: -I 173 # ignore wear_level_count for disks matching this modelMatch device name using special key $name:
smartd::rules:
- attr: $name
match: ^nvme # regexp match
options: -H # will append all matching rules
- attr: type
match: ssd
options: -l errorthis would output (assuming NVMe has attribute type with value ssd)
/dev/nvme0n1 -H -l error
Ignore device completely (will be ommited from the list):
smartd::rules:
- attr: vendor
match: DELL
action: ignoreApply megaraid device type
smartd::rules:
- atrr: model
match: PERC
options: -d megaraid,0See man smartd.conf for full configuration specification.
-aequivalent of-H -f -t -l error -l selftest -l selfteststs -C 197 -U 198-memail address for notifications-ddevice typeauto,ata,scsi,nvme,ignore,removable-Hperform S.M.A.R.T health check, i.e.smartctl -H /dev/sda-iignore failure of Usage Attributes (e.g. percent of lifetime used)
Will scan for all devices, and then monitor them. It will send one email warning per device for any problems that are found.
smartd::devicescan: true
smartd::options: '-H -d ata -m root@example.com'this would produce config:
DEVICESCAN -H -d ata -m root@example.com
that will ensure that smartd will check SMART health status on all ata drives daily.
Common configuration will be applied for all disks defined bellow (in the config).
smartd::defaults:
- '-a -R5! -W 2,40,45 -I 194 -s L/../../7/00'
- '-m admin@example.com'Written for Puppet 6 and newer, backward compatibility with older versions hasn't been tested.