Home Directory Plugins Hardware Server Hardware HP (Compaq) Powershell NRPE NSClient script for HP SmartArray check

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Powershell NRPE NSClient script for HP SmartArray check

Rating
9 votes
Favoured:
1
Current Version
1.2
Last Release Date
2013-09-24
Compatible With
  • Nagios 2.x
  • Nagios 3.x
Owner
License
GPL
Hits
74004
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Powershell script to check HP SmartArray RAID status on Windows
######################################################

Plugin deprecated !

Please go to : http://exchange.nagios.org/directory/Plugins/Hardware/Server-Hardware/HP-%28Compaq%29/NRPE-script-for-HP-SmartArray-checks/details

######################################################

Because the Hpacucli takes long time to execute, when you call it for each drive thats become conflicting while adding drives to enclosure.
I don't find a script thats pleased me so i developped it.

All can use, copy, redistribute, modify and improve it.
But please, respect the 'AUTHOR' & 'VERSION' lines (append your's to the list, mandatory).


Checks :
- Physical drives status
- Logical drives status
- Compatible with multiple Arrays

Future improvements (all suggestions and dev. are welcome) :
- Compatibility with multiple HP Smart Array controllers
- Properly handle NRPE's 1024b limitation in return packet
- Some other ...

NSClient++ config :
- Copy check_smartarray.ps1 to NSCLient++ scripts folder
- Set Powershell execution policy to 'Set-ExecutionPolicy Unrestricted'
- Append to NSC.ini : 'check_raid=cmd /c echo scripts/check_smartarray.ps1; exit $LastExitCode | powershell.exe -Command -'
- Restart NSClient++ service

Nagios config example with nrpe-check :
define service {
use critical-service
host_name MyWindowsServer
service_description RAID Status
check_command check_nrpe!check_raid
}

define command {
command_name check_raid
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c check_raid
}
Reviews (7)
byMJ-Lenox, March 10, 2015
I added on to the script felix has created above. This one will return OK with spare drives and return a more specific error to Nagios...

---

$array_config_util = 'C:\Program Files (x86)\Compaq\Hpacucli\Bin\hpacucli.exe'

try {
$exec = & $array_config_util 'ctrl all show config'
#Write-Output $exec
}
catch {
Write-Host "Problem checking array status (hint: nagios\check_smartarray.ps1)"
exit 3
}

# filter results for lines that talk about drives (physicaldrive, logicaldrive)
# and do not end with "OK":
$not_OK = $exec | Where-Object { $_ -like "*drive*" } | Where-Object { $_ -notlike "*OK)"} | Where-Object { $_ -notlike "*OK, spare)"}
if ($not_OK.length -lt 2) {
Write-Host "Array status appears OK"
Write-Host $not_OK
exit 0
}

Write-Host "Array status not OK;" $not_OK
#write-Host $not_OK
exit 2

---
bybeinbliss, August 4, 2014
any news on:
Cannot index into a null array.
At C:Program FilesNSClient++scriptscheck_smartarray.ps1:94 char:77
+ return ($state

?
I also had trouble with this script on our servers. In particular, it returned a false "OK" status when I pulled a drive out of the array. I tried debugging it for a bit, but ended up getting frustrated and just rewrote it much shorter:
----
####
#
# NAME: check_smartarray.ps1
#
# ABOUT: Checks the output of HP's Array Configuration Utility for Smart Array
# RAID controllers, and tries to detect any problems with array status.
#
# This was inspired by Christophe Robert's "Powershell NRPE NSClient
# script for HP SmartArray check", found here:
# http://exchange.nagios.org/directory/Plugins/Hardware/Server-Hardware/HP-(Compaq)/Powershell-NRPE-NSClient-script-for-HP-SmartArray-check/details
# That one seemed a bit complicated, so I shortened it.
#
# AUTHOR: Felix Howe
#
# DISCLAIMER: I don't warrant this code as being suitable for anything;
# use at your own risk. In writing it I represent only myself, not my employer.
#
####

$array_config_util = 'C:\Program Files\Compaq\Hpacucli\Bin\hpacucli.exe'

try {
$exec = & $array_config_util 'ctrl all show config'
#Write-Output $exec
}
catch {
Write-Host "Problem checking array status (hint: nagios\check_smartarray.ps1)"
exit 3
}

# filter results for lines that talk about drives (physicaldrive, logicaldrive)
# and do not end with "OK":
$not_OK = $exec | Where-Object { $_ -like "*drive*" } | Where-Object { $_ -notlike "*OK)" }
if ($not_OK.length -lt 2) {
Write-Host "Array status appears OK"
exit 0
}

Write-Host "Array status not OK; please check (hint: nagios\check_smartarray.ps1)"
exit 2
----
byEricAiken, July 19, 2013
1 of 1 people found this review helpful
Looking forward to this plugin but getting some errors: Any thoughts? Running on win2k3 x64. I have a few print here statements trying to locate where the errors are coming from.

c:\Users\eric.aiken\Downloads>powershell -File check_smartarray.ps1 -t30 -c check_raid
here0

Smart Array P410i in Slot 0 (Embedded) (sn: 5001438018A01EB0)

array A (SAS, Unused Space: 0 MB)


logicaldrive 1 (1.6 TB, RAID 5, OK)

physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS, 900.1 GB, OK)
physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SAS, 900.1 GB, OK)
physicaldrive 1I:1:3 (port 1I:box 1:bay 3, SAS, 900.1 GB, OK)

