search
top

How To Get XtremIO Volume Data Using PowerShell and XtremLib

Introduction

In an earlier post we introduced the XtremIO PowerShell modules available for download and use from EMC. We covered a few of the basic cmdlets available. In this post we will look at Using the Get-XtremVolumes cmdlet to create a capacity report for specific volumes.

Getting Started

If you have followed the post earlier you should have the certs and the XtremLib PowerShell modules installed and ready on your system. If not please refer to the post and get setup.

Our objective is to get a list of the Volumes and display the properties for Logical Space in Use and Volume Size and display the output in GB with the option to save as an CSV file.

 

The Code

<#
.SYNOPSIS
This script will get a dump of XtremIO Volumes and display logical space in use and volume size.

.DESCRIPTION
This script will get a dump of XtremIO Volumes and display logical space in use and volume size.

.NOTES
File Name : getxiovols.ps1
Author :
Requires : XtremIO PowerShell Modules 1.1.5
Version : 1.0 (June 21, 2018 )

.OUTPUTS
Screen Output. can be modified to save to csv just uncomment

.EXAMPLE
C:\PS> .\getxiovols.ps1

#>

# Import the XtremLib PowerShell Modules
# Download from
Import-Module XtremLib

# Start a session to XtremIO array
New-XtremSession -XmsName <XMS Name> –Username <user> –Password <password>

# Use Get-XtremVolumes cmdlet to get Name, Volume Size and Logical Space in use.

# Uncomment to save output to csv file
# Get-XtremVolumes | Select-Object -Property name,@{Name="Volume Size GB";E={($_.'vol-size'/1MB)}},@{Name="Logical Space in Use GB";E={"{0:N}" -f ($_.'logical-space-in-use'/1MB)-as [float]}} | Export-Csv -Path c:\temp\xiocapacity.csv

#
Get-XtremVolumes | Select-Object -Property name,@{Name="Volume Size GB";E={($_.'vol-size'/1MB)}},@{Name="Logical Space in Use GB";E={"{0:N}" -f ($_.'logical-space-in-use'/1MB)-as [float]}}

If we look at the code we can see that there is really not a lot needed. Most of the work is in converting the output of the sizes to GB. Which from the code example this can be re-used in future scripts.

So let us break down the code.

First we need to import the XtremLib module.

Import-Module XtremLib

Next, we need to create a session with XMS (XtremIO Management Server). Change the values in <> to you server and credentials.

New-XtremSession -XmsName <XMS Name> –Username <user> –Password <password>

Final statement is to use the Get-XtremVolumes cmdlet and display Name, Vol-size and logical-space-in-use properties. Minus the conversions our output will look like this.

Get-XtremVolumes | Select-Object -Property 'name','vol-size','logical-space-in-use'

get-xtremvolumes1

Not very readable, so let us use a few expressions to clean it up. PowerShell allows us to do this pretty easy. From the example above we see two ways. the first for vol-size the output has no decimal places as the volumes were created as such. so using the @{Name=”Volume Size GB”;E={($_.’vol-size’/1MB)}}. We are dividing the value by MB. Now our output looks better.

Get-XtremVolumes | Select-Object -Property name,@{Name="Volume Size GB";E={($_.'vol-size'/1MB)}}

get-xtremvolumes2

 

For Logical Space In Use we have a long string of decimals so we will need to use {0:N} and the -as [float] we can get the output to no more than two after the decimal point in the conversion. Here is how we achieve it.

@{Name="Logical Space in Use GB";E={"{0:N}" -f ($_.'logical-space-in-use'/1MB)-as [float]}}

So adding to the rest of our string we get.

Get-XtremVolumes | Select-Object -Property name,@{Name="Volume Size GB";E={($_.'vol-size'/1MB)}},@{Name="Logical Space in Use GB";E={"{0:N}" -f ($_.'logical-space-in-use'/1MB)-as [float]}}

and the final outcome?

xiovol3

Final step is to give the script the ability to save the output to csv. We achieve this by adding | Export-Csv -Path c:\temp\xiocapacity.csv.

Conclusion

With a few commands using PowerShell and the XtremLib modules we have created a capacity report that can be saved to CSV format and usable for any manager or yourself needing report data from you XIO.

 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

top