gnmic-get
Retrieve data from network devices using gNMI
TLDR
Get a snapshot of the device state at a specific path
Query the device state at multiple paths
Query the device state at multiple paths with a common prefix
Query the device state and specify response encoding (json_ietf)
SYNOPSIS
gnmic [GLOBAL_FLAGS] get [GET_FLAGS] [--path <gNMI_PATH>...]
PARAMETERS
-a, --address
Specifies one or more gNMI target addresses (e.g., host:port). Can be specified multiple times.
-u, --username
Sets the username for gNMI authentication.
-p, --password
Sets the password for gNMI authentication.
--insecure
Disables TLS certificate verification, useful for testing with self-signed certificates.
--tls-ca, --tls-cert, --tls-key
Paths to TLS CA, client certificate, and client key files for mutual TLS authentication.
-P, --path
One or more gNMI paths to retrieve data from. This option can be specified multiple times.
--prefix
A gNMI path prefix that is applied to all specified --path arguments.
-t, --type
Specifies the data type to retrieve: ALL, CONFIG, STATE, OPERATIONAL. Defaults to ALL.
--model
One or more OpenConfig or custom data models to include in the gNMI capabilities request, aiding path resolution.
--encoding
Specifies the gNMI encoding for the request message: JSON, JSON_IETF, ASCII, PROTO.
--format
Specifies the output format for the received data: JSON, YAML, TEXT. Affects client-side rendering.
--target
The target name used when connecting to a gNMI proxy that manages multiple targets.
--timeout
Sets the gRPC timeout for the request (e.g., 5s, 1m). If exceeded, the command will abort.
DESCRIPTION
gnmic-get is a core subcommand of the gnmic command-line interface client, designed to interact with network devices implementing the gNMI (gRPC Network Management Interface) protocol.
It enables users to retrieve configuration and state information from a gNMI target, which is typically a network device or a network function. This command is crucial for various network automation tasks, including monitoring device operational parameters, fetching specific configuration elements, validating device state programmatically, and debugging.
gnmic-get supports fetching data based on precise gNMI paths, allowing for granular control over the retrieved information. It can interact with different data models, such as OpenConfig, and handle various data encodings (e.g., JSON, JSON_IETF). The command provides flexibility in specifying target addresses, authentication credentials, and TLS settings for secure and authenticated communication with network infrastructure. Its output can be formatted in different ways, making it suitable for scripting and integration with other automation tools.
CAVEATS
gnmic-get requires a gNMI-enabled network device or service to connect to.
Understanding of gNMI path syntax and relevant data models (e.g., OpenConfig) is essential for effective use.
Authentication and TLS configuration can be complex and must be correctly set up for secure communication.
Retrieving large data sets might consume significant network bandwidth and device resources, potentially impacting performance.
GNMI PATH SYNTAX
gNMI paths specify data elements in a tree-like structure. They are typically absolute and can include keys for list entries. For example: /interfaces/interface[name=ethernet0/1]/state/admin-status retrieves the administrative status of a specific interface. Paths can point to configurations (config), operational states (state), or a combination.
DATA TYPES
The --type flag allows filtering the data returned by the target:
CONFIG: retrieves user-configured data.
STATE: retrieves operational state data, which is typically read-only.
OPERATIONAL: often a superset of STATE, including dynamically generated data.
ALL: retrieves all available data (both CONFIG and STATE/OPERATIONAL).
HISTORY
gnmic emerged as a critical tool in the growing ecosystem of network automation, driven by the adoption of gNMI as an open standard for network management. Developed by the open-source community, it provides a flexible and powerful command-line interface for interacting with gNMI targets, complementing existing tools and enabling modern, intent-driven network operations. Its development is closely tied to advancements in network operating systems supporting gNMI and the proliferation of network automation practices.
SEE ALSO
gnmic(1), gnmic-set(1), gnmic-subscribe(1), gnmic-cap(1), grpc(7)