Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inputs.cisco_telemetry_gnmi crashes when request a specific field #6847

Closed
door7302 opened this issue Jan 2, 2020 · 2 comments · Fixed by #6848
Closed

inputs.cisco_telemetry_gnmi crashes when request a specific field #6847

door7302 opened this issue Jan 2, 2020 · 2 comments · Fixed by #6848
Labels
bug unexpected problem or unintended behavior panic issue that results in panics from Telegraf
Milestone

Comments

@door7302
Copy link
Contributor

door7302 commented Jan 2, 2020

Hello

when we request a specific field (full path) the plugin crashes and stops

Sample config :

[[inputs.cisco_telemetry_gnmi]]

  addresses = [
        "xxxxxx:57400"
        ]
  encoding = "json"
  redial = "30s"

  [[inputs.cisco_telemetry_gnmi.subscription]]
    name = "PHY_COUNTERS"
    path = "/state/port[port-id=*]/ethernet/oper-speed"
    subscription_mode = "sample"
    sample_interval = "30s"

And the crash info :

2020-01-02T14:48:23Z I! Starting Telegraf
panic: runtime error: slice bounds out of range

goroutine 27 [running]:
github.com/influxdata/telegraf/plugins/inputs/cisco_telemetry_gnmi.(*CiscoTelemetryGNMI).handleSubscribeResponse(0xc00068f1e0, 0xc000059941, 0xe, 0xc0001d0be0)
        /opt/src/github.com/influxdata/telegraf/plugins/inputs/cisco_telemetry_gnmi/cisco_telemetry_gnmi.go:285 

Actually in this case at line 285 of the cisco_telemetry_gnmi.go the aliasPath == key therefor key[len(aliasPath)+1:] failed.

if len(aliasPath) > 0 {
key = key[len(aliasPath)+1:]
}

To avoid that I added a second check like that :

if len(aliasPath) > 0 && len(key) != len(aliasPath) {
key = key[len(aliasPath)+1:]
}

Could you add this fix ???

BR
David

@danielnelson danielnelson added bug unexpected problem or unintended behavior panic issue that results in panics from Telegraf labels Jan 2, 2020
@danielnelson danielnelson added this to the 1.13.1 milestone Jan 2, 2020
@danielnelson
Copy link
Contributor

If the path is fully specified maybe we should use the last component as the field key, in this case oper_speed. I think this gives a better progression as you increase the length of the path:

  • path: /state
    • key: port/ethernet/oper_speed
  • path: /state/port[port-id=*]
    • key: ethernet/oper_speed
  • path: /state/port[port-id=*]/ethernet
    • key: oper_speed
  • path: /state/port[port-id=*]/ethernet/oper-speed
    • key: oper_speed

I created #6848 with this strategy (and some test changes), what do you think about this method?

cc @sbyx

@door7302
Copy link
Contributor Author

door7302 commented Jan 3, 2020

Hello,

Cool. Your solution is better.

Thanks.
David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior panic issue that results in panics from Telegraf
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants