openconfig / gnmi

gRPC Network Management Interface
Apache License 2.0
478 stars 197 forks source link

How do I set the subscription mode to either "ON_CHANGE/STREAM" or "SAMPLE/POLL" with the "gnmi_client" command? #83

Closed LukeCage closed 4 years ago

LukeCage commented 4 years ago

I am unable to subscribe to and collect streaming telemetry data from my remote devices. Can someone help me construct the command. An example of a command that works for "ON_CHANGE" (default?) based subscription mode is below:

-bash-4.2$ ./gnmi_cli -a 10.111.27.8:6702 -client_crt client_https_rsa40965.cert.pem -client_key client_https_rsa40965.key.pem -with_user_pass -dt s -client_types gnmi -insecure -updates_only -qt s -q /al:alarm-notification

According to github documentation, on-line, the command takes the following form:

gnmi_cli -address localhost:10161 \ -proto "subscribe:<mode: 0, prefix:<>, subscription:<mode:0, path: <elem: <name: 'openconfig-system:system'> elem: <name: 'clock' > elem: <name: 'config'> elem: <name: 'timezone-name'>>>>" \ -timeout 5s -alsologtostderr \ -polling_interval 5s \ -client_crt certs/client1.crt -client_key certs/client1.key -ca_crt certs/onfca.crt

So, it appears that I have to set the subscription mode (to "SAMPLE") via the -proto option. How would I do this? Every command I issued fails.

hellt commented 4 years ago

Hi @LukeCage dont mean to step on openconfig/gnmi toes, but if you will exhaust your options with the reference client, I encourage you to try out the other client - https://gnmic.kmrd.dev - it uses openconfig/gnmi as a backend lib.

It is heavily documented and your case should be solved easily with the cli flags

LukeCage commented 4 years ago

Thanks for your reply, @hellt ...

My problem is that I don't have super user privileges to install your app on the server, so I am committed (like it or not) to use this one. I would like to try yours though and hope to access a server that will allow me to do so.

Cheers.

hellt commented 4 years ago

you don't need sudo rights, you can download the binary manually from the releases, having only curl/wget https://github.com/karimra/gnmic/releases/tag/v0.4.1

gcsl commented 4 years ago

I see you have SAMPLE in quotes in your text. An ENUM is not quoted in a text proto. Try adding

-proto "subscribe:<subscription:<path:<elem:<name:'openconfig-system:system> elem: <name: clock'> elem: <name: 'config'> elem: <name: 'timezone-name'>> mode: SAMPLE sample_interval: 5000000000>>"

leave the -timeout and -polling_interval off. -timeout will terminate before your second response and -polling_interval is for polling mode where client (the cli in this case) triggers the retrieval of data.

Not knowing what server you are using, but the yang module name should not appear in the gNMI path and the prefix< origin: "openconfig">> may need to be set.

On Thu, Oct 22, 2020 at 1:26 PM Luke Cage notifications@github.com wrote:

I am unable to subscribe to and collect streaming telemetry data from my remote devices. Can someone help me construct the command. An example of a command that works for "ON_CHANGE" (default?) based subscription mode is below:

-bash-4.2$ ./gnmi_cli -a 10.111.27.8:6702 -client_crt client_https_rsa40965.cert.pem -client_key client_https_rsa40965.key.pem -with_user_pass -dt s -client_types gnmi -insecure -updates_only -qt s -q /al:alarm-notification

According to github documentation, on-line, the command takes the following form:

gnmi_cli -address localhost:10161 -proto "subscribe:<mode: 0, prefix:<>, subscription:<mode:0, path: <elem: <name: 'openconfig-system:system'> elem: <name: 'clock' > elem: <name: 'config'> elem: <name: 'timezone-name'>>>>" -timeout 5s -alsologtostderr -polling_interval 5s -client_crt certs/client1.crt -client_key certs/client1.key -ca_crt certs/onfca.crt

So, it appears that I have to set the subscription mode (to "SAMPLE") via the -proto option. How would I do this? Every command I issued fails.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openconfig/gnmi/issues/83, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEL4QL7V2OA5ULNXK7PA2PDSMBTMHANCNFSM4S3QAJ7A .

