Src/Private/Get-AbrOntapStorageAGGR.ps1

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
function Get-AbrOntapStorageAGGR {
    <#
    .SYNOPSIS
        Used by As Built Report to retrieve NetApp ONTAP storage summary information from the Cluster Management Network
    .DESCRIPTION

    .NOTES
        Version: 0.6.5
        Author: Jonathan Colon
        Twitter: @jcolonfzenpr
        Github: rebelinux
    .EXAMPLE

    .LINK

    #>

    [CmdletBinding()]
    param (
    )

    begin {
        Write-PscriboMessage "Collecting ONTAP storage aggregate information."
    }

    process {
        try {
            $AggrSpace = Get-NcAggr -Controller $Array
            if ($AggrSpace) {
                $AggrSpaceSummary = foreach ($Aggr in $AggrSpace) {
                    try {
                        $RootAggr = Get-NcAggr $Aggr.Name -Controller $Array | ForEach-Object{ $_.AggrRaidAttributes.HasLocalRoot }
                        [PSCustomObject] @{
                            'Name' = $Aggr.Name
                            'Capacity' = Switch ([string]::IsNullOrEmpty($Aggr.Totalsize)) {
                                $true {'Unknown'}
                                $false {$Aggr.Totalsize | ConvertTo-FormattedNumber -Type Datasize -ErrorAction SilentlyContinue}
                                default {'Unknown'}
                            }
                            'Available' = Switch ([string]::IsNullOrEmpty($Aggr.Available)) {
                                $true {'Unknown'}
                                $false {$Aggr.Available | ConvertTo-FormattedNumber -Type Datasize -ErrorAction SilentlyContinue}
                                default {'Unknown'}
                            }
                            'Used' = Switch ([string]::IsNullOrEmpty($Aggr.Used)) {
                                $true {'Unknown'}
                                $false {$Aggr.Used | ConvertTo-FormattedNumber -Type Percent -ErrorAction SilentlyContinue}
                                default {'Unknown'}
                            }
                            'Disk Count' = $Aggr.Disks
                            'Root' = ConvertTo-TextYN $RootAggr
                            'Raid Type' = Switch ([string]::IsNullOrEmpty($Aggr.RaidType)) {
                                $true {'Unknown'}
                                $false {($Aggr.RaidType.Split(",")[0]).ToUpper()}
                                default {'Unknown'}
                            }
                            'State' = $Aggr.State
                        }
                    }
                    catch {
                        Write-PscriboMessage -IsWarning $_.Exception.Message
                    }
                }
                if ($Healthcheck.Storage.Aggr) {
                    $AggrSpaceSummary | Where-Object { $_.'State' -eq 'failed' } | Set-Style -Style Critical -Property 'State'
                    $AggrSpaceSummary | Where-Object { $_.'State' -eq 'unknown' -or $_.'State' -eq 'offline' } | Set-Style -Style Warning -Property 'State'
                    $AggrSpaceSummary | Where-Object { $_.'Used' -ge 90 } | Set-Style -Style Critical -Property 'Used'
                }
                $TableParams = @{
                    Name = "Aggregates - $($ClusterInfo.ClusterName)"
                    List = $false
                    ColumnWidths = 27, 10, 10, 10, 10, 8, 15, 10
                }
                if ($Report.ShowTableCaptions) {
                    $TableParams['Caption'] = "- $($TableParams.Name)"
                }
                $AggrSpaceSummary | Table @TableParams
            }
            try {
                $AggrSpare = Get-NcAggrSpare -Controller $Array
                if ($AggrSpare) {
                    Section -Style Heading4 'Aggregate Spares' {
                        $AggrSpareSummary = foreach ($Spare in $AggrSpare) {
                            try {
                                [PSCustomObject] @{
                                    'Name' = $Spare.Disk
                                    'Capacity' = Switch ([string]::IsNullOrEmpty($Spare.TotalSize)) {
                                        $true {'-'}
                                        $false {$Spare.TotalSize | ConvertTo-FormattedNumber -Type Datasize -ErrorAction SilentlyContinue}
                                        default {'-'}
                                    }
                                    'Root Usable' = Switch ([string]::IsNullOrEmpty($Spare.LocalUsableRootSize)) {
                                        $true {'-'}
                                        $false {$Spare.LocalUsableRootSize | ConvertTo-FormattedNumber -Type Datasize -ErrorAction SilentlyContinue}
                                        default {'-'}
                                    }
                                    'Data Usable' = Switch ([string]::IsNullOrEmpty($Spare.LocalUsableDataSize)) {
                                        $true {'-'}
                                        $false {$Spare.LocalUsableDataSize | ConvertTo-FormattedNumber -Type Datasize -ErrorAction SilentlyContinue}
                                        default {'-'}
                                    }
                                    'Shared Disk' = ConvertTo-TextYN $Spare.IsDiskShared
                                    'Disk Zeroed' = ConvertTo-TextYN $Spare.IsDiskZeroed
                                    'Owner' = $Spare.OriginalOwner
                                }
                            }
                            catch {
                                Write-PscriboMessage -IsWarning $_.Exception.Message
                            }
                        }
                        if ($Healthcheck.Storage.Aggr) {
                            $AggrSpareSummary | Where-Object { $_.'Disk Zeroed' -eq 'No' } | Set-Style -Style Warning -Property 'Disk Zeroed'
                        }
                        $TableParams = @{
                            Name = "Aggregates Spares - $($ClusterInfo.ClusterName)"
                            List = $false
                            ColumnWidths = 20, 12, 12, 12, 12, 12, 20
                        }
                        if ($Report.ShowTableCaptions) {
                            $TableParams['Caption'] = "- $($TableParams.Name)"
                        }
                        $AggrSpareSummary | Table @TableParams
                    }
                }
            }
            catch {
                Write-PscriboMessage -IsWarning $_.Exception.Message
            }
            try {
                if ($InfoLevel.Storage -ge 2) {
                    Section -Style Heading4 'Aggregate Options' {
                        $Aggregates = Get-NcAggr -Controller $Array | Where-Object {!$_.AggrRaidAttributes.HasLocalRoot}
                        foreach ($Aggregate in $Aggregates) {
                            try {
                                Section -Style Heading5 "$($Aggregate.Name) Options" {
                                    $OutObj = @()
                                    $Options = Get-NcAggrOption -Controller $Array -Name $Aggregate.Name
                                    $Option = @{}
                                    $Options | ForEach-Object {$Option.add($_.Name, $_.Value)}
                                    $inObj = [ordered] @{
                                        'azcs_read_optimization' = $TextInfo.ToTitleCase($Option.azcs_read_optimization)
                                        'dir_holes' = ConvertTo-TextYN $Option.dir_holes
                                        'dlog_hole_reserve' = $TextInfo.ToTitleCase($Option.dlog_hole_reserve)
                                        'enable_cold_data_reporting' = ConvertTo-TextYN $Option.enable_cold_data_reporting
                                        'encrypt_with_aggr_key' = ConvertTo-TextYN $Option.encrypt_with_aggr_key
                                        'free_space_realloc' = $TextInfo.ToTitleCase($Option.free_space_realloc)
                                        'fs_size_fixed' = $TextInfo.ToTitleCase($Option.fs_size_fixed)
                                        'ha_policy' = $TextInfo.ToTitleCase($Option.ha_policy)
                                        'hybrid_enabled' = ConvertTo-TextYN $Option.hybrid_enabled
                                        'ignore_inconsistent' = $TextInfo.ToTitleCase($Option.ignore_inconsistent)
                                        'logical_space_enforcement' = ConvertTo-TextYN $Option.logical_space_enforcement
                                        'logical_space_reporting' = ConvertTo-TextYN $Option.logical_space_reporting
                                        'max_write_alloc_blocks' = $TextInfo.ToTitleCase($Option.max_write_alloc_blocks)
                                        'nearly_full_threshold' = $TextInfo.ToTitleCase($Option.nearly_full_threshold)
                                        'no_delete_log' = $TextInfo.ToTitleCase($Option.no_delete_log)
                                        'no_i2p' = $TextInfo.ToTitleCase($Option.no_i2p)
                                        'nosnap' = $TextInfo.ToTitleCase($Option.nosnap)
                                        'percent_snapshot_space' = $TextInfo.ToTitleCase($Option.percent_snapshot_space)
                                        'raid_cv' = $TextInfo.ToTitleCase($Option.raid_cv)
                                        'raid_lost_write' = $TextInfo.ToTitleCase($Option.raid_lost_write)
                                        'raidsize' = $TextInfo.ToTitleCase($Option.raidsize)
                                        'raidtype' = $TextInfo.ToTitleCase($Option.raidtype)
                                        'resyncsnaptime' = $TextInfo.ToTitleCase($Option.resyncsnaptime)
                                        'single_instance_data_logging' = $TextInfo.ToTitleCase($Option.single_instance_data_logging)
                                        'snapmirrored' = $TextInfo.ToTitleCase($Option.snapmirrored)
                                        'snapshot_autodelete' = $TextInfo.ToTitleCase($Option.snapshot_autodelete)
                                        'striping' = $TextInfo.ToTitleCase($Option.striping)
                                        'thorough_scrub' = $TextInfo.ToTitleCase($Option.thorough_scrub)
                                    }
                                    $OutObj += [pscustomobject]$inobj

                                    $TableParams = @{
                                        Name = "Aggregates Options - $($Aggregate.Name)"
                                        List = $true
                                        ColumnWidths = 50, 50
                                    }
                                    if ($Report.ShowTableCaptions) {
                                        $TableParams['Caption'] = "- $($TableParams.Name)"
                                    }
                                    $OutObj | Table @TableParams
                                }
                            }
                            catch {
                                Write-PscriboMessage -IsWarning $_.Exception.Message
                            }
                        }
                    }
                }
            }
            catch {
                Write-PscriboMessage -IsWarning $_.Exception.Message
            }
        }
        catch {
            Write-PscriboMessage -IsWarning $_.Exception.Message
        }
    }

    end {}

}