Insights

CodeBase: Nagios Plugin > LSI Hardware RAID Controller – Underlying Physical Disk S.M.A.R.T Monitoring

Category: Resources

A simple and efficient way of grabbing the smart health of a scalable amount of disks on an LSI Hardware RAID Controller, exiting to Nagios statuses.

We are providing the following code to be used as an information resource only. It is licensed under GNU GPL. Any use of, or development of the resources provided is strictly unsupported and VooServers Ltd will not be liable for any loss of or damage to business or personal assets.

#!/bin/bash
#
#Dave Byrne
#LSI Hardware RAID S.M.A.R.T Check
#

#Where is storcli?
storclibin="/opt/MegaRAID/storcli/storcli64"

#Check if storcli actually exists, echo and exit warning if it isnt
if ! [ -e "$storclibin" ]
then
  echo "WARNING - StorCli Not Found"
  exit 1
fi

#Get number of underlying physical disks from storcli
underlyingdisks=`$storclibin /c0 show|grep "Physical Drives"|awk '{ print $4}'`

#Loop to grab the smart health result from all physical disks
counter=0
while [ $counter -lt $underlyingdisks ]; do
  #echo counter at $counter
  smartctl -d sat+megaraid,$counter -a /dev/sda|grep "SMART overall-health self-assessment test result" >> /usr/results.txt
  let counter=counter+1
done

#Analyse results and start giving exit codes

if grep -q FAILED "/usr/results.txt";
then
    #failed string found, time to work out what disk it was
    line=`awk '/FAILED/{ print NR; exit }' /usr/results.txt`
    #subtract 1 from line number as disks start at 0
    let line=line-1
    diskinfo=`smartctl -d sat+megaraid,$line -a /dev/sda|grep -E 'Device Model|Serial Number'`
    printf "CRITICAL - Device ID #$line FAILURE ImminentnDISK INFO: n$diskinfo n"
    rm -f /usr/results.txt
    exit 2
else
    #failed string not found, echo and exit ok
    echo "OK - All array disks healthy"
    rm -f /usr/results.txt
    exit 0
fi

This plugin is also published in Nagios Exchange HERE

More articles

Microsoft Teams Banner Image

5 Features You Might Not Know About in Microsoft Teams

Microsoft Teams has become the go-to communication tool for countless businesses, largely due to its wide range of features and ease of use. It offers various ways to communicate, collaborate, and boost productivity, all while keeping things simple and user-friendly. We’ve compiled a list of five such features below and hope that you find them as useful as we and our clients do.

Read the article
blog default img

Endpoint Security: SentinelOne

The IT industry has a rapidly evolving landscape, with new technologies announced daily and breakthroughs constantly on the horizon. In recent years, cybersecurity has firmly secured its place in almost all, if not all, discussions surrounding IT operations. In this article, we'll explore the importance of endpoint security and how SentinelOne can help strengthen your overall security posture.

Read the article