SEP (Vendor ID PMCSIERA, Model SRC 8x6G) 250 (WWID: 5001438018A01EBF)

here1
Smart Array P410i in Slot 0 (Embedded) (sn: 5001438018A01EB0)
array A (SAS, Unused Space: 0 MB)
logicaldrive 1 (1.6 TB, RAID 5, OK)
physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS, 900.1 GB, OK)
physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SAS, 900.1 GB, OK)
physicaldrive 1I:1:3 (port 1I:box 1:bay 3, SAS, 900.1 GB, OK)
SEP (Vendor ID PMCSIERA, Model SRC 8x6G) 250 (WWID: 5001438018A01EBF)
here2

Name Value
---- -----
Array 0 - lv System.Collections.DictionaryEntry
Array 0 - pd {System.Collections.DictionaryEntry, System.Collections.DictionaryEntry, System.Collections.Dictiona...
Cannot index into a null array.
At C:\Users\eric.aiken\Downloads\check_smartarray.ps1:94 char:77
+ return ($state | Select-String -Pattern "(?Id : MethodNotFound

Method invocation failed because [System.Object[]] doesn't contain a method named 'ContainsKey'.
At C:\Users\eric.aiken\Downloads\check_smartarray.ps1:190 char:25
+ if ($errors.ContainsKey tain a method named 'ContainsKey'.
At C:\Users\eric.aiken\Downloads\check_smartarray.ps1:190 char:25
+ if ($errors.ContainsKey
Owner's reply

Thank you for your feedback with debug !

I found the error, I'll correct it and publish a new version soon. The error is that the script only accept the SATA array and not SAS one ...

Returns OK but status information show:

"Cannot index into a null array."

Looking forward to an updated version!
Owner's reply

Hi,

Thanks for the feedback.
I can't reproduce the error so can you uncomment #164 & #170 lines and send me the result by mail (my mail is in the script header) ?

Regards,

byterat, March 11, 2013
Same error here.
byclarkus978, March 6, 2013
When run against my server, Nagios is reporting the following under Status Information:

The string starting:
At line:1 char:2
+ -
cordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

At least it returns with a Status of 'OK'
Owner's reply

Hi,

I'm trying to reproduce the error but i can't.

Did you modify the path of 'hpacucli' program in the script ? Or anything else ?

Can you uncomment the lines 164 & 170 and send me the result by mail (you can find my mail addr. in the header) ?

Thank you.