While checking the vmkernel logs on our VMware ESX Servers today, I ran into some errors referencing luns using a vml string. It looks something like this: vml.827149017315617. I would like to know what lun this error is referencing, but I prefer the LUN Path notation, e.g.: vmhba1:2:137. So I wrote this Powershell VI Toolkit function that can translate the vml into the lun path:
# Function: Translate a VML (e.g.: vml.9364839746917650) to a Lun Path (e.g.: vmhba1:2:137) function Translate-VmlToLunPath { param( [string]$VMHostName, [string]$Vml ) Return (Get-VMHost $VMhostName | Get-ScsiLun | Where {$_.ConsoleDeviceName -match $Vml}).CanonicalName }
Feed it a host name and a vml string and it will return the lun path. Here’s an example script that uses this function when looking for LUNs with SCSI Reservation Errors:
# Example use in a script: Get LUNs with SCSI Reservation Conflicts $VIServerName = "myVIServer" $NumLines = 1000 $VC = Connect-VIServer $VIServerName ForEach ($VMHost in Get-VMHost) { ForEach ($Log in ($VMHost | Get-Log -Key vmkernel -NumLines $NumLines)) { $MatchedEntries = $Log.Entries | Where {$_ -match "reservation" -and $_ -match "vml.\d*"} ForEach ($VmlId in $matches.values) { $myObj = "" | Select VMHost, ErrorLun $myObj.VMHost = $VMHost.Name $myObj.ErrorLun = Translate-VmlToLunPath -VMHostName $VMHost.Name -Vml $VmlId Return $myObj } } } Disconnect-VIServer -Confirm:$False
Enjoy!
Hugo