LukeCage commented 4 years ago

HI @gcsl ...

You example has 6 "<" and 7 ">" so I am not sure how they all match as one command.

Your open and closed quotes seem suspect to me also. So, it is hard for me to interpret accurately what you are trying to communicate to me.

Thanks,

Luke

LukeCage commented 4 years ago

Hi @hellt ,

I downloaded the compressed tar-ball and tried to run the gNMIc client but I got the following message:

-bash-4.2$ ./gnmic -a 10.111.22.194:6702 -u luke -p cage --insecure capabilities --log gnmic 2020/10/26 13:03:04.235019 failed to create a gRPC client for target '10.111.22.194:6702', timeout (10s) reached

Clearly, if a gRPC connection is not established between the client and server, gNMIc will not work. What do you think my problem might be here?

Thanks,

Luke.

hellt commented 4 years ago

@LukeCage can be many things, which are likely have to be with the gnmi target configution.

Things I'd have tried:

  1. Add --debug flag to see if any low-level log messages will be helpful.
  2. check target config to see if it allows unsecured connections (--insecure flag in gnmic will not not use TLS setup). If target is configured to use TLS certs, than use --skip-verify flag instead.
  3. Check username and password, port.
gcsl commented 4 years ago

Apologies. I was trying to merge a command I had used on one of my devices with the path you had supplied. The suggestion was focused around the two fields in the proto

mode: SAMPLE sample_interval: 5000000000

With no quotes and an embedded sample interval.

On Mon, Oct 26, 2020 at 4:26 PM Luke Cage notifications@github.com wrote:

HI @gcsl https://github.com/gcsl ...

You example has 6 "<" and 7 ">" so I am not sure how they all match as one command.

Your open and closed quotes seem suspect to me also. So, it is hard for me to interpret accurately what you are trying to communicate to me.

Thanks,

Luke

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/openconfig/gnmi/issues/83#issuecomment-716802631, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEL4QL5TMUD2JSZR2C6ZRATSMXLORANCNFSM4S3QAJ7A .

LukeCage commented 4 years ago

Hi @hellt ... The version of the client you are recommending is 0.4.3. Do you not support a higher version gNMI client?

-bash-4.2$ gnmic version version : 0.4.3 commit : 6d3605c date : 2020-11-10T09:47:23Z gitURL : https://github.com/karimra/gnmic docs : https://gnmic.kmrd.dev -bash-4.2$

hellt commented 4 years ago

@LukeCage this is the version of the gnmic client, it has no correlation with gNMI specification version (which is 0.7.0 at this moment, iirc)

In other words, gnmic 0.4.3 can work with gNMI 0.7.0 targets

LukeCage commented 4 years ago

This is a bit of a relief, @hellt. Thanks.

I am not having any luck running simple commands. I was wondering if you can help me with one ... I have tried your documentation but I still am unable to get a response from my device that works with other gNMI clients.

How would you format a command like this (for example):

gnmi_cli -a 10.111.27.8:6702 -client_crt client_https_rsa40965.cert.pem -client_key client_https_rsa40965.key.pem -with_user_pass -dt s -client_types gnmi -insecure -updates_only -qt s -q /al:alarm-notification

hellt commented 4 years ago

@LukeCage

example for Capabilities RPC

gnmic -a 10.111.27.8:6702 --tls-cert client_https_rsa40965.cert.pem --tls-key client_https_rsa40965.key.pem -u <user_name> -p <password> --skip-verify capabilities

add --log --debug to see the logging messages with debug level

LukeCage commented 4 years ago

Thanks, @hellt ...

I'll give that a whirl in the morrow. I appreciate your help!

Luke.

LukeCage commented 4 years ago

@hellt,

When I get an error message as shown below, how do I figure out the correct structure for the string path (xpath?) to provide to gnmic?

-bash-4.2$ gnmic -a 10.111.27.8:6702 --tls-cert client_https_rsa40965.cert.pem --tls-key client_https_rsa40965.key.pem -u admin -p admin --skip-verify \

