The Convert-ScsiCode PowerShell function decodes SCSI sense codes found in the vmkernel.log from ESXi hosts. It uses a JSON based SCSI Code database provided by virten.net. The function works just like my web-based SCSI Sense Code Decoder but allows you to integrate it in your automation scripts.
The function is part of my Virten.net.VimAutomation module, which is a set of PowerShell function built for managing, troubleshooting and automating VMware based platforms. The module can be easily obtained from the PowerShell Gallery and is available on GitHub.
Install Virten.net.VimAutomation from PowerShell Gallery
The Virten.net PowerCLI Automation Module is available in the PowerShell Gallery.
PS> Install-Module -Name Virten.net.VimAutomation
Install Virten.net.VimAutomation from GitHub (Manual Installation)
The Virten.net PowerCLI Automation Module is also available on GitHub. To manually install this module, copy the Virten.net.VimAutomation folder (Download) into your local module directory. There are various module directories, they can be identified with the
$env:PSModulePath environment variable. Activate the module with
PS> Import-Module Virten.net.VimAutomation -Force -Verbose.
SCSI errors or warnings in ESXi are displayed with 6 status codes. This function converts these sense codes from ESXi Hosts to human readable status information. In the vmkernel.log system log file from an ESXi 5.x or 6.0 hosts, you see entries similar to the following:
ScsiDeviceIO: [...] Cmd 0xG [...] to dev "naa.x" failed H:0xA D:0xB P:0xC Valid sense data: 0xD 0xE 0xF.
- A: Host Status Code
- B: Device Status Code
- C: Plugin Status Code
- D: Sense Key
- E: Additional Sense Code (ASC)
- F: Additional Sense Code Qualifier (ASCQ)
- G: Operational Code (Command)
|HostStatus||Host Status Code|
|DeviceStatus||Device Status Code|
|PluginStatus||Plugin Status Code|
|ASC||Additional Sense Code (ASC)|
|ASCQ||Additional Sense Code Qualifier (ASCQ)|
|OpCode||Operational Code (Command)|
The first option to use the function is by simply passing HostStatus, DeviceStatus, PluginStatus, SenseKey, ASC, ASCQ and OpCode to the function. Use ft -AutoSize -Wrap for better readability.
PS> Convert-ScsiCode 0 2 0 5 24 0 1a |ft -AutoSize -Wrap
You can also translate single status codes by its type:
PS> Convert-ScsiCode -HostStatus 1 |ft -AutoSize -Wrap Type Code Name Description ---- ---- ---- ----------- Host Status 0x01 NO_CONNECT This status is returned if the connection is lost to the LUN. This can occur if the LUN is no longer visible to the host from the array side or if the physical connection to the array has been removed.
Or pass multiple status codes to the function:
PS> Convert-ScsiCode -HostStatus 0 -DeviceStatus 2 -PluginStatus 4 |ft -AutoSize -Wrap Type Code Name Description ---- ---- ---- ----------- Host Status 0x00 OK This status is returned when there is no error on the host side. This is when you will see if there is a status for a Device or Plugin. It is also when you will see Valid sense data instead of Possible sense Data. Device Status 0x02 CHECK_CONDITION This status is returned when a command fails for a specific reason. When a CHECK CONDITION is received, the ESX storage stack will send out a SCSI command 0x3 (REQUEST SENSE) in order to get the SCSI sense data (Sense Key, Additional Sense Code, ASC Qualifier, and other bits). The sense data is listed after Valid sense data in the order of Sense Key, Additional Sense Code, and ASC Qualifier. Plugin Status 0x04 REQUEUE The plug-in wants to requeue the I/O back. The I/O will be retried.
Visit VMware ESXi SCSI Sense Code Decoder for a Web-based decoder.