aristanetworks/goarista

parsing the gNMI path

Closed this issue · 1 comments

Hi,

I just wanted to know what is the best way of parsing the gNMI path. here is some data that I am getting from the Arista box:

map[/interfaces/interface[name=Port-Channel226]/state/counters/out-unicast-pkts:598230893]
map[/interfaces/interface[name=Port-Channel224]/state/counters/in-unicast-pkts:208183099]
map[/interfaces/interface[name=Port-Channel224]/state/counters/out-multicast-pkts:8616378]
map[/interfaces/interface[name=Port-Channel224]/state/counters/out-unicast-pkts:327460909]
map[/interfaces/interface[name=Port-Channel224]/state/counters/in-octets:88626871847]
map[/interfaces/interface[name=Port-Channel224]/state/counters/out-octets:372953173718]
map[/interfaces/interface[name=Port-Channel221]/state/counters/in-unicast-pkts:335453344]
map[/interfaces/interface[name=Port-Channel221]/state/counters/out-unicast-pkts:674831508]
map[/interfaces/interface[name=Port-Channel221]/state/counters/in-octets:119804970761]
map[/interfaces/interface[name=Port-Channel221]/state/counters/out-octets:864045654312]
map[/interfaces/interface[name=Port-Channel221]/state/counters/out-multicast-pkts:8616934]
map[/interfaces/interface[name=Port-Channel200]/state/counters/out-unicast-pkts:3753840804]
map[/interfaces/interface[name=Port-Channel200]/state/counters/out-octets:2738173779493]
map[/interfaces/interface[name=Port-Channel200]/state/counters/in-unicast-pkts:3144894501]
map[/interfaces/interface[name=Port-Channel200]/state/counters/out-multicast-pkts:8616981]
map[/interfaces/interface[name=Port-Channel200]/state/counters/in-octets:351296153373]
map[/interfaces/interface[name=Port-Channel222]/state/counters/in-multicast-pkts:437702]
map[/interfaces/interface[name=Port-Channel222]/state/counters/out-octets:908188033189]
map[/interfaces/interface[name=Port-Channel222]/state/counters/out-unicast-pkts:708918871]
map[/interfaces/interface[name=Port-Channel222]/state/counters/in-unicast-pkts:370284215]
map[/interfaces/interface[name=Port-Channel222]/state/counters/out-multicast-pkts:8608520]
map[/interfaces/interface[name=Port-Channel222]/state/counters/in-octets:106991631465]
map[/interfaces/interface[name=Port-Channel223]/state/counters/out-multicast-pkts:8616366]
map[/interfaces/interface[name=Port-Channel223]/state/counters/out-octets:369357998866]
map[/interfaces/interface[name=Port-Channel223]/state/counters/in-unicast-pkts:196088837]
map[/interfaces/interface[name=Port-Channel223]/state/counters/out-unicast-pkts:338519621]
map[/interfaces/interface[name=Port-Channel223]/state/counters/in-octets:97310470424]

I am trying to create a struct for each interface and save the values.

Thanks,

The schema for this data comes from the openconfig-interfaces YANG model.

A couple suggestions on how to process this data:
The OpenConfig group created ygot which can turn YANG types into Go structs or protocol buffer messages.

The OpenConfig group also provides a gnmi client library that among other things provides a "persistence layer for all notifications. The notifications build up an internal tree which can be queried and walked using CacheClient's methods."