Page 1 of 2

IBM / LSI MegaCLI

Posted: Wed May 30, 2012 7:56 am
by pshankland
Hi all,

Have just installed the MegaCLI application on my Nagios server to see what information I could pull off the RAID controller. Just be running a single command you can find out loads of information that would be really useful:
[root@rpl-jensen MegaCli]# ./MegaCli64 -PDList -aALL

Adapter #0

Enclosure Device ID: 252
Slot Number: 0
Drive's postion: DiskGroup: 0, Span: 0, Arm: 0
Enclosure position: 0
Device Id: 10
WWN: 500000E116D88251
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS
Raw Size: 68.365 GB [0x88bb6b0 Sectors]
Non Coerced Size: 67.865 GB [0x87bb6b0 Sectors]
Coerced Size: 67.054 GB [0x861c000 Sectors]
Firmware state: Online, Spun Up
Device Firmware Level: SC17
Shield Counter: 0
Successful diagnostics completion on : N/A
SAS Address(0): 0x500000e116d88252
SAS Address(1): 0x0
Connected Port Number: 1(path0)
Inquiry Data: IBM-ESXSMBE2073RC SC17D3A04KYDSC17SC17SC17
IBM FRU/CRU: 43X0847
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None
Device Speed: 6.0Gb/s
Link Speed: 6.0Gb/s
Media Type: Hard Disk Device
Drive Temperature :35C (95.00 F)
PI Eligibility: No
Drive is formatted for PI information: No
PI: No PI
Drive's write cache : Disabled
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s
Port-1 :
Port status: Active
Port's Linkspeed: Unknown
Drive has flagged a S.M.A.R.T alert : No
The command run is "./MegaCli64 -PDList -aALL" to bring back the above information on all the disks. The info I would have thought was most interesting would be:
  • Slot Number
    Media Error Count
    Other Error Count
    Predictive Failure Count
    Drive Temperature
Could anyone point me in the right direction of where to start writing a plugin for this??

Thanks.
Pete.

Re: IBM / LSI MegaCLI

Posted: Wed May 30, 2012 9:26 am
by agriffin
Nagios plugins are just executables that print text and exit with specific exit codes. The developer guidelines will give you some more detail. In this case your plugin will probably just run MegaCli64 and parse its output. Depending on what language you will be writing your plugin in, there may be a library available to help you (I know there's one for perl and one for python).

Re: IBM / LSI MegaCLI

Posted: Thu May 31, 2012 3:41 am
by pshankland
Hi,

I have got the following script called 'check_serveraid.sh':

Code: Select all

#! /bin/sh

cd /opt/MegaRAID/MegaCli/
./MegaCli64 -PDInfo -PhysDrv [$1:$2] -aALL | grep -e 'Drive Temperature'
As an example, when you run './check_serveraid.sh 252 0' from the plugins directory you get the following output:

Code: Select all

Drive Temperature :35C (95.00 F)
I have created a check command and service and added the service to the local host but get the following which is, I assume, because of the format of the output:
check_serveraid.png
check_serveraid.png (9.26 KiB) Viewed 9714 times
So, a couple of questions:

1) Could anyone give me an example of how I could just output the 35C value of the script output?
2) I can run this script locally but obviously won't be able to run on remote machines. How could I change this?

Thanks.
Pete.

Re: IBM / LSI MegaCLI

Posted: Thu May 31, 2012 3:49 pm
by lmiltchev
1) Could anyone give me an example of how I could just output the 35C value of the script output?
What are the permissions of your file? Can you run this script as nagios user?
2) I can run this script locally but obviously won't be able to run on remote machines. How could I change this?
You will have to install it on the remote machine and then use check_nrpe or check_by_ssh, whichever is applicable to your setup.

Re: IBM / LSI MegaCLI

Posted: Fri Jun 01, 2012 2:50 am
by pshankland
What are the permissions of your file? Can you run this script as nagios user?

Code: Select all

-rwxrwxr-x 1 nagios nagios      85 Jun  1 08:41 check_serveraid.sh
I have also moved the MegaCli64 executable to the plugins directory and changed the owner / permissions:

Code: Select all

-rwxr-xr-x 1 nagios nagios 2570568 Jun  1 08:40 MegaCli64
You will have to install it on the remote machine and then use check_nrpe or check_by_ssh, whichever is applicable to your setup.
Thanks for this info. I'll try check_by_ssh when it works on the local server.

Any further ideas why I keep getting (null)?

Thanks.
Pete.

Re: IBM / LSI MegaCLI

Posted: Fri Jun 01, 2012 2:34 pm
by agriffin
Try running your plugin as the nagios user like so:

Code: Select all

su nagios -s /bin/bash -c "./check_serveraid.sh"

Re: IBM / LSI MegaCLI

Posted: Mon Jun 11, 2012 5:14 am
by pshankland
Hmm, if I run:

Code: Select all

su root -s /bin/bash -c "./check_serveraid.sh 252 0"
I get:

Code: Select all

Drive Temperature :36C (96.80 F)
However, if I run:

Code: Select all

su nagios -s /bin/bash -c "./check_serveraid.sh 252 0"
I get no output :(

Any ideas how I can fault find this?

Thanks.

Re: IBM / LSI MegaCLI

Posted: Mon Jun 11, 2012 9:39 am
by agriffin
You could give the nagios user permission to run MegaCLI64 as root. First of all, if you're not familiar with how to use the vi text editor, you'll want to run 'export VISUAL=nano'. Then run 'visudo' and add the following line to the file that comes up:

Code: Select all

nagios ALL = NOPASSWD: /opt/MegaRAID/MegaCLI/MegaCli64
Then change your script to use sudo:

Code: Select all

#! /bin/sh

cd /opt/MegaRAID/MegaCli/
sudo ./MegaCli64 -PDInfo -PhysDrv [$1:$2] -aALL | grep -e 'Drive Temperature'

Re: IBM / LSI MegaCLI

Posted: Mon Jun 11, 2012 10:55 am
by pshankland
Used vi to modify VISUDO and added the following line as directed:

Code: Select all

nagios ALL = NOPASSWD: /opt/MegaRAID/MegaCLI/MegaCli64
Then I modified the check_serveraid.sh script to the following:

Code: Select all

#! /bin/sh

cd /opt/MegaRAID/MegaCli/
sudo ./MegaCli64 -PDInfo -PhysDrv [$1:$2] -aALL | grep -e 'Drive Temperature'
Now when I run:

Code: Select all

su nagios -s /bin/bash -c "./check_serveraid.sh 252 0"
I just get the following:
[sudo] password for nagios:
Really confused :(

Re: IBM / LSI MegaCLI

Posted: Mon Jun 11, 2012 10:58 am
by pshankland
Sorry, spotted a mistake in the modification to VISUDO...

Code: Select all

nagios ALL = NOPASSWD: /opt/MegaRAID/MegaCLI/MegaCli64
should actually be

Code: Select all

nagios ALL = NOPASSWD: /opt/MegaRAID/MegaCli/MegaCli64
Just a cAsE issue :)
check_serveraid working.png
Thanks.