devlink-monitor - Linux


Overview

devlink-monitor monitors and displays network device events in real-time. It provides a structured output format ideal for automation and monitoring scripts.

Syntax

devlink-monitor [options]

Options/Flags

  • -h, –help: Display help and exit.
  • -v, –version: Display version and exit.
  • -d, –device : Specify the device to monitor. Default: all devices.
  • -o, –output : Specify the output format. Valid options: summary (default), json, keyval, keyid, valueid, bpf.
  • -f, –filter : Filter events based on an expression. Expression format: field=value,field2=value2,…
  • -s, –stream: Stream output continuously.
  • -D, –data-only: Display only the data portion of events.
  • -e, –events <EVENT_MASK>: Specify the event types to monitor. Default: all events. Event masks: FUNC, FILTER, PORT, RESET.
  • -w, –wait : Wait a specified number of seconds before exiting. Default: indefinitely.

Examples

Monitor all events for 10 seconds:

devlink-monitor -w 10

Monitor filter events for specific device:

devlink-monitor -d eth0 -e FILTER

Output events in JSON format:

devlink-monitor -o json

Filter events with key-value expression:

devlink-monitor -f port=1,type=NEW

Common Issues

  • Ensure that the Linux kernel version supports the devlink-monitor feature (5.10+).
  • Verify that the network device is supported by devlink.
  • Check the device name carefully to avoid monitoring the wrong interface.

Integration

  • Use devlink-monitor in scripts to monitor network events and trigger actions.
  • Combine devlink-monitor with nfcapd to capture and analyze network traffic.
  • Integrate devlink-monitor with network monitoring systems like Nagios or Prometheus.

Related Commands