Configuration
This section explains how to send and receive Get RPC requests for three use cases: Configuration data, State data, and All data types.
Prerequisites
Before configuring streaming telemetry with TLS, ensure the following:
| • | A supported OcNOS router running a compatible release. |
| • | Access to the management interface of the router. |
| • | Any gNMI client that complies with gNMI specifications can be used as a client. |
| • | Download and install the gNMI collector package by referring to the gnmic Installation section. |
| • | Generate the server and client certificates following the Certificate Management for OcNOS and gNMI process to enable secure communication. |
Topology
The Figure 4. Get RPC Connection illustrates how the gNMI client connects to the OcNOS router to send all data type Get RPC request.
Before configuring, meet all Prerequisites.
Use Case 1:Get RPC Requests for Configuration Data Type
The gnmic command retrieves configuration data from the specified device. The --type config flag specifies that the data is of type configuration. The response includes configuration settings for the interface named po1, such as the MTU value and the enable-switchport setting, which are part of the device’s configuration.
./gnmic -a 10.12.162.22:9339 -u admin -p admin --insecure get --path 'ipi:/interfaces/interface[name="po1"]' --encoding json_ietf --type config --timeout 120s
[
{
"source": "10.12.162.22:9339",
"timestamp": 1730122009406462625,
"time": "2024-10-28T13:26:49.406462625Z",
"updates": [
{
"Path": "ipi:interfaces/interface[name=po1]",
"values": {
"interfaces/interface": {
"interfaces": {
"interface": [
{
"config": {
"enable-switchport": "",
"mtu": "300",
"name": "po1"
},
"name": "po1"
}
]
}
}
}
}
]
}
]
Use Case 2:Get RPC Requests for State Data Type
The gnmic command retrieves state data from the specified device. The --type state flag specifies that the data being retrieved is of type state. The response includes various operational details for the interface named ge1, such as its admin-status, oper-status, and various packet counters, which reflect the current state of the interface. This data provides information on the interface’s operational condition, such as whether it is up or down, and details like in-packets, out-packets, and error-disable-reason, which monitors and troubleshoots the interface’s performance.
./gnmic -a 10.12.162.22:9339 -u admin -p admin --insecure get --path "ipi:/interfaces/interface[name=\"ge1\"]/state" --encoding json_ietf --type state --timeout 120s
[
{
"source": "10.12.162.22:9339",
"timestamp": 1730123321680355567,
"time": "2024-10-28T13:48:41.680355567Z",
"updates": [
{
"Path": "ipi:interfaces/interface[name=ge1]/state",
"values": {
"interfaces/interface/state": {
"interfaces": {
"interface": [
{
"name": "ge1",
"state": {
"admin-status": "up",
"counters": {
"extended-counters": {
"error-disable-reason": "not-applicable"
},
"in-broadcast-pkts": "0",
"in-discards": "0",
"in-errors": "0",
"in-fcs-errors": "0",
"in-multicast-pkts": "0",
"in-octets": "0",
"in-pkts": "0",
"in-unicast-pkts": "0",
"last-clear": "2024 Oct 28 11:59:43 (01:48:58 ago)",
"out-broadcast-pkts": "0",
"out-discards": "0",
"out-errors": "0",
"out-multicast-pkts": "0",
"out-octets": "0",
"out-pkts": "0",
"out-unicast-pkts": "0"
},
"custom-state": {
"current-bandwidth": "0"
},
"enable-switchport": "",
"ifindex": "5001",
"last-change": "103900",
"logical": "false",
"name": "ge1",
"oper-status": "down"
}
}
]
}
}
}
}
]
}
]
Use Case 3:Get RPC Requests for All Data Types
The gnmic command retrieves all data types for the specified BGP instance. In this case, the --type flag is not used, meaning that the command will retrieve both configuration and state data related to the BGP instance with AS number 100.
The response includes the configuration and state information for the BGP instance and its peers, such as:
| • | Configuration Data: |
-
bgp-as: 100confirms the AS number for the BGP instance. -
peer-address: 4.4.4.1andpeer-as: 100show the configuration of BGP peers.
| • | State Data: |
-
bgp-peer-state: idleindicates the state of the BGP peer (idle in this case). -
The counters, such as
notification-in: 0, update-message-in: 0, andupdate-message-out: 0, reflect the number of BGP notifications and update messages received and sent. -
total-prefixes: 0indicates that no prefixes are being exchanged yet.
# ./gnmic -a 10.12.162.22:9339 -u admin -p admin --insecure get --path "ipi:/bgp/bgp-instances/bgp-instance[bgp-as=100]" --encoding json_ietf --timeout 120s
[
{
"source": "10.12.162.22:9339",
"timestamp": 1730120826528664430,
"time": "2024-10-28T13:07:06.52866443Z",
"updates": [
{
"Path": "ipi:bgp/bgp-instances/bgp-instance[bgp-as=100]",
"values": {
"bgp/bgp-instances/bgp-instance": {
"bgp": {
"bgp-instances": {
"bgp-instance": [
{
"bgp-as": "100",
"config": {
"bgp-as": "100"
},
"peers": {
"peer": [
{
"config": {
"peer-address": "4.4.4.1",
"peer-as": "100"
},
"peer-address": "4.4.4.1",
"state": {
"bgp-peer-state": "idle",
"counters": {
"notification-in": "0",
"notification-out": "0",
"update-message-in": "0",
"update-message-out": "0"
},
"dynamically-configured": "false",
"peer-address": "4.4.4.1",
"peer-as": "100",
"peer-type": "ibgp"
}
},
{
"config": {
"peer-address": "4.4.4.5",
"peer-as": "100"
},
"peer-address": "4.4.4.5",
"state": {
"bgp-peer-state": "idle",
"counters": {
"notification-in": "0",
"notification-out": "0",
"update-message-in": "0",
"update-message-out": "0"
},
"dynamically-configured": "false",
"peer-address": "4.4.4.5",
"peer-as": "100",
"peer-type": "ibgp"
}
}
]
},
"rib": {
"address-family": [
{
"afi": "link-state",
"safi": "link-state",
"state": {
"afi": "link-state",
"safi": "link-state"
}
}
]
},
"state": {
"bgp-as": "100",
"router-run-time-ip-address": "0.0.0.0",
"scan-remain-time": "35",
"table-version": "1",
"total-prefixes": "0",
"version": "4"
}
}
]
}
}
}
}
}
]
}
]