get --path /ciena-sys-tmet:system-state/memory --debug 2020/11/12 09:02:01 version=0.4.3, commit=6d3605c, date=2020-11-10T09:47:23Z, gitURL=https://github.com/karimra/gnmic, docs=https://gnmic.kmrd.dev Error: path parse error: invalid string path /ciena-sys-tmet:system-state/memory: invalid node name: "ciena-sys-tmet:system-state" -bash-4.2$

LukeCage commented 4 years ago

@hellt,

I tried again but modified the xpath I initially used. I replaced the colon with a "/" and it yielded the following result. Still not successful in getting usable results.

-bash-4.2$ gnmic -a 10.111.27.8:6702 --tls-cert client_https_rsa40965.cert.pem --tls-key client_https_rsa40965.key.pem -u admin -p admin --skip-verify get --path /ciena-sys-tmet/logical-core-count --debug 2020/11/12 09:37:16 version=0.4.3, commit=6d3605c, date=2020-11-10T09:47:23Z, gitURL=https://github.com/karimra/gnmic, docs=https://gnmic.kmrd.dev gnmic 2020/11/12 09:37:16.545572 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: parsed scheme: "" gnmic 2020/11/12 09:37:16.545609 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: scheme "" not registered, fallback to default scheme gnmic 2020/11/12 09:37:16.545652 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: ccResolverWrapper: sending update to cc: {[{10.111.27.8:6702 0 }] } gnmic 2020/11/12 09:37:16.545673 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: ClientConn switching balancer to "pick_first" gnmic 2020/11/12 09:37:16.545689 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Channel switches to new LB policy "pick_first" gnmic 2020/11/12 09:37:16.545746 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Subchannel Connectivity change to CONNECTING gnmic 2020/11/12 09:37:16.545799 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Subchannel picks a new address "10.111.27.8:6702" to connect gnmic 2020/11/12 09:37:16.545833 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:57: pickfirstBalancer: UpdateSubConnState: 0xc0003524e0, {CONNECTING } gnmic 2020/11/12 09:37:16.545851 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Channel Connectivity change to CONNECTING gnmic 2020/11/12 09:37:16.737554 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Subchannel Connectivity change to READY gnmic 2020/11/12 09:37:16.737623 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:57: pickfirstBalancer: UpdateSubConnState: 0xc0003524e0, {READY } gnmic 2020/11/12 09:37:16.737646 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Channel Connectivity change to READY gnmic 2020/11/12 09:37:16.738697 /home/runner/work/gnmic/gnmic/cmd/get.go:119: sending gNMI GetRequest: prefix='', path='[elem:{name:"ciena-sys-tmet"} elem:{name:"logical-core-count"}]', type='ALL', encoding='JSON', models='[]', extension='[]' to 10.111.27.8:6702 gnmic 2020/11/12 09:37:26.739188 /home/runner/work/gnmic/gnmic/cmd/get.go:123: failed sending GetRequest to 10.111.27.8:6702: failed sending GetRequest to '10.111.27.8:6702': rpc error: code = DeadlineExceeded desc = context deadline exceeded -bash-4.2$

hellt commented 4 years ago

@LukeCage first, verify that your transport/auth and TLS works by either calling the Capabilities RPC or the get with path / If either of them works, the transport layer is good.

Now for the actual path that you used, yes, that is a known issue that we for now keep in our backlog... Essentially, the issue roots in the other package that we use for path parsing - https://github.com/google/gnxi/issues/244 According to that package, the path can't contain a : char. So far we were waiting on someone from package maintainers to answer our raised issue, but so far no luck.

So before we went ahead and write our own version of path parsing which will support the : characters in the path I suggest you try the following:

  1. remove the prefix and use the path /system-state/memory
LukeCage commented 4 years ago

Not getting very far with this @hellt

What does the error message "Channel Connectivity change to TRANSIENT_FAILURE" mean? There seems to be a TLS related issue that suspect but I am not sure I am interpreting the message correctly.

