-
Notifications
You must be signed in to change notification settings - Fork 0
/
disklog.ps1
323 lines (284 loc) · 14.9 KB
/
disklog.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
cls
$welcome = @"
______ _____ _______ _ _ _____ ______
| \ | |______ |____/ | | | | ____
|_____/ __|__ ______| | \_ |_____ |_____| |_____|
W.S.S.D
"@
write-host $welcome
$fname = "disklog-"+[DateTime]::Now.ToString("yyyyMMdd-HHmmss")+".html"
$folder = 'C:\Dell'
$filename = $folder + "\" + $fname
$filenamez= $filename -replace ".html",".zip"
Write-host "Please wait for 3-5 minutes"
Write-host "Output file path :"$filenamez
if (!(Test-Path $folder)) { mkdir C:\Dell }
$html = ''
$html = '<html>'
$html += '<style>body { font-family:Helvetica; } h1 { font-size:22px;font-weight:bold;margin-bottom: auto; } h2 { font-size:20px;font-weight:bold;padding-top:25px;margin-bottom:0px; } h3 { margin-bottom:0px; } label { font-family:monospace; font-size:10px;} table { border-collapse:collapse; min-width:550px; max-width:899px;padding:8px; }
th, td { text-align:left;padding:5px;font-size:12px;border:1px solid #ddd; } tr:nth-child(even) { background-color: #f2f2f2 } th { background-color: #04AA6D; color: white; }</style>'
if ((Get-Command "Get-Cluster" -ErrorAction SilentlyContinue)) {
$html += '<h1>Disk Log</h1>'
$html += '<label>Running at ' + $env:COMPUTERNAME + ' Time : ' + [DateTime]::Now.ToString("yyyyMMdd-HHmmss") + '</label>'
$html += '<body>'
$html += '<h2>Cluster Info</h2>'
$getCluster = Get-Cluster | select Name,Domain,CrossSiteDelay,CrossSiteThreshold,CrossSubnetDelay,CrossSubnetThreshold
$html += $getCluster | ConvertTo-html -Fragment
}
if ((Get-Command "Get-ClusterPerf" -ErrorAction SilentlyContinue)) {
Get-ClusterPerf | out-file C:\Dell\temp.txt
$File = Get-Content C:\Dell\temp.txt
$clusperf = @()
Foreach ($Line in $File) {
if (!($Line.Contains("Series") -or $Line.Contains("Time") -or $Line.Contains("Value") -or $Line.Contains("Unit") -or $Line.Contains("-"))) {
$mystring = ($Line -replace "\s+"," ").Trim()
$mystring = $mystring.Split(" ")
$clusperf += @(
[PSCustomObject]@{
series = $mystring[0];
value = $mystring[3];
unit = $mystring[4];
}
)
}
}
$html += '<h2>Cluster Statistics</h2>'
$html += '<table style="width:auto;border:1px solid #ddd;">'
$html += '<thead style="background-color: #04AA6D;text-align:left;"><tr>'
$html += '<th style="border:1px solid #ddd;">Series</th>'
$html += '<th style="border:1px solid #ddd;">Value</th>'
$html += '</tr></thead><tbody>'
$i = 0
foreach ($data in $clusperf) {
if ($data.series) {
if (!$data.series.Contains("Object")) {
if($i % 2 -eq 0){
$html += '<tr style="border:1px solid #ddd;background-color: #f2f2f2;">'
}else{
$html += '<tr style="border:1px solid #ddd;">'
}
$html += '<td style="border:1px solid #ddd;">' + $data.series + '</td>'
$html += '<td style="border:1px solid #ddd;">' + $data.value + " " + $data.unit + '</td>'
$html += '</tr>'
$i++
}
}
}
$html += '</tbody></table>'
}
$ttdisks = 0
$html += '<h2>Cluster Health</h2>'
$getHealth = Get-HealthFault | select @{label="Severity";expression={$_.PerceivedSeverity}}, Reason, @{label="Description";expression={$_.FaultingObjectDescription}},@{label="Action";expression={$_.RecommendedActions}}
$html += $getHealth | ConvertTo-html -Fragment
$ttdisk = Get-Virtualdisk | Select FootprintOnPool
Foreach ($mvol in $ttdisk) {
$ttdisks += $mvol.FootprintOnPool
}
$s2dSize = Get-StoragePool | ? Friendlyname -NotLike 'Primordial' | Select Size
$atd = Get-StoragePool | ? Friendlyname -Like 'S2D *' | Select ThinProvisioningAlertThresholds
$util = [math]::round(($ttdisks/$s2dSize.size)*100)
$html += '<h2>StoragePool Usage</h2>'
$html += '<table style="width:auto;border:1px solid #ddd;">'
$html += '<thead style="background-color: #04AA6D;text-align:left;"><tr>'
$html += '<th style="border:1px solid #ddd;">StoragePool Threshold</th>'
$html += '<th style="border:1px solid #ddd;">Actual Utilization</th>'
$html += '</tr></thead><tbody>'
$html += '<td style="border:1px solid #ddd;">' + $atd.ThinProvisioningAlertThresholds + '</td>'
$html += '<td style="border:1px solid #ddd;">' + $util + '</td>'
$html += '</tr>'
$html += '</tbody></table>'
if ((Get-Command "Get-ClusterNode" -ErrorAction SilentlyContinue)) {
$html += '<h2>Cluster Nodes</h2>'
$getClusterNode = Get-ClusterNode | select Name, State, Type, SerialNumber -ErrorAction SilentlyContinue
$html += $getClusterNode | ConvertTo-html -Fragment
}
$html += '<h2>Virtual Disk</h2>'
$getVirtualDisk = Get-VirtualDisk | select FriendlyName,PhysicalDiskRedundancy,NumberOfDataCopies,OperationalStatus,HealthStatus,@{label="Size(GB)";expression={[math]::round($_.Size/1GB,2)}},@{label="FootprintOnPool(GB)";expression={[math]::round($_.FootprintOnPool/1GB,2)}},@{label="Provisioning";expression={$_.ProvisioningType}},@{label="Dedup";expression={$_.IsDeduplicationEnabled}}
$html += $getVirtualDisk | ConvertTo-html -Fragment
if ((Get-Command "Get-ClusterSharedVolume" -ErrorAction SilentlyContinue)) {
$html += '<h2>Virtual Disk (CSV) Owner</h2>'
$getCSV = Get-ClusterSharedVolume | select Name,State,OwnerNode | Sort OwnerNode
$html += $getCSV | ConvertTo-html -Fragment
}
$html += '<h2>Virtual Disk - Volume</h2>'
$getvdks = Get-VirtualDisk
$stovdks = foreach ($vdk in $getvdks) {
Get-VirtualDisk -UniqueId $vdk.UniqueId | Get-Disk | Get-Partition | Get-Volume | select FileSystemLabel,DriveLetter,FileSystem,FileSystemType,HealthStatus,ResiliencySettingNameDefault,OperationalStatus,AllocationUnitSize,@{label="SizeRemaining (GB)";expression={[math]::round($_.SizeRemaining/1GB,2)}},@{label="Size (GB)";expression={[math]::round($_.Size/1GB,2)}}
}
$html += $stovdks | ConvertTo-html -Fragment
$html += '<h2>StoragePool</h2>'
$getstgpool = Get-StoragePool | select FriendlyName,OperationalStatus,HealthStatus,IsPrimordial,IsReadOnly,ResiliencySettingNameDefault,@{label="Size(GB)";expression={[math]::round($_.Size/1GB,2)}},@{label="AllocatedSize(GB)";expression={[math]::round($_.AllocatedSize/1GB,2)}},SupportedProvisioningTypes,ProvisioningTypeDefault
$html += $getstgpool | ConvertTo-html -Fragment
$getStoJob = Get-StorageJob | select Name, IsBackgroundTask, ElapsedTime, JobState, PercentComplete, BytesProcessed, BytesTotal
if ($getStoJob) {
$html += '<h2>StorageJob</h2>'
$html += $getStoJob | ConvertTo-html -Fragment
}
$getLC = Get-PhysicalDisk | ? {$_.OperationalStatus -match 'Lost Communication'} | Select FriendlyName,SerialNumber,CanPool,OperationalStatus,HealthStatus,VirtualDiskFootprint,Usage,@{label="Size (GB)";expression={[math]::round($_.Size/1GB,2)}},PhysicalLocation,ObjectId
if ($getLC) {
$html += '<h2>Disk Loss Communication : ' + ($getLC).count + '</h2>'
$html += $getLC | ConvertTo-html -Fragment
}
$getTE = Get-PhysicalDisk | ? {$_.OperationalStatus -match 'Transient Error'} | Select FriendlyName,SerialNumber,CanPool,OperationalStatus,HealthStatus,VirtualDiskFootprint,Usage,@{label="Size (GB)";expression={[math]::round($_.Size/1GB,2)}},PhysicalLocation,ObjectId
if ($getTE) {
$html += '<h2>Transient Error : ' + ($getTE).count + '</h2>'
$html += $getTE | ConvertTo-html -Fragment
}
$getIOE = Get-PhysicalDisk | ? {$_.OperationalStatus -match 'IO error'} | Select FriendlyName,SerialNumber,CanPool,OperationalStatus,HealthStatus,VirtualDiskFootprint,Usage,@{label="Size (GB)";expression={[math]::round($_.Size/1GB,2)}},PhysicalLocation,ObjectId
if ($getIOE) {
$html += '<h2>Disk IO Error : ' + ($getIOE).count + '</h2>'
$html += $getIOE | ConvertTo-html -Fragment
}
$getRFP = Get-PhysicalDisk | ? {$_.OperationalStatus -match 'Remove From Pool'} | Select FriendlyName,SerialNumber,CanPool,OperationalStatus,HealthStatus,VirtualDiskFootprint,Usage,@{label="Size (GB)";expression={[math]::round($_.Size/1GB,2)}},PhysicalLocation,ObjectId
if ($getRFP) {
$html += '<h2>Remove From Pool : ' + ($getRFP).count + '</h2>'
$html += $getRFP | ConvertTo-html -Fragment
}
$errCode = @()
$errCode = @(
'OK'
'IO error'
'Transient Error'
'Lost Communication'
'In Maintenance Mode'
'Removing From Pool, OK'
)
$getNOk = Get-PhysicalDisk | ? {$_.OperationalStatus -notin $errCode} | Select FriendlyName,SerialNumber,CanPool,OperationalStatus,HealthStatus,VirtualDiskFootprint,Usage,@{label="Size (GB)";expression={[math]::round($_.Size/1GB,2)}},PhysicalLocation,ObjectId
if ($getNOk) {
$html += '<h2>Non Okay Drive : ' + ($getNOk).count + '</h2>'
$html += $getNOk | ConvertTo-html -Fragment
}
if ((Get-Command "Get-StorageNode" -ErrorAction SilentlyContinue)) {
$html += '<h2>Connected Hard Disks Per Node</h2>'
$Nodes = Get-StorageNode | Select Name -Unique | Sort Name
ForEach($Node in $Nodes){
$html += '<h3>Hostname : ' + $Node.name + ' Total Disks : ' + (Get-StorageNode -Name $Node.name | Get-PhysicalDisk -PhysicallyConnected).count + '</h3>'
$getNode = Get-StorageNode -Name $Node.name | Get-PhysicalDisk -PhysicallyConnected | Select FriendlyName,SerialNumber,CanPool,OperationalStatus,HealthStatus,Usage,@{label="Size (GB)";expression={[math]::round($_.Size/1GB,2)}},@{label="Percentage (%)";expression={[math]::round(($_.VirtualDiskFootprint/$_.Size)*100,2)}},PhysicalLocation -Unique | sort PhysicalLocation
$html += $getNode | ConvertTo-html -Fragment
}
$tbhead = @()
$tbhead = @(
'Hostname'
'FriendlyName'
'SerialNumber'
'CanPool'
'OperationalStatus'
'HealthStatus'
'PhysicalLocation'
'PowerOnHours'
'Temperature'
'ReadEC'
'ReadET'
'ReadEU'
'WriteEC'
'WriteET'
'WriteEU'
'ObjectId'
)
$html += '<h2>Physically Connected Hard Disk Details</h2>'
$html += '<table><tr>'
foreach ($item in $tbhead) {
$html += '<th>' + $item + '</th>'
}
$html += '</tr>'
$gdisksto = @()
$fnodes = Get-StorageNode | Select Name -Unique | Sort Name
ForEach($Node in $fnodes){
$gdisks = Get-StorageNode -Name $Node.name | Get-PhysicalDisk -PhysicallyConnected | Select FriendlyName,SerialNumber,ObjectId | sort PhysicalLocation
foreach ($gdisk in $gdisks) {
$gdid = $gdisk.ObjectId
$gid = $gdid.split(":")
$gidc = $gid[2] -replace "[^a-zA-Z0-9]"
$gdisksto += @(
[PSCustomObject]@{Name = $Node.name;
FriendlyName = $gdisk.FriendlyName;
SerialNumber = $gdisk.SerialNumber;
ObjectId = $gdisk.ObjectId;
UniqueId = $gidc;
}
)
}
}
$vdisks = Get-Physicaldisk | sort PhysicalLocation
$storects = foreach ($mydisk in $vdisks) {
Get-PhysicalDisk -UniqueId $mydisk.UniqueId | Get-StorageReliabilityCounter | select UniqueId, ReadErrorsCorrected, ReadErrorsTotal, ReadErrorsUncorrected, WriteErrorsCorrected, WriteErrorsTotal, WriteErrorsUncorrected, PowerOnHours, Temperature
}
$stordwr = @()
foreach ($gdsk in $storects) {
$stauid = $gdsk.UniqueId
$uid = $stauid.split(":")
$suid = $uid[2] -replace "[^a-zA-Z0-9]"
$stordwr += @(
[PSCustomObject]@{ReadErrorsCorrected = $gdsk.ReadErrorsCorrected;
ReadErrorsTotal = $gdsk.ReadErrorsTotal;
ReadErrorsUncorrected = $gdsk.ReadErrorsUncorrected;
WriteErrorsCorrected = $gdsk.WriteErrorsCorrected;
WriteErrorsTotal = $gdsk.WriteErrorsTotal;
WriteErrorsUncorrected = $gdsk.WriteErrorsUncorrected;
PowerOnHours = $gdsk.PowerOnHours;
Temperature = $gdsk.Temperature;
UniqueId = $suid;
}
)
}
$ston2d = @()
foreach ($dt in $stordwr) {
foreach ($gd in $gdisksto) {
if ($dt.UniqueId -eq $gd.UniqueId) {
$ston2d += @(
[PSCustomObject]@{Name = $gd.name
ReadErrorsCorrected = $dt.ReadErrorsCorrected;
ReadErrorsTotal = $dt.ReadErrorsTotal;
ReadErrorsUncorrected = $dt.ReadErrorsUncorrected;
WriteErrorsCorrected = $dt.WriteErrorsCorrected;
WriteErrorsTotal = $dt.WriteErrorsTotal;
WriteErrorsUncorrected = $dt.WriteErrorsUncorrected;
PowerOnHours = $dt.PowerOnHours;
Temperature = $dt.Temperature;
UniqueId = $dt.UniqueId;
ObjectId = $gd.ObjectId;
}
)
}
}
}
$xout = foreach ($md in $vdisks) {
$oid = $md.ObjectId
$ouid = $oid.split(":")
$uuid = $ouid[2] -replace "[^a-zA-Z0-9]"
foreach($vvdisk in $ston2d) {
if ($uuid -eq $vvdisk.UniqueId) {
$fname = $vvdisk.name
$sname = $fname.split(".")
$html += '<tr><td data-toggle="tooltip" title="' + $fname + '">' + $sname[0].toUpper() + '</td><td>' + $md.friendlyname + '</td><td>' + $md.serialnumber + '</td><td>' + $md.CanPool + '</td><td>' + $md.OperationalStatus + '</td><td>' + $md.HealthStatus + '</td><td>' + $md.PhysicalLocation + '</td><td>' + $vvdisk.PowerOnHours + '</td><td>' + $vvdisk.Temperature + '</td><td>' + $vvdisk.ReadErrorsCorrected + '</td><td>' + $vvdisk.ReadErrorsTotal + '</td><td>' + $vvdisk.ReadErrorsUncorrected + '</td><td>' + $vvdisk.WriteErrorsCorrected + '</td><td>' + $vvdisk.WriteErrorsTotal + '</td><td>' + $vvdisk.WriteErrorsUncorrected + '</td><td>' + $vvdisk.ObjectId + '</td></tr>'
}
}
}
$html += $xout
$html += '</table>'
}
$getConDisk = Get-Physicaldisk | Select FriendlyName,SerialNumber,CanPool,OperationalStatus,HealthStatus,Usage,@{label="Size(GB)";expression={[math]::round($_.Size/1GB,2)}},PhysicalLocation | sort PhysicalLocation
$html += '<h2>All Hard Disk : ' + ($getConDisk).count + '</h2>'
$html += $getConDisk | ConvertTo-html -Fragment
$fldisk = Get-Physicaldisk | select FriendlyName,HealthStatus,OperationalStatus, SerialNumber,AdapterSerialNumber,Manufacturer,Model,BusType,FirmwareVersion,MediaType,LogicalSectorSize,PhysicalSectorSize,ObjectId | sort PhysicalLocation
$html += '<h2>All Hard Disk Format-List : ' + ($fldisk).count + '</h2>'
$html += $fldisk | ConvertTo-html -Fragment
$v2pdisk = Get-VirtualDisk | sort PhysicalLocation
foreach ($v in $v2pdisk){
$html += '<h3>Physical Disks used by ' + $v.FriendlyName + '</h3>'
$v2p = Get-PhysicalDisk -VirtualDisk $v | select DeviceId, FriendlyName, SerialNumber, MediaType, CanPool, OperationalStatus, HealthStatus, Usage, @{label="Size (GB)";expression={[math]::round($_.Size/1GB,2)}}, FirmwareVersion, PhysicalLocation
$html += $v2p | ConvertTo-html -Fragment
}
$html += '<h2>StorageSpaceDriver-Operational</h2>'
$date = (get-date).AddDays(-30)
$ssdo = Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-StorageSpaces-Driver/Operational';Level=1,2,3;StartTime = $date} | select TimeCreated,Id,LevelDisplayName,Message | sort ProviderName,TimeCreated -Descending
$html += $ssdo | ConvertTo-html -Fragment
$html += '<h2>System Log</h2>'
$ssdo = Get-WinEvent -FilterHashtable @{LogName='System';ProviderName='Disk','Chkdsk','Microsoft-Windows-Kernel-Power';Level=1,2,3;StartTime = $date} | select TimeCreated,Id,LevelDisplayName,Message | sort ProviderName,TimeCreated -Descending
$html += $ssdo | ConvertTo-html -Fragment
$html += '</body></html>'
$html | out-file $filename -Append
Compress-Archive -Path $filename -DestinationPath $filenamez
rm C:\Dell\temp.txt
rm $filename
Write-host "Done!"