Closed PatBoEPFL closed 1 month ago
Try moving the / after the : in the path
Here is the output (hopefully I did understand you correctly):
$ gnmic --skip-verify -a <switch-fqdn>:8080 -u admin -p '<password>' get --path "openconfig-interfaces:/interfaces/interface[name=Ethernet10]/state/counters"
[
{
"source": "sw-t-in-s19-pod1-lf1.xaas.epfl.ch:8080",
"timestamp": 1717493251746880522,
"time": "2024-06-04T11:27:31.746880522+02:00",
"updates": [
{
"Path": "openconfig-interfaces:openconfig-interfaces:interfaces/interface[name=Ethernet10]/state/counters",
"values": {
"openconfig-interfaces:interfaces/interface/state/counters": null
}
}
]
}
]
I tried also two path variants:
$ gnmic --skip-verify -a <switch-fqnd>:8080 -u admin -p '<password>' get --path "/interfaces/interface[name=Ethernet10]/state/counters"
[
{
"source": "sw-t-in-s19-pod1-lf1.xaas.epfl.ch:8080",
"timestamp": 1717493695400886222,
"time": "2024-06-04T11:34:55.400886222+02:00",
"updates": [
{
"Path": "openconfig-interfaces:interfaces/interface[name=Ethernet10]/state/counters",
"values": {
"openconfig-interfaces:interfaces/interface/state/counters": null
}
}
]
}
]
$ gnmic --skip-verify -a <switch-fqdn>:8080 -u admin -p '<password>' get --path "interfaces/interface[name=Ethernet10]/state/counters"
[
{
"source": "sw-t-in-s19-pod1-lf1.xaas.epfl.ch:8080",
"timestamp": 1717493707277195478,
"time": "2024-06-04T11:35:07.277195478+02:00",
"updates": [
{
"Path": "openconfig-interfaces:interfaces/interface[name=Ethernet10]/state/counters",
"values": {
"openconfig-interfaces:interfaces/interface/state/counters": null
}
}
]
}
]
All those variants show the same result.
Ok, maybe the good path forward is to leverage gnmic's flags to enable the printout of the request in the prototext format and compare it with the prototext format you got from gnmi_get tool
you need to add
--format prototext --print-request
Here is the output with those two more flags:
$ gnmic --skip-verify -a <switch-fqdn>:8080 -u admin -p '<password>' get --path "interfaces/interface[name=Ethernet10]/state/counters" --format prototext --print-request
path: {
elem: {
name: "interfaces"
}
elem: {
name: "interface"
key: {
key: "name"
value: "Ethernet10"
}
}
elem: {
name: "state"
}
elem: {
name: "counters"
}
}
Get Response:
notification: {
timestamp: 1717503002822758800
update: {
path: {
elem: {
name: "openconfig-interfaces:interfaces"
}
elem: {
name: "interface"
key: {
key: "name"
value: "Ethernet10"
}
}
elem: {
name: "state"
}
elem: {
name: "counters"
}
}
val: {}
}
}
Another way to write null output for val ;-)
Add -e json_ietf
to your gnmic command
Hello,
It works:
$ gnmic --skip-verify -a <switch-fqdn>:8080 -u admin -p '<password>' get --path "interfaces/interface[name=Ethernet10]/state/counters" --format prototext --print-request -e json_ietf
Get Request:
path: {
elem: {
name: "interfaces"
}
elem: {
name: "interface"
key: {
key: "name"
value: "Ethernet10"
}
}
elem: {
name: "state"
}
elem: {
name: "counters"
}
}
encoding: JSON_IETF
Get Response:
notification: {
timestamp: 1717577544652442254
update: {
path: {
elem: {
name: "openconfig-interfaces:interfaces"
}
elem: {
name: "interface"
key: {
key: "name"
value: "Ethernet10"
}
}
elem: {
name: "state"
}
elem: {
name: "counters"
}
}
val: {
json_ietf_val: "{\"openconfig-interfaces:counters\":{\"in-bits-per-second\":\"0\",\"in-broadcast-pkts\":\"55\",\"in-discards\":\"0\",\"in-errors\":\"0\",\"in-multicast-pkts\":\"39771\",\"in-octets\":\"8937943\",\"in-octets-per-second\":\"0\",\"in-pkts\":\"49188\",\"in-pkts-per-second\":\"0\",\"in-unicast-pkts\":\"9362\",\"in-utilization\":0,\"last-clear\":\"0\",\"out-bits-per-second\":\"1508632\",\"out-broadcast-pkts\":\"102625805\",\"out-discards\":\"0\",\"out-errors\":\"0\",\"out-multicast-pkts\":\"9383004\",\"out-octets\":\"39442583645\",\"out-octets-per-second\":\"188579\",\"out-pkts\":\"115556271\",\"out-pkts-per-second\":\"376\",\"out-unicast-pkts\":\"3547163\",\"out-utilization\":0}}"
}
}
}
And with only the -e json_ietf
flag:
$ gnmic --skip-verify -a <switch-fqdn>:8080 -u admin -p '<password>' get --path "interfaces/interface[name=Ethernet10]/state/counters" -e json_ietf
[
{
"source": "sw-t-in-s19-pod1-lf1.xaas.epfl.ch:8080",
"timestamp": 1717577555938484391,
"time": "2024-06-05T10:52:35.938484391+02:00",
"updates": [
{
"Path": "openconfig-interfaces:interfaces/interface[name=Ethernet10]/state/counters",
"values": {
"openconfig-interfaces:interfaces/interface/state/counters": {
"openconfig-interfaces:counters": {
"in-bits-per-second": "0",
"in-broadcast-pkts": "55",
"in-discards": "0",
"in-errors": "0",
"in-multicast-pkts": "39771",
"in-octets": "8937943",
"in-octets-per-second": "0",
"in-pkts": "49188",
"in-pkts-per-second": "0",
"in-unicast-pkts": "9362",
"in-utilization": 0,
"last-clear": "0",
"out-bits-per-second": "927656",
"out-broadcast-pkts": "102629786",
"out-discards": "0",
"out-errors": "0",
"out-multicast-pkts": "9383139",
"out-octets": "39443846396",
"out-octets-per-second": "115957",
"out-pkts": "115560459",
"out-pkts-per-second": "395",
"out-unicast-pkts": "3547417",
"out-utilization": 0
}
}
}
}
]
}
]
Many thanks :-)
Hello,
I'm trying to use gnmic to get information and counters of Dell SONiC switches. Using the gnmi_get command works (https://github.com/google/gnxi), but the path returns "null" gnmic get command.
The same with gnmi_get:
I've tested this Dell SONiC 4.1.2, with different paths and only get 'null" as response. I couldn't any flags that I may have added.
Best regards, Patrice