gnmic> --address 10.111.22.7:9339 --insecure --username diag --password ciena123 --tls-cert client_https_rsa40965.cert.pem --tls-key client_https_rsa40965.key.pem subscribe --mode stream --stream-mode on-change --path /al/alarm-notification --debug 2020/11/16 14:34:42 version=0.4.3, commit=6d3605c, date=2020-11-10T09:47:23Z, gitURL=https://github.com/karimra/gnmic, docs=https://gnmic.kmrd.dev gnmic 2020/11/16 14:34:42.837441 /home/runner/work/gnmic/gnmic/cmd/subscribe.go:75: targets: map[10.111.22.7:9339:{"Name":"10.111.22.7:9339","Address":"10.111.22.7:9339","Username":"diag","Password":"ciena123","Timeout":10000000000,"Insecure":true,"TLSCA":null,"TLSCert":null,"TLSKey":null,"SkipVerify":false,"Subscriptions":null,"Outputs":null,"BufferSize":0,"RetryTimer":10000000000}] gnmic 2020/11/16 14:34:42.837730 /home/runner/work/gnmic/gnmic/cmd/subscribe.go:82: subscriptions: map[default:{"Name":"default","Models":null,"Prefix":"","Target":"","Paths":["/al/alarm-notification"],"Mode":"stream","StreamMode":"on-change","Encoding":"json","Qos":null,"SampleInterval":0,"HeartbeatInterval":0,"SuppressRedundant":false,"UpdatesOnly":false}] gnmic 2020/11/16 14:34:42.837803 /home/runner/work/gnmic/gnmic/cmd/subscribe.go:89: outputs: map[default-stdout:map[file-type:stdout format: type:file]] gnmic 2020/11/16 14:34:42.837890 /home/runner/work/gnmic/gnmic/collector/collector.go:108: starting collector with cfg=&{PrometheusAddress: Debug:true Format: TargetReceiveBuffer:1000 RetryTimer:10s} gnmic 2020/11/16 14:34:42.838090 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: parsed scheme: "" gnmic 2020/11/16 14:34:42.838114 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: scheme "" not registered, fallback to default scheme gnmic 2020/11/16 14:34:42.838152 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: ccResolverWrapper: sending update to cc: {[{10.111.22.7:9339 0 }] } gnmic 2020/11/16 14:34:42.838182 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: ClientConn switching balancer to "pick_first" gnmic 2020/11/16 14:34:42.838200 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Channel switches to new LB policy "pick_first" gnmic 2020/11/16 14:34:42.838248 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Subchannel Connectivity change to CONNECTING gnmic 2020/11/16 14:34:42.838290 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Subchannel picks a new address "10.111.22.7:9339" to connect file_output 2020/11/16 14:34:42.838786 /home/runner/work/gnmic/gnmic/outputs/file/file.go:110: initialized file output: {"Cfg":{"FileName":"","FileType":"stdout","Format":"json","Multiline":true,"Indent":" ","Separator":"\n"}} gnmic 2020/11/16 14:34:42.838844 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:57: pickfirstBalancer: UpdateSubConnState: 0xc0003e0560, {CONNECTING } gnmic 2020/11/16 14:34:42.838865 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Channel Connectivity change to CONNECTING gnmic 2020/11/16 14:34:42.915291 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:57: transport: loopyWriter.run returning. connection error: desc = "transport is closing" gnmic 2020/11/16 14:34:42.915348 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Subchannel Connectivity change to TRANSIENT_FAILURE gnmic 2020/11/16 14:34:42.915399 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:57: pickfirstBalancer: UpdateSubConnState: 0xc0003e0560, {TRANSIENT_FAILURE connection closed} gnmic 2020/11/16 14:34:42.915422 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: _Channel Connectivity change to TRANSIENTFAILURE gnmic 2020/11/16 14:34:43.915610 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Subchannel Connectivity change to CONNECTING gnmic 2020/11/16 14:34:43.915672 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:49: Subchannel picks a new address "10.111.22.7:9339" to connect gnmic 2020/11/16 14:34:43.915705 /home/runner/go/pkg/mod/google.golang.org/grpc@v1.30.0/grpclog/logger.go:57: pickfirstBalancer: UpdateSubConnState: 0xc0003e0560, {CONNECTING }

hellt commented 4 years ago

@LukeCage for gnmic related questions I think its better to open an issue in gnmic project.

LukeCage commented 4 years ago

OK ... Thanks @hellt ... One more question ... does your gNMI client support a certain version of TLS? If so, what version would that be?