Using MegaCLI to Monitor Openfiler

UPDATE — There’s a better way to do this. See my latest post here: Using MegaCLI to Monitor Openfiler (rev2).

There’s quite a few posts around the ‘net on Openfiler and MegaCLI. Why another one? I wanted to customize my scripts a bit differently, and none of them worked 100% for me. Most of the code is scavenged but attributed where possible.

Installing MegaCLI

  1. First, find and download the latest MegaCLI supported by your controller on the LSI website.
  2. Extract the RPM’s on your workstation and scp them to your openfiler box to /root (on windows, WinSCP works).
  3. SSH to the openfiler box
  4. /root/rpm2cpio MegaCli-8.00.11-1.i386.rpm  | cpio -idmv
  5. /root/rpm2cpio Lib_Utils-1.00-05.noarch.rpm   | cpio -idmv
  6. Test with /opt/MegaRAID/MegaCLI/MegaCli64 -PDList -aAll

Configuring MegaCLI and Cron

  1. vi /opt/MegaRAID/MegaCLI/analysis.awk
  2. Add the following to this new file:
    # This is a little AWK program that interprets MegaCLI output
    #using two spaces at the beginning of each line for outlook -- see
    /Device Id/ { counter += 1; device[counter] = $3 }
    /Firmware state/ { state_drive[counter] = $3 }
    /Inquiry/ { name_drive[counter] = $3 " " $4 " " $5 " " $6 }
    END {
    for (i=1; i
  3. vi /root/raidstatus
  4. Add the following to this new file. NOTE: make sure to change SYSTEMNAME, and the target\sender addresses.
    /opt/MegaRAID/MegaCli/MegaCli64 -PdList -aALL > /tmp/SYSTEMNAME-megaCLIdump.txt
    cat /tmp/SYSTEMNAME-megaCLIdump.txt | awk -f /opt/MegaRAID/MegaCli/analysis.awk > /tmp/megarc.raidstatus
    #ref: (fishguy; post 6)
    cd /opt/MegaRAID/MegaCli
    ./MegaCli64 -AdpAllInfo -aALL | grep "Degraded" > degraded.txt
    ./MegaCli64 -AdpAllInfo -aALL | grep "Failed Disks" > failed.txt
    a='cat degraded.txt'
    b='cat failed.txt'
    echo $a $b | grep "1" > dead.txt
    if [[ $? -eq 0 ]];
    cat /tmp/megarc.raidstatus | mailx -s "Warning: SYSTEMNAME.chem failed disk or degraded array" -r -a /tmp/SYSTEMNAME-megaCLIdump.txt
    rm -f /opt/MegaRAID/MegaCli/degraded.txt
    rm -f /opt/MegaRAID/MegaCli/failed.txt
    rm -f /opt/MegaRAID/MegaCli/dead.txt
    rm -f /tmp/SYSTEMNAME-megaCLIdump.txt
    rm -f /tmp/megarc.raidstatus
    exit 0
  5. chmod 700 /root/raidstatus
  6. Next, open the Openfiler GUI, click the “System” tab, then click “Notifications” in the right navigation panel.
  7. Enter your notifications (email) settings into this configuration page and click “save”. My emails from the command line wouldn’t send until I completed this step.
  8. Next run “chrontab -e” and add the following line:
  9. */5 * * * * /root/raidstatus

Once complete, cron should run this script every 5mins and email if any raid members are offline.



3 thoughts on “Using MegaCLI to Monitor Openfiler

  1. I am having no luck running megacli on openfiler. It gives me this error:
    OSSpecificInitialize: Failed to load Please ensure that libsfs is present in the system.
    The dependent library not available. Please contact LSI for distribution of the package

    Any ideas? Thank you for this article!

  2. Pingback: Table of Contents | windowsmasher

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s