01.08
Recently I have been setting up a new PRTG monitoring environment for a customer, and I really wanted to get some useful stats out of the HP P2000 SAN that they have. I initially started looking into whether SNMP might be a good option, as it would then be relatively easy to extract the information I needed from the SAN. Unfortunately I couldn’t extract the information I needed via SNMP.
I wanted to be able to gather information like IOPS, CPU usage etc. I then noticed as part of the HP Performance Monitoring Tool, that it comes with a command line tool called msacli.exe, which you can pass commands to which then outputs the result into XML format. This was perfect, so I installed the HP Performance Monitoring tool onto my monitoring Server. I then started playing around with PowerShell, (which I love at the moment BTW!) so that I could parse the results I needed back into my PRTG monitor.
So I initially wanted to get the stats from one of the Controllers which you can do from the msacli command line tool:
1 |
msacli.exe -ip 192.168.0.1 -user admin -pass password -cmd "show controller-statistics" -outdir "C:\HP P2000 MSA Performance Tool\Output" -noConsole |
This will output the controller stats to an XML file located at C:\HP P2000 MSA Performance Tool\Output.
I then built a PowerShell script based on this XML file, so that I could add the script as a Exe/Script Advanced sensor. This script can be found below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
cd 'C:\HP P2000 MSA Performance Tool' .\msacli.exe -ip 192.168.0.1 -user admin -pass password -cmd "show controller-statistics" -outdir "C:\HP P2000 MSA Performance Tool\Output" -noConsole [xml]$xmlFile= Get-Content "C:\HP P2000 MSA Performance Tool\Output\show__controller_statistics.xml" $cpuLoad = $xmlFile.RESPONSE.OBJECT.PROPERTY[1]."#text" $cpuLoad = $cpuLoad.ToString() $iops = $xmlFile.RESPONSE.OBJECT.PROPERTY[6]."#text" $iops = $iops.ToString() Write-Host "<?xml version=`"1.0`" encoding=`"Windows-1252`" ?>" Write-Host "<prtg>" Write-Host "<result>" Write-Host "<channel>Controller IOPS</channel>" Write-Host "<value>$iops</value>" Write-Host "</result>" Write-Host "<result>" Write-Host "<channel>CPU Load</channel>" Write-Host "<value>$cpuLoad</value>" Write-Host "</result>" Write-Host "</prtg>" |
This then within the PRTG Network Monitor console, should show something like this:
Stay tuned for further updates, as I share further PowerShell scripts for which to monitor your P2000 SAN with PRTG Network Monitor!
Thanks for posting this. I’ve been trying to figure his out for a while. Any updates or new tools?
I am glad that this has been useful for you.
I will be posting some more updates soon on monitoring HP P2000 SANs. They all make use of msacli.exe so the scripts are all very similar to the current script that I have shared.
Thanks for posting this Robert. I have a question though, is there a particular firmware version that has to be installed on the controllers to get this working? I could not get it to recognize the “show controller-statistic” command.
Thanks,
I am not too sure to be honest. I am presuming that if you read the pre-requisites for the HP P2000 Monitoring Tool, that you should be able to find out the minimum firmware required in order for this tool to run. So if you run the command manually rather than using the script, do you not get any output? I also noticed in your comment, that you are using “show controller-statistic” – this will not work as the command has to be exact: “show controller-statistics”. So try executing the following command: msacli.exe -ip 192.168.0.1 -user admin -pass password -cmd “show controller-statistics”
This should product an XML file from within the command prompt window. Let me know if that works or not (don’t forget to change the IP and the username and password above!).
You should be able to SSH in to your p2000 and run the command manually to see if it works.
Also – I had to eidt the posted code to get it to work for me. For my p2000, I had to add the index of the OBJECT array otherwise powershell could not parse the XML and it would error .
I changed line 6 from
$xmlFile.RESPONSE.OBJECT.PROPERTY[1].”#text”
to
$xmlFile.RESPONSE.OBJECT[0].PROPERTY[1].”#text”
Not sure if this is something related to my specific firmware or not , I have TS240P003
I had to do the same. I believe its because you have 2 controllers.
Object[0] gets you stats on controller 1
object[1] gets controller 2
That makes sense – the HP Controller I was coding against, was only using one controller (in an active/passive formation).
Thanks for pointing this out, I will amend my code for this.
Actually, what version of Powershell are you using? I am using the latest release that comes with Server 2012/Windows 8 (Powershell V3)
You can find your version by entering this at the command line:
get-host|Select-Object version
Great input! Thanks.
Waiting for more to come
Highly descriptive post, I loved that a lot.
Will there be a part 2?
Thanks for sharing your knowledge with the PRTG community!