Microsoft Virtualization Discussions

Get the netapp cluster mode count and the total sizeper disks type

tchuise92
7,593 Views

Good afternoon,

 

I am new in powershell and i want to know if someone could help me collecting the count of disks and also the total usable space per each disks type.

 

$AllDisks7M += $NonMetroDisks7M
$AllDisks7M += $MetroDisks7M
$AllDisks7M += $ReplicationDisks7M
ForEach($Disk7M in $AllDisks7M)
{
$foundType = 0
for($i = 0; $i -le $DiskTypes7M.Length-1; $i++)
{
if($DiskTypes7M[$i][0] -eq $Disk7M.PhysSpace)
{
$DiskTypes7M[$i][1] ++
$foundType = 1
}
}
if(!$foundType)
{
$DiskTypes7M += ,@($Disk7M.PhysSpace, 1)
}
}
$DiskTypes7M = $DiskTypes7M | sort-object @{Expression={$_[0]}; Ascending=$false}

 

I used that script for collecting on 7 mode but it is not working on cluster mode prompting this message:

 

You cannot call a method on a null-valued expression.
At line:103 char:1
+ $p.TotalSize = $PDCTSizeCM.toString()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

8 REPLIES 8

asulliva
7,590 Views

What is the expected output of your script?

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

tchuise92
7,581 Views

 

 this for example is the output of the 7 mode

PS C:\Users\XXXX> $DiskTypes7M

4000787030016

200

1778132385792

231

588124522352

701

587421531156

305

293710764580

216

288196759322

457

 

I want to have this type of matrix for the cluster mode as well

for example for the first 2 lines

the longer number is the total size of the 200 disks type X306-XXXXXXXX of my system

JGPSHNTAP
7,576 Views

Interesting..

 

start with get-ncdisk

 

And to convert the numbers use convertto-formattednumber cmdlet

 

 

tchuise92
7,568 Views

When I use this command it show the size of the different disks not the total size like I was thinking

 

ConvertTo-FormattedNumber 4000787030016


ConvertTo-FormattedNumber 4000787030016


ConvertTo-FormattedNumber 1778132385792


ConvertTo-FormattedNumber 588124721152

 

ConvertTo-FormattedNumber 587421536256

 

ConvertTo-FormattedNumber 293710766080

 

ConvertTo-FormattedNumber 288196759552
4T
4T
2T
588G
587G
294G
288G

asulliva
7,564 Views

Here's what I came up with...you'll want to adjust depending on what you want to see.

 

$diskReport = @{}

Get-NcDisk | %{
    $diskCapacity = ConvertTo-FormattedNumber ($_.DiskInventoryInfo.BytesPerSector * $_.DiskInventoryInfo.RightSizeSectors)
    $id = "$($_.DiskInventoryInfo.DiskType)_$($diskCapacity)"

    if ($diskReport.Keys -notcontains $id) {
        $diskReport.$($id) = @{ 'Capacity' = 0; 'Count' = 0; }
    }
    
    $diskReport.$($id).Capacity += $_.Capacity
    $diskReport.$($id).Count++
        
}

$diskReport.GetEnumerator() | Select @{'N'="DiskType";'E'={ $_.Name }}, @{'N'="TotalRawCapacity";'E'={ ConvertTo-FormattedNumber $_.Value.Capacity }},@{'N'="Count";'E'={ ConvertTo-FormattedNumber $_.Value.Count }}

This will show the disk type (SAS, SSD, SATA) and the right size value as a single field, e.g. "SAS_1T", along with the total raw capacity of the disk type in the system and the count.

 

DiskType TotalRawCapacity Count
-------- ---------------- -----
SAS_445G 43T              96   
SAS_1T   49T              40   
SSD_406G 3T               8    

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

anne_thom
5,551 Views

This is great thanks! How can this be iterated for many filers?  tx. 

asulliva
7,550 Views

If you want to use disk model for the "type" information that's an easy modification from what I had originally...

 

$diskReport = @{}

Get-NcDisk | %{
    $id = $_.DiskInventoryInfo.Model

    if ($diskReport.Keys -notcontains $id) {
        $diskReport.$($id) = @{ 'Capacity' = 0; 'Count' = 0; }
    }
    
    $diskReport.$($id).Capacity += ($_.DiskInventoryInfo.BytesPerSector * $_.DiskInventoryInfo.RightSizeSectors)
    $diskReport.$($id).Count++
        
}

$diskReport.GetEnumerator() | Select `
    @{'N'="DiskType";'E'={ $_.Name }}, `
    @{'N'="TotalRawCapacity";'E'={ ConvertTo-FormattedNumber $_.Value.Capacity DataSize "0.00" }}, `
    @{'N'="Count";'E'={ ConvertTo-FormattedNumber $_.Value.Count }}

Which results in:

 

DiskType         TotalRawCapacity Count
--------         ---------------- -----
X438_1625400MCSG 2.95 TB          8    
X425_HCBEP1T2A10 44.26 TB         40   
X421_FAL12450A10 38.46 TB         95   
X421_HCOBD450A10 414.58 GB        1    

Note I changed Convertto-FormattedNumber to use more precision in the output also.

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

tchuise92
7,180 Views

Thank you a lot Andrews, I have been off work for a while that helps me a lot.I will test it in my environment

Public