Hi All
We are looking for Script which will provide lun Utilization in below format.
This will help in provide lun details like vmfs type/ last update /Capacity of Lun/Capacity of lun(inGB) /Free space/Used space and % of lun utilization
All luns are managed by our centrally vcenter server. I am not expert in powercli hopefully from this forum i Will get assistance 🙂
LUN Identification Name | Type | Last Update | Capacity (GB) | Free (GB) | Used Space(GB) | % of LUN Utilization |
LUN01_vol01 | VMFS3 | 3/6/2017 1:30:52 PM | 1863.68 | 901.04 | 962.64 | 51.65 |
LUN02_vol01 | VMFS3 | 3/6/2017 1:30:51 PM | 1536 | 597.64 | 938.36 | 61.09 |
Thanks in Advance
PS
Not sure what you want to see under Last Update.
Get-Datastore |
Select Name,
@{N='Type';E={"$($_.Type)$($_.ExtensionData.Info.Vmfs.MajorVersion)"}},
@{N='CapacityGB';E={[math]::Round($_.CapacityGB)}},
@{N='FreeSpaceGB';E={[math]::Round($_.FreeSpaceGB)}},
@{N='UsedSpaceGB';E={[math]::Round($_.CapacityGB - $_.FreeSpaceGB,1)}},
@{N='% of LUN Utilization';E={[math]::Round(($_.CapacityGB - $_.FreeSpaceGB)/$_.CapacityGB * 100,1)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not sure what you want to see under Last Update.
Get-Datastore |
Select Name,
@{N='Type';E={"$($_.Type)$($_.ExtensionData.Info.Vmfs.MajorVersion)"}},
@{N='CapacityGB';E={[math]::Round($_.CapacityGB)}},
@{N='FreeSpaceGB';E={[math]::Round($_.FreeSpaceGB)}},
@{N='UsedSpaceGB';E={[math]::Round($_.CapacityGB - $_.FreeSpaceGB,1)}},
@{N='% of LUN Utilization';E={[math]::Round(($_.CapacityGB - $_.FreeSpaceGB)/$_.CapacityGB * 100,1)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for LuCD
Really appreciate for the quick reply ...
Script is running but not sure where its getting saved in csv format. (searced in desktop and C drive too not found the CSV output)
and also if we can add few more columns like next to @{N='Type';E={"$($_.Type)$($_.ExtensionData.Info.Vmfs.MajorVersion)"}}
Name | Identifier | Path ID | LUN |
DELL Fibre Channel Disk (naa.690b11c0003d8d6600000887519c23fa) | naa.690b11c0003d8d6600000887519c23fa | vmhba1:C0:T0:L21 | 101 |
This is with the Identifier field included, and an export to a CSV.
Get-Datastore |
Select Name,
@{N='Type';E={"$($_.Type)$($_.ExtensionData.Info.Vmfs.MajorVersion)"}},
@{N='CapacityGB';E={[math]::Round($_.CapacityGB)}},
@{N='FreeSpaceGB';E={[math]::Round($_.FreeSpaceGB)}},
@{N='UsedSpaceGB';E={[math]::Round($_.CapacityGB - $_.FreeSpaceGB,1)}},
@{N='% of LUN Utilization';E={[math]::Round(($_.CapacityGB - $_.FreeSpaceGB)/$_.CapacityGB * 100,1)}},
@{N='Identifier';E={$_.ExtensionData.Info.Vmfs.Extent[0]}} |
Export-Csv report.csv -NoTypeInformation -UseCulture
The Path Id for a datastore can be different per VMHost.
How will you display that? This is for datastores that are shared between multiple VMHosts.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks now csv is generated. You are right Path Id for a datastore can be different per VMHost. So this one we donot required.
can it possible to have datastore LUN number all added in new Column.
I'm afraid the LUN number can also be different per VMHost.
The only unique value is the Identifier afaik.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi ,
We can remove the Identifier also or is it will affect on something ?
Like below
Get-Datastore |
Select Name,
@{N='Type';E={"$($_.Type)$($_.ExtensionData.Info.Vmfs.MajorVersion)"}},
@{N='CapacityGB';E={[math]::Round($_.CapacityGB)}},
@{N='FreeSpaceGB';E={[math]::Round($_.FreeSpaceGB)}},
@{N='UsedSpaceGB';E={[math]::Round($_.CapacityGB - $_.FreeSpaceGB,1)}},
@{N='% of LUN Utilization';E={[math]::Round(($_.CapacityGB - $_.FreeSpaceGB)/$_.CapacityGB *100,1)}} |
Export-Csv report.csv -NoTypeInformation -UseCulture
Hi LucD,
I would like to get these reports in mail. Is it possible ??
Sure, try like this
Select Name,
@{N = 'Type'; E = { "$($_.Type)$($_.ExtensionData.Info.Vmfs.MajorVersion)" } },
@{N = 'CapacityGB'; E = { [math]::Round($_.CapacityGB) } },
@{N = 'FreeSpaceGB'; E = { [math]::Round($_.FreeSpaceGB) } },
@{N = 'UsedSpaceGB'; E = { [math]::Round($_.CapacityGB - $_.FreeSpaceGB, 1) } },
@{N = '% of LUN Utilization'; E = { [math]::Round(($_.CapacityGB - $_.FreeSpaceGB) / $_.CapacityGB * 100, 1) } }
$sMail = @{
To = 'me@domain'
From = 'report@domain'
Subject = 'Datastore Report'
SmtpServer = 'mail.domain'
Body = $report | ConvertTo-Html | Out-String
BodyAsHtml = $true
}
Send-MailMessage @sMail
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is there any reason why the Identifier column is only showing "
VMware.Vim.HostScsiDiskPartition |
" as the result ?
Try changing that line to
@{N='Identifier';E={$_.ExtensionData.Info.Vmfs.Extent[0].DiskName}} |
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you Luc, it is working as expected 🙂
Hey LucD,
I would like to know where to run this script.
Hope i need to run it in a server which has access to the Vcentre ??
Do mention me where to run it ? I'm from storage background and because we don't have any specifc SNMP to monitor the LUN utilization, we would like to have these scripts to get the LUN utilization !! So kindly get back to me on this.
Yes, you can run the script on any host that can connect (Connect-VIServer) to the vCenter.
It doesn't really matter if it is a workstation or a server.
The host where you run the script, needs to have PowerShell and the VMware PowerCLI modules installed.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference