Skip to content

Instantly share code, notes, and snippets.

@cosysn
Created March 22, 2017 06:53
Show Gist options
  • Save cosysn/484987b48c1a4d3098586b40568c8864 to your computer and use it in GitHub Desktop.
Save cosysn/484987b48c1a4d3098586b40568c8864 to your computer and use it in GitHub Desktop.
通过WMI来获取MPIO Disk的信息
$MPIODisks = Get-WmiObject -Namespace "root\wmi" -Class mpio_disk_info |
Select-Object "DriveInfo"
foreach ($Disk in $MPIODisks) {
$mpiodrives = $disk.DriveInfo
foreach ($Drive in $mpiodrives) {
Write-Host "Drive : " $Drive.Name
Write-Host "Path : " $Drive.NumberPaths
Write-Host "Serial Num: " $Drive.SerialNumber
}
}
$LBPolicy=Get-WmiObject -Namespace "root\wmi" -Class DSM_QueryLBPolicy_V2
foreach ($lb in $LBPolicy) {
Write-Host $lb.__CLASS
Write-Host $lb.InstanceName
Write-Host $lb.LoadBalancePolicy.DSMPathCount
$dsm_paths = $lb.LoadBalancePolicy.DSM_Paths
foreach ($path in $dsm_paths) {
Write-Host " __CLASS:"$path.__CLASS
Write-Host " DsmPathId:"$path.DsmPathId
Write-Host " Reserved:"$path.Reserved
Write-Host " PathWeight:"$path.PathWeight
Write-Host " PrimaryPath:"$path.PrimaryPath
Write-Host " OptimizedPath:"$path.OptimizedPath
Write-Host " PreferredPath:"$path.PreferredPath
Write-Host " FailedPath:"$path.FailedPath
Write-Host " TargetPortGroup_State:"$path.TargetPortGroup_State
Write-Host " ALUASupport:"$path.ALUASupport
Write-Host " SymmetricLUA:"$path.SymmetricLUA
Write-Host " TargetPortGroup_Preferred:"$path.TargetPortGroup_Preferred
Write-Host " TargetPortGroup_Identifier:"$path.TargetPortGroup_Identifier
Write-Host " TargetPort_Identifier:"$path.TargetPort_Identifier
}
}
$DiskHealthPackets = Get-WmiObject -Namespace "root\wmi" -Class mpio_disk_health_info |
Select-Object DiskHealthPackets
foreach ($diskhealth in $DiskHealthPackets.DiskHealthPackets) {
Write-Host $diskhealth.Name
Write-Host $diskhealth.NumberIoErrors
Write-Host $diskhealth.NumberRetries
Write-Host $diskhealth.CreateTime
Write-Host $diskhealth.PathFailures
Write-Host $diskhealth.FailTime
}
$mpio_paths=Get-WmiObject -Namespace "root\wmi" -Class MPIO_PATH_HEALTH_INFO
$path_health_packets=$mpio_paths.PathHealthPackets
foreach ($path in $path_health_packets) {
Write-Host "=================================================="
Write-Host " PathId:"$path.PathId
Write-Host " NumberReads:"$path.NumberReads
Write-Host " NumberWrites:"$path.NumberWrites
Write-Host " NumberBytesRead:"$path.NumberBytesRead
Write-Host " NumberBytesWritten:"$path.NumberBytesWritten
Write-Host " NumberRetries:"$path.NumberRetries
Write-Host " NumberIoErrors:"$path.NumberIoErrors
Write-Host " CreateTime:"$path.CreateTime
Write-Host " FailTime:"$path.FailTime
Write-Host " PathOffline:"$path.PathOffline
Write-Host " NumberReadsWrap:"$path.NumberReadsWrap
Write-Host " NumberWritesWrap:"$path.NumberWritesWrap
Write-Host " NumberBytesReadWrap:"$path.NumberBytesReadWrap
Write-Host " NumberBytesWrittenWrap:"$path.NumberBytesWrittenWrap
Write-Host " NumberReadsWrap:"$path.OutstandingRequests
Write-Host " Pad:"$path.Pad
}
@cosysn
Copy link
Author

cosysn commented Mar 22, 2017

该脚本只在Win2012R2上测试通过,其他服务器还有待测试。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment