How to monitor hardware RAID with MegaCli (LSI RAID)

How to monitor hardware RAID with MegaCli (LSI RAID)#

If you want to monitor a target computer RAID array, and if your target computer is equipped with LSI RAID controller(s), then this section is for you!

Note

MegaCli ss also known as CmdTool2.


Important

🙏 Help is welcome / appreciated 🙏

🚧 WiP / TODO 🚧

Prerequisites:


  • On the target computer, install MegaCli in /opt/MegaRAID/MegaCli/MegaCli64 like described here or here.

  • Allow sshmonitor-user to use MegaCli as root without password (thanks to sudo and visudo):

    target-pc # visudo
        > ...
        > ## Allows asnet user to run /opt/MegaRAID/MegaCli/Megacli64 as root without password:
        > sshmonitor-user ALL = NOPASSWD: /opt/MegaRAID/MegaCli/MegaCli64
    
  • Create a symlink for the restricted bash environment:

    target-pc # ln -s /opt/MegaRAID/MegaCli/MegaCli64 /home/sshmonitor-user/bin/megacli
    

    See the security how-to and the security explanations for more details.

  • Add the following alias in the .bashrc:

    target-pc # vi /home/sshmonitor-user/.bashrc
    
        > readonly PATH=$HOME/bin
      + >
      + > alias megacli="sudo megacli"
    
  • Make sure MegaCli is working well with the sshmonitor-user:

    target-pc $ echo $USER
    
        sshmonitor-user
    
    target-pc $ megacli -adpallinfo -aALL
    
        ...
    

  • On the host computer, add the following to your .substitutions file:

    >     ...
    + >
    + >     # LSI RAID monitoring
    + >     {
    + >         CATEGORY="lsi_raid:"
    + > 
    + >         # Shell instruction used to get the LSI RAID state (0: OK, 1: KO), and associated EPICS alarm
    + >         PV_NAME_SCALAR_1="lsi_raid_state"
    + >         SCALAR_1_INSTRUCTION="megacli -LDInfo -Lall -aAll | grep State | awk '{print \\\\$3}' | sed 's/Optimal/0/' | sed 's/Degraded/1/' | sed 's/Failed/2/' | sort -n -r | head -n 1"
    + >         LOAD_SCALAR_1 = ""
    + >         HIHI_SCALAR_1 = "1"
    + >         HHSV_SCALAR_1 = "MAJOR"
    + >         PINI_SCALAR_1 = "1"
    + >     }
    + > 
    > }
    

🚧 TODO 🚧

Make sure that the configuration described in this how-to will work in a restricted bash environment.