HP (Compaq)

Powershell NRPE NSClient script for HP SmartArray check

Description:

Powershell script to check HP SmartArray RAID status on Windows

Current Version

1.2

Last Release Date

2013-09-24

Compatible With

  • Nagios 2.x
  • Nagios 3.x

Owner

Bob

License

GPL


Project Notes
###################################################### 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) Add a Review
new script
by MJ-Lenox, March 31, 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)CompaqHpacucliBinhpacucli.exe' try { $exec = & $array_config_util 'ctrl all show config' #Write-Output $exec } catch { Write-Host "Problem checking array status (hint: nagioscheck_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 ---



any news
by beinbliss, August 31, 2014

any news on: Cannot index into a null array. At C:Program FilesNSClient++scriptscheck_smartarray.ps1:94 char:77 + return ($state ?



complex; made simpler version
by felix_h, March 31, 2014

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 FilesCompaqHpacucliBinhpacucli.exe' try { $exec = & $array_config_util 'ctrl all show config' #Write-Output $exec } catch { Write-Host "Problem checking array status (hint: nagioscheck_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: nagioscheck_smartarray.ps1)" exit 2 ----



Thought on this
by EricAiken, July 31, 2013

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:Userseric.aikenDownloads>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:Userseric.aikenDownloadscheck_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:Userseric.aikenDownloadscheck_smartarray.ps1:190 char:25 + if ($errors.ContainsKey tain a method named 'ContainsKey'. At C:Userseric.aikenDownloadscheck_smartarray.ps1:190 char:25 + if ($errors.ContainsKey



Cannot index into a null array.
by smac, April 30, 2013

Returns OK but status information show: "Cannot index into a null array." Looking forward to an updated version!



sma error
by terat, March 31, 2013

Same error here.



It works, but...
by clarkus978, March 31, 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'



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
3.7 (9)
Favorites
1
Views
74,010