Note: Please see part 2.
Unsurprisingly, when managing a SAN, I needed to track our rate of disk space consumption.
Underwhelmed by HP’s own reporting tools, I decided I needed to roll my own.
I wanted to:
- Log total cluster utilisation – track usage, determine growth rate, etc.
- Log volume utilisation and size – track where consumption is growing, etc.
Pretty straightforward stuff, but a more complex that it ought to be.
- Connect to SAN via CLIQ through Poweshell
- Output info in XML format
- Parse info, export into CSV (one for total cluster utilisation, one for volume-by-volume utilisation)
- Import CSV into Splunk for logging
The code below does the following
- Connects to the cluster – I created a read-only account since the user//pass is in plain text.
- Runs the cliq command getgroupinfo – this outputs a lot of data. Not a problem in our small environment, but could take a long time to run in a large or complex environment.
- Import the getgroupinfo output into an XML PowerShell object
- Output and format required data into CSV
I run this script as a twice-daily scheduled task, and import it into Splunk on the same schedule. This way, I have a log of all my volume and total cluster usage. Within Splunk I can run reports to generate usage graphs, alerts and trend data.
If you don’t use a logging product like Splunk, you could export this data into a database and do with it what you will!
$user = "USERNAME" $pass = "PASSWORD" $hostsystem = "CLUSTER_VIP" $XML = [XML](cliq getgroupinfo login=$hostsystem username=$user password=$pass output=xml) $Report = @() $Row = "" | select CLUSTER, SPACETOTAL, UNPROVISIONEDSPACE, PROVISIONEDSPACE, DATE #blank row $Row.CLUSTER = $XML.gauche.response.group.cluster.name $Row.SPACETOTAL = [Math]::Round((($XML.gauche.response.group.cluster.spaceTotal)/1024/1024),2) $Row.UNPROVISIONEDSPACE = [Math]::Round((($XML.gauche.response.group.cluster.unprovisionedSpace)/1024/1024),2) $Row.PROVISIONEDSPACE = [Math]::Round((($XML.gauche.response.group.cluster.spaceTotal-$XML.gauche.response.group.cluster.unprovisionedSpace)/1024/1024),2) $Row.DATE = Get-Date $Report += $row $Report | Export-Csv "C:\Logging\lefthand\utlisation.csv" -NoTypeInformation # dump the report to .csv $nodes = $XML.SelectNodes("/gauche/response/group/cluster/volume") $VReport = @() for ($x = 0; $x -lt $nodes.Count; $x++){ $Vrow = "" | select NAME, CLUSTER, SIZE, CONSUMEDSPACE, PROVISIONEDSPACE, THIN, PRIMARY, DATE # blank row $Vrow.NAME = $nodes.Item($x).name # Add the data to the row $Vrow.CLUSTER = $nodes.Item($x).clusterName $Vrow.SIZE = $nodes.Item($x).size # Size of the volume if ($nodes.Item($x).consumedSpace){ $Vrow.CONSUMEDSPACE = $nodes.Item($x).consumedSpace } else { $Vrow.CONSUMEDSPACE = $nodes.Item($x).provisionedSpace } $Vrow.PROVISIONEDSPACE = $nodes.Item($x).provisionedSpace $Vrow.THIN = $nodes.Item($x).thinProvision $Vrow.PRIMARY = $nodes.Item($x).isPrimary $Vrow.DATE = Get-Date $VReport += $Vrow } $VReport | Export-Csv "C:\Logging\lefthand\volumeUtlisation.csv" -NoTypeInformation # dump the report to .csv
Also, a big thanks to Greg’s Powershell/CLIQ blog article here.
Pingback: Logging HP Lefthand cluster utilisation part 2 | Staring at rectangles