Using the SNMPD-SMARTCTL connector

Once the snmp-agents/snmpd-smartctl-connector package has been installed some basic configuration is required.

Configuration

The snmp-agents/snmpd-smartctl-connector configuration file, located at /etc/snmpd-smartctl-connector, is relatively straightforward as shown in the example below.

/etc/snmpd-smartctl-connector
# List of disk devices to monitor
DEVICES=(/dev/sd*[a-z])

# Path to cache directory
CACHEDIR=/tmp/snmp-cache/smartctl

# Command to run smartctl
SMARTCMD="/usr/sbin/smartctl"

# Command to run snmptranslate
SNMP_TRANSLATE="/usr/bin/snmptranslate"

# Define debug to log lots
# DEBUG="true"

As you can see the first line is the only one which may need to be modified for the snmpd-smartctl-connector to function correctly on a standard Gentoo Linux installation. Any SMART capable devices that you wish to monitor should be added here. The remaining entries allow the cache directory to be relocated, the paths for the required utilities to be specified should they be installed in a non-standard location and debug mode to be activated.

Data collection script

Once you have configured the snmpd-smartctl-connector the cache of SMART data should be created manually using the update-smartctl-cache application, as shown below, to ensure that it works without problems.

lisa update-smartctl-cache
Rebuilding info files...done. 
Rebuilding state files...done. 
Rebuilding attribute files...done. 

Assuming that everything works as expected you will want to create a cron entry to execute the update-smartctl-cache application at regular intervals. The data retrieved by the snmpd-smartctl-connector will be read from this cache so will only be updated at the interval you configure here.

lisa crontab -e

The example below shows a crontab entry which would execute the update-smartctl-cache application every five minutes.

/tmp/crontab.XXXXyXKwdT
*/5 * * * * /usr/sbin/update-smartctl-cache > /dev/null

SNMPD-SMARTCTL connector script

When you are sure the data collection script is indeed operating correctly the next step is to modify the SNMP daemon configuration so that it will use the snmpd-smartctl-connector script whenever it receives a request for the SMARTCTL-MIB::smartCtlTable branch of the OID tree.

The example configuration entry below uses the pass_persist directive to load the snmpd-smartctl-connector script and associate it with the correct OID. This configuration directive should be added to the existing SNMPD configuration.

/etc/snmp/snmpd.conf
pass_persist .1.3.6.1.4.1.38696.2.1 /usr/sbin/snmpd-smartctl-connector

Now that we have reconfigured the SNMPD daemon to use the snmpd-smartctl-connector we need to restart it so that our changes take effect.

lisa /etc/init.d/snmpd restart

Testing the SNMPD-SMARTCTL connector script

The final step is to test that the new data is indeed available from the SNMPD daemon. In the example below we can use the snmptable utility to display the complete SMARTCTL-MIB::smartCtlTable for the local machine.

lisa snmptable -c hacking -v 2c -CH localhost SMARTCTL-MIB::smartCtlTable
  1      /dev/sda      Seagate Barracuda 7200.7 and 7200.7 Plus family      ST3160827AS      5MT0CKR4      160,041,885,696 bytes      6      true      39      0      0      0      0      44      53      50 
  2      /dev/sdb      Seagate Barracuda 7200.7 and 7200.7 Plus family      ST3160827AS      5MT0CG5Q      160,041,885,696 bytes      6      true      38      0      0      0      0      57      54      63 
  3      /dev/sdc      Seagate Barracuda 7200.7 and 7200.7 Plus family      ST3160827AS      5MT0CG9Y      160,041,885,696 bytes      6      true      40      1      0      0     15      48      54      54 
  4      /dev/sdd      Seagate Barracuda 7200.7 and 7200.7 Plus family      ST3160827AS      5MT0CG7J      160,041,885,696 bytes      6      true      39      0      0      0      0      51      53      57 

As you can see in the example above the SMARTCTL-MIB::smartCtlTable contains a wealth of information. For your convenience a brief description of each field is given below.

  1. Device Index
  2. Device Path
  3. Model Family
  4. Device Model
  5. Serial Number
  6. User Capacity
  7. ATA Version
  8. Health OK [boolean]
  9. Temperature [raw]
  10. Reallocated Sector Count [raw]
  11. Current Pending Sector Count [raw]
  12. Off-line Uncorrectable Sector Count [raw]
  13. UDMA CRC Error Count [raw]
  14. Read Error Rate [lifetime]
  15. Seek Error Rate [lifetime]
  16. Hardware ECC Recovered [lifetime]

More information and a detailed description of each field can be found in the SMARTCTL-MIB details section of the SNMP MIB describing Harddisk SMART Data documentation.