MLNX-OS CLI Troubleshooting: Filters, watch and Log Commands - 夜莺博客

MLNX-OS CLI Troubleshooting: Filters, watch and Log Commands

NVIDIA (Mellanox) MLNX-OS switches come with an industry-style CLI that hides some of its most useful troubleshooting power in the pipeline operators: filtering, live monitoring and structured output. Once you learn that every show command can be filtered with include/exclude, watched at a refresh interval, or printed as JSON, log analysis and fault hunting on Spectrum and InfiniBand switches become dramatically faster. This guide covers the CLI modes, the show-command pipeline tricks and the logging commands that matter during troubleshooting.

CLI Modes

MLNX-OS has three main privilege levels. Commands are lowercase and case-sensitive:

  • Standard mode: the initial shell; read-only queries of a restricted state set.
  • Enable mode: enable - full state visibility plus actions such as reboot, but no configuration changes.
  • Config mode: configure terminal - full configuration access, allowed for admin-role accounts. Exit back with exit or no configure.

You cannot jump directly from Standard to Config mode; you must pass through Enable.

switch > enable
switch # configure terminal
switch (config) #

Filtering Show Output with include and exclude

Every show command can be piped to a filter, which saves you from scrolling through hundreds of lines during an incident:

switch (config) # show module | include "SW1|OK"
switch (config) # show interfaces | exclude "0"
switch (config) # show version | include version ignore-case
switch (config) # show asic-version | include SIB2

Filters support extended regular expressions, the ignore-case option, and the next/prev parameters to print surrounding lines. Multiple filters can be chained with additional pipe characters.

Live Monitoring with watch

The watch operator re-runs a show command at a fixed interval (2 seconds by default) and updates the screen, which is perfect for watching counters while you reproduce a fault:

switch (config) # show interfaces counters | watch interval 5
switch (config) # show power | watch diff interval 1

The diff keyword highlights what changed between two consecutive iterations. Exit watch mode with Ctrl+C. watch cannot be combined with json-print.

Structured Output with json-print

For automation and precise parsing, pipe any show command to json-print to get the output as JSON instead of a formatted table:

switch (config) # show system profile
Profile: eth-single-switch
switch (config) # show system profile | json-print
{ "Profile": "eth-single-switch" }

Logging Commands for Troubleshooting

Event and log inspection is the core of MLNX-OS troubleshooting. The key commands:

show logging

Displays the logging configuration: local and remote log levels, number of archived log files (default 10), rotation size threshold, and configured remote syslog servers.

show log

Shows the log file itself with paging; supports continuous (tail -f style), file selection and regex matching:

switch # show log
switch # show log files 3
switch # show log matching "link down"
switch # show log continuous not matching "heartbeat"

Remote syslog is configured from config mode, and log files can be rotated or deleted manually:

switch (config) # logging 10.10.10.5 protocol tcp
switch (config) # logging files delete current
switch (config) # show logging events interfaces source-counters

Event source-counters output gives per-interface Rx/Tx discard, FCS error, symbol error and storm-control counters - a fast first stop when a port looks unhealthy.

Useful Verification Commands

show version
show inventory
show module
show system profile
show interfaces counters
show logging events

Related reading: MLNX-OS CLI filters, watch and link diagnostics and Mellanox MLNX-OS VLAN and IP routing configuration.

Original article: NVIDIA MLNX-OS User Manual: Command Line Interface