Skip to content

SMART

Install prerequisites

apt-get install smartmontools libjson-perl libmime-base64-perl
pkg install p5-JSON p5-MIME-Base64 smartmontools
dnf install smartmontools perl-JSON perl-MIME-Base64

SNMP Extend

  1. Copy the Perl script, smart, to the desired host.
wget https://github.com/librenms/librenms-agent/raw/master/snmp/smart-v1 -O /etc/snmp/smart
  1. Make the script executable
chmod +x /etc/snmp/smart
  1. Setup a cronjob to run it. This ensures slow to poll disks won't result in errors.
 */5 * * * * /etc/snmp/smart -u -Z
  1. Edit your snmpd.conf file and add:
extend smart /bin/cat /var/cache/smart
  1. You will also need to create the config file, which defaults to the same path as the script, but with .config appended. So if the script is located at /etc/snmp/smart, the config file will be /etc/snmp/smart.config. Alternatively you can also specific a config via -c.

  2. Anything starting with a # is comment.

  3. variables is $variable=$value.
  4. Empty lines are ignored.
  5. Spaces and tabes at either the start or end of a line are ignored.
  6. Any line with out a matched variable or # are treated as a disk.
#This is a comment
cache=/var/cache/smart
smartctl=/usr/bin/env smartctl
useSN=1
ada0
ada1
da5 /dev/da5 -d sat
twl0,0 /dev/twl0 -d 3ware,0
twl0,1 /dev/twl0 -d 3ware,1
twl0,2 /dev/twl0 -d 3ware,2

The variables are as below.

Variable Default Description
cache /var/cache/smart The path to the cache file to use.
smartctl /usr/bin/env smartctl The path to use for smartctl.
useSN 1 If set to 1, it will use the disks SN for reporting instead of the device name.

A disk line is can be as simple as just a disk name under /dev/. Such as in the config above The line ada0 would resolve to /dev/ada0 and would be called with no special argument. If a line has a space in it, everything before the space is treated as the disk name and is what used for reporting and everything after that is used as the argument to be passed to smartctl.

If you want to guess at the configuration, call it with -g and it will print out what it thinks it should be.

  1. Restart snmpd on your host

    sudo systemctl restart snmpd
    

The application should be auto-discovered as described at the top of the page. If it is not, please follow the steps set out under SNMP Extend heading top of page.

  1. Optionally setup nightly self tests for the disks. The exend will run the specified test on all configured disks if called with the -t flag and the name of the SMART test to run.

    0 0 * * * /etc/snmp/smart -t long