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
No related posts.

Richard
August 27th, 2009
Hi Hugo, when I try to run your script, I am receiving this error message:
Get-Log : 8/27/2009 10:58:52 AM Get-Log A2618ED6-5613-4F05-9693-DF51274B582B A general system error occurred:
At C:\Users\test\Documents\SysAdmin\Scripts\VMware Scripts\getscsireservationerrors.ps1:8 char:37
+ ForEach ($Log in ($VMHost | Get-Log <<<< -Key vmkernel -NumLines $NumLines))
+ CategoryInfo : NotSpecified: (:) [Get-Log], ViRuntimeException
+ FullyQualifiedErrorId : Client20_RuntimeDataServiceImpl_GetSingleLog_ViError,VMware.VimAutomation.Commands.GetLog
Any idea what is going on here?
admin
August 27th, 2009
It appears the Get-Log cmdlet is causing a general system error. Are you sure you have permissions to read the logfiles on the ESX server? I wouldn’t know what else could be wrong.
Hugo
Richard
August 27th, 2009
It’s a ESXi server, therefore vmkernel logs do not exists? When I change vmkernel to messages the get-log commando itself works.