Table of contents
- About gNMIc
- Install gNMIc on your automation setup
- Generate data from YANG files
- Subscribe to CVP models
- Subscribe to OpenConfig data streamed by EOS devices and stored in CVP
- Interfaces
- BGP
- Subscribe to the
bgp
YANG container - Subscribe to the
state
YANG container for all bgp neighbors - Subscribe to the
session-state
YANG leaf for the bgp neighbor 172.16.200.2 in default VRF - Subscribe to the
config
YANG container for the bgp neighbor 172.16.200.1 - Subscribe to the
state
YANG container for the bgp neighbor 172.16.200.1 in the default VRF
- Subscribe to the
- gNMI History Extension
- Use
jq
to parse JSON in bash
gNMIc is a gNMI client
gNMIc documentation https://gnmic.kmrd.dev/
gNMIc source code https://github.com/karimra/gnmic
bash -c "$(curl -sL https://get-gnmic.kmrd.dev)"
gnmic version
gnmic help
Copy all the YANG files from OpenConfig repository to the local directory
mkdir yang_modules
git clone https://github.com/openconfig/public.git
cp public/release/models/*.yang yang_modules/.
cp -R public/release/models/*/*.yang yang_modules/.
cp public/third_party/ietf/*.yang yang_modules/.
cd yang_modules/
ls
gnmic generate path --file openconfig-interfaces.yang --state-only
gnmic generate path --file openconfig-interfaces.yang --types
gnmic generate --file openconfig-interfaces.yang
gnmic generate --file openconfig-interfaces.yang --json
gnmic -a 192.168.0.5:443 capabilities --token=$token --skip-verify
Get the device-id
YANG leaf for all devices from CVP inventory
gnmic -a 192.168.0.5:443 --mode=once subscribe --path /inventory/state/device/device-id --token=$token --skip-verify
Subscribe to the device-id
YANG leaf for all devices from CVP inventory
gnmic -a 192.168.0.5:443 --mode=stream subscribe --path /inventory/state/device/device-id --token=$token --skip-verify --stream-mode ON_CHANGE
Go to Devices > Inventory and replace the target in the commands below with the device ID
found in the CVP device inventory.
The device ID
is the device SN.
gnmic -a 192.168.0.5:443 subscribe --path "openconfig:/interfaces/interface/state/counters" --token=$token --target=leaf1 --skip-verify
gnmic -a 192.168.0.5:443 subscribe --path "openconfig:/interfaces/interface[name=Ethernet1]/state/admin-status" --token=$token --target=leaf1 --skip-verify
gnmic -a 192.168.0.5:443 subscribe --path "openconfig:/network-instances/network-instance/protocols/protocol/bgp/" --token=$token --target=leaf1 --skip-verify
gnmic -a 192.168.0.5:443 subscribe --path "openconfig:/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/state" --token=$token --target=leaf1 --skip-verify
gnmic -a 192.168.0.5:443 subscribe --path "openconfig:network-instances/network-instance[name=default]/protocols/protocol/bgp/neighbors/neighbor[neighbor-address=172.16.0.2]/state/session-state" --token=$token --target=leaf1 --skip-verify
gnmic -a 192.168.0.5:443 subscribe --path "openconfig:/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor[neighbor-address=172.16.200.1]/config" --token=$token --target=leaf1 --skip-verify
gnmic -a 192.168.0.5:443 subscribe --path "openconfig:/network-instances/network-instance[name=default]/protocols/protocol/bgp/neighbors/neighbor[neighbor-address=172.16.200.1]/state" --token=$token --target=leaf1 --skip-verify
This is defined in this repository https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-history.md
This allow to:
- retrieve data at a specific time in the past
- request all updates applied to a data tree between two specified times
gnmic -a 192.168.0.5:443 subscribe \
--path "openconfig:/interfaces/interface/state/counters" \
--token=`cat token.tok` --mode=once --target=spine1 \
--skip-verify --history-snapshot=2022-07-17T12:56:00Z
gnmic -a 192.168.0.5:443 subscribe \
--path "openconfig:/interfaces/interface/state/counters" \
--token=`cat token.tok` --mode=stream --target=spine1 --skip-verify\
--history-start=2022-07-17T12:53:00Z --history-end=2022-07-17T12:55:00Z
sudo apt-get install -y jq
gnmic -a 192.168.0.5:443 subscribe --path "openconfig:/interfaces/interface/state/counters" --token=$token --target=leaf1 --skip-verify | jq .
gnmic -a 192.168.0.5:443 subscribe --path "openconfig:/interfaces/interface/state/counters" --token=$token --target=leaf1 --skip-verify | jq .updates[].Path
Filter the output to see only the values of the leaves
under the counters
container for the interface Ethernet4
gnmic -a 192.168.0.5:443 subscribe --path "openconfig:/interfaces/interface[name=Ethernet4]/state/counters" --token=$token --target=leaf1 --skip-verify | jq .updates[].values