RAID array monitoring at home

Ever since I started using a simple RAID-1 setup at home, the only verification I had done to check on the status of the array was issuing some commands by hand on the command line.  I finally got around to implementing something a bit more proactive using Nagios, its NRPE plugin tool, and a simple bash script that queries dmraid.

To cut to the chase, for those who understand Nagios syntax, the below two sections are added to my server’s Nagios configs.

define command { command_name    check_nrpe command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }  define service { use  generic-service name check-raid host_name $yourhosts service_description Software Raid check_command check_nrpe!check_raid } 

Servers who wish to have their RAID status checked, are added to the host_name parameter here, or can get the services tag added in the hostname definition.

The below code is added client-side to the nrpe.cfg, where the NRPE daemon is installed and listening. The command section assigns the check_raid command a simple script to run when the test is executed.

pinotnoir:/etc/nagios$ cat nrpe_local.cfg command[check_raid]=/usr/lib/nagios/plugins/  :::bash pinotnoir:/usr/lib/nagios/plugins$: cat #----------------- #!/bin/sh raid_status=`dmraid -s | grep status | awk '{print $3}'` if [ "$raid_status" = "ok" ] ; then echo "RAID Status OK" exit 0 else echo "RAID Status NOT OKAY" exit 1 fi 

This is the actual source of the script. As of the writing of this blog post, it only supports checking one RAID array using the dmraid utility.

Example output of dmraid is pasted below, where my script simple pulls out the status line.

pinotnoir:/usr/lib/nagios/plugins$ sudo dmraid -s *** Active Set name : nvidia_bfecfffb size : 976773120 stride : 128 type : mirror status : ok subsets: 0 devs : 2 spares : 0 

Understandably it is quite short and basic at this point, where I hope to have more scripts forth coming that provide more exposure into the status of the RAID array, and potentially support multiple arrays.