gNMI Genstate Subscription
Starting in Junos OS Evolved Release 24.2R1, Juniper Networks publishes the
genstate YANG data models. The genstate
models are
subscribable YANG models for operational state data on Junos devices. gNMI clients can
subscribe to resource paths defined in the models to retrieve specific state data.
View or download the models from the Juniper/yang GitHub repository or Juniper Networks.
Using the new models, gNMI clients in gRPC dial-in environments can subscribe to a genstate resource path and STREAM statistics in SAMPLE sub mode only to a collector. ON_CHANGE sub mode is not supported.
The subscription example that follows uses a target device configured for mutual
authentication using X.509 certificates. The subscription request supplies the root CA
certificate required to verify the target device's local certificate, and it also
provides the client's key and certificate so that the target device can authenticate the
client. The subscription uses STREAM mode and submode SAMPLE and requests data for the
resource path genstate:/genstate/system-information/os-version
. The
telemetry data returned to the collector shows that the target device is operating with
Junos OS version 24.2R1.12-EVO
.
user@controller:~$ gnmic sub -a 198.51.100.10:32767 --mode stream --stream-mode sample -u grpc-user -p secret --tls-ca certs/serverRootCA.crt --tls-cert certs/client.crt --tls-key certs/client.key --sample-interval 30s --path genstate:/genstate/system-information/os-version { "source": "198.51.100.10:32767", "subscription-name": "default-1708559603", "timestamp": 1708559609668499930, "time": "2024-02-21T15:53:29.66849993-08:00", "prefix": "genstate:genstate/system-information/os-version", "updates": [ { "Path": "os-version", "values": { "os-version": "24.2R1.12-EVO" } } ] }
The subscription example that follows again uses a target device configured for mutual
authentication using X.509 certificates. The subscription uses STREAM mode and submode
SAMPLE and requests data for the resource path
genstate:/genstate/interface-information/physical-interface[name=et-1/0/1]/admin-status
.
The admin-status
(administrative status) indicates whether the
interface is enabled (up) or disabled (down). The telemetry data returned to the
collector shows that physical interface et-1/0/1
is
up
.
user@controller:~$ gnmic sub -a 198.51.100.10:32767 --mode stream --stream-mode sample -u grpc-user -p secret --tls-ca certs/serverRootCA.crt --tls-cert certs/client.crt --tls-key certs/client.key --sample-interval 30s --path genstate:/genstate/interface-information/physical-interface[name=et-1/0/1]/admin-status { "source": "198.51.100.10:32767", "subscription-name": "default-1708561308", "timestamp": 1708561313983469233, "time": "2024-02-21T16:21:53.983469233-08:00", "prefix": "genstate:genstate/interface-information/physical-interface[name=et-1/0/1]/admin-status", "updates": [ { "Path": "admin-status", "values": { "admin-status": "up" } } ] }