karimra / gnmic

gNMIc is a gNMI CLI client and collector
https://gnmic.kmrd.dev
Apache License 2.0
217 stars 32 forks source link

gnmi history extension #622

Closed ksator closed 2 years ago

ksator commented 2 years ago

Hello I would like to use gnmic with these 2 diff use cases https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-history.md#1-purpose

but I dont see the gnmic options for these 2 diff use cases Is it already supported? Many thanks in advance for your help!

ksator commented 2 years ago

The gnmi client published on the GH org aristanetworks supports 3 flags for these 2 options https://github.com/aristanetworks/goarista/blob/master/gnmi/client/client.go#L81-L89

Example using this client, to query a database (-addr) about a device (target):


ability to request historical data from the server
there are two kinds:
- snapshot request using -mode=once -history_snapshot=timestamp
- range request using -mode=stream -history_start=timestamp -history_end=timestamp
timestamp must be specified in RFC3339 format

Get interfaces status of a device at a specific time

gnmi -addr=192.0.2.100:443 -token=`cat token.tok` -mode=once -history_snapshot=2021-07-13T09:47:00Z subscribe origin=openconfig target=JPE17471508 "/interfaces/interface[name=Ethernet47]/state/admin-status"
[2021-07-13T09:33:41.479506009Z] (JPE17471508) /interfaces/interface[name=Ethernet47]/state/admin-status = DOWN

Get interface status of a device at a specified time range

gnmi -addr=192.0.2.100:443 -token=`cat token.tok` -mode=stream -history_start=2021-07-13T09:47:00Z -history_end=2021-07-13T09:51:00Z subscribe origin=openconfig target=JPE17471508 "/interfaces/interface[name=Ethernet47]/state/admin-status"
[2021-07-13T09:47:34.67759454Z] (JPE17471508) /interfaces/interface[name=Ethernet47]/state/admin-status = DOWN
[2021-07-13T09:47:31.195992481Z] (JPE17471508) /interfaces/interface[name=Ethernet47]/state/admin-status = UP
[2021-07-13T09:33:41.479506009Z] (JPE17471508) /interfaces/interface[name=Ethernet47]/state/admin-status = DOWN```
karimra commented 2 years ago

Hi @ksator, This is not currently supported. I will look into implementing it. Thanks

ksator commented 2 years ago

Thank you @karimra !

karimra commented 2 years ago

welcome, please try v0.26.0 and let me know how it goes.

ksator commented 2 years ago

Hello @karimra

These ones are working:

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                                                                                                                                                         ```

Thank you so much!
You can close this issue