Using the SNMPD-MDRAID connector

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

Configuration

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

/etc/snmpd-mdraid-connector
# List of disk devices to monitor
DEVICES=(/dev/md*[0-9])

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

# Command to run mdadm
MDADMCMD="/sbin/mdadm"

# 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-mdraid-connector to function correctly on a standard Gentoo Linux installation. Any MD-RAID 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-mdraid-connector the cache of MD-RAID state data should be created manually using the update-mdraid-cache application, as shown below, to ensure that it works without problems.

lisa update-mdraid-cache
Rebuilding cache files...done. 

Assuming that everything works as expected you will want to create a cron entry to execute the update-mdraid-cache application at regular intervals. The data retrieved by the snmpd-mdraid-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-mdraid-cache application every five minutes.

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

SNMPD-MDRAID 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-mdraid-connector script whenever it receives a request for the MD-RAID-MIB::mdRaidTable branch of the OID tree.

The example configuration entry below uses the pass_persist directive to load the snmpd-mdraid-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.2 /usr/sbin/snmpd-mdraid-connector

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

lisa /etc/init.d/snmpd restart

Testing the SNMPD-MDRAID connector script

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

lisa snmptable -c hacking -v 2c -CH localhost MD-RAID-MIB::mdRaidTable
  1      /dev/md0   0.90   e6414f84:9563e117:be6508ee:8797bbcc     raid1      N/A                  N/A        128448        128448    true    false    false    4    4    4    0    0 
  2      /dev/md1   0.90   bb8e6b0b:e52afea6:42a5569a:f0f6d253     raid10     near=2               64K        497792        248896    true    false    false    4    4    4    0    0 
  3      /dev/md2   0.90   2c393ecb:2ce60414:4d9f5052:a44143f0     raid5      left-symmetric       64K       2987712        995904    true    false    false    4    4    4    0    0 
  4      /dev/md3   0.90   d5ddef30:6702b071:3ba102da:5f8f7fb5     raid5      left-symmetric       64K     437754816     145918272    true    false    false    4    4    4    0    0 

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

  1. Device Index
  2. Device Path
  3. Metadata version
  4. UUID
  5. RAID level
  6. RAID layout
  7. Chunk size
  8. Array size
  9. Device size
  10. Array health OK
  11. Array has failed components
  12. Array has spare components
  13. Total components in array
  14. Active components in array
  15. Working components in array
  16. Failed components in array
  17. Spare components in array

More information and a detailed description of each field can be found in the MD-RAID-MIB details section of the SNMP MIB describing MD-RAID array state documentation.