LinuxCommandLibrary

nmcli-monitor

Monitor network connection changes

TLDR

Start monitoring NetworkManager changes

$ nmcli [[m|monitor]]
copy

SYNOPSIS

nmcli [OPTIONS] monitor

PARAMETERS

--escape, -e
    Escape output to prevent issues with special characters, useful when parsing names or values.

--colors <auto|always|never>
    Control whether output uses colors for better readability. 'auto' is default, 'always' forces colors, 'never' disables them.

--help, -h
    Show help for the nmcli command and its subcommands, including global options.

--version, -v
    Show nmcli version information.

DESCRIPTION

nmcli monitor is a subcommand of the nmcli (NetworkManager command-line interface) utility, designed for real-time observation of NetworkManager's activities. It streams events related to network devices, connections, and overall NetworkManager state changes directly to the terminal. This command is invaluable for debugging network issues, understanding NetworkManager's behavior, and verifying network configuration changes as they happen.

It displays notifications for various events including device activation/deactivation, connection establishment/teardown, IP address assignments, DNS updates, and Wi-Fi scanning results. The output provides dynamic insights into how NetworkManager manages network interfaces, making it a powerful tool for system administrators and network engineers alike. The continuous stream of information helps identify transient issues or unexpected network transitions that might be difficult to catch with static status commands.

CAVEATS

The nmcli monitor command requires the NetworkManager service to be running and active. Its output can be extremely verbose on busy networks, continuously streaming events to the console. Due to its dynamic, event-based nature, the output is generally not suitable for structured parsing with tools like grep or awk in a programmatic way, unlike other nmcli commands that produce tabular data. Furthermore, to access all event information, appropriate user permissions (e.g., membership in the netdev group or root privileges) may be necessary.

TYPICAL USAGE

To use nmcli monitor, simply run it in a terminal. It will immediately start displaying events as NetworkManager detects them. To stop monitoring, press Ctrl+C. This command is often run in a dedicated terminal window while performing other network configurations or debugging, allowing for immediate feedback on system changes.

INTERPRETING OUTPUT

The output of nmcli monitor consists of time-stamped lines detailing various events. Common events include:
Device state changes (e.g., 'device (eth0): link connected', 'device (wlan0): activation successful').
Connection state changes (e.g., 'connection (my_wifi): activated').
NetworkManager state changes (e.g., 'NetworkManager state is 'connected (global)'').
It provides a granular view of NetworkManager's decision-making and operational status, invaluable for understanding network dynamics.

HISTORY

The nmcli utility, which includes the monitor subcommand, is part of the NetworkManager project, initiated by Red Hat in 2004. nmcli itself was introduced as the primary command-line interface for NetworkManager, offering a more user-friendly and scriptable alternative to direct D-Bus interactions. The monitor subcommand was subsequently added to provide real-time event streaming capabilities, enhancing nmcli's diagnostic and debugging functionalities as NetworkManager evolved to handle complex network environments.

SEE ALSO

nmcli(1), NetworkManager(8), ip(8), iw(8)

Copied to clipboard