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

Support for space in gnmi path #15405

Open
dangleminh opened this issue May 27, 2024 · 5 comments
Open

Support for space in gnmi path #15405

dangleminh opened this issue May 27, 2024 · 5 comments
Assignees
Labels
feature request Requests for new plugin and for new features to existing plugins upstream bug or issues that rely on dependency fixes

Comments

@dangleminh
Copy link

Use Case

We are using gnmi input but seems space doesnt work for path, please see below:

[[inputs.gnmi.subscription]]
    name = "show_version"
    origin = "cli"
    subscription_mode = "sample"
    path = "show version"
    sample_interval = "10s"

Getting the error:

root@telegraf:/tmp# tail -n 10 /var/log/telegraf/telegraf.log
2024-05-27T12:53:55Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-05-27T12:53:55Z I! Loaded inputs: gnmi
2024-05-27T12:53:55Z I! Loaded aggregators: 
2024-05-27T12:53:55Z I! Loaded processors: 
2024-05-27T12:53:55Z I! Loaded secretstores: 
2024-05-27T12:53:55Z I! Loaded outputs: file influxdb_v2
2024-05-27T12:53:55Z I! Tags enabled: host=telegraf
2024-05-27T12:53:55Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"telegraf", Flush Interval:10s
2024-05-27T12:53:55Z D! [agent] Initializing plugins
2024-05-27T12:53:55Z E! [telegraf] Error running agent: could not initialize input inputs.gnmi: invalid string path show version: invalid node name: "show version"

Expected behavior

path is required space as every cli in the network OS contains space. Openconfig gnmic can support space as below:

root@telegraf:/etc/telegraf# gnmic -a <ip>:6030 -u <username> -p <password> --insecure  --gzip get --path "cli:/show version"
[
  {
    "source": "10.0.0.101:6030",
    "timestamp": 1716814647867157162,
    "time": "2024-05-27T12:57:27.867157162Z",
    "updates": [
      {
        "Path": "cli:show version",
        "values": {
          "show version": {
            "architecture": "i686",
            "bootupTimestamp": 1716573325.0758307,
            "configMacAddress": "00:00:00:00:00:00",
            "hardwareRevision": "",
            "hwMacAddress": "00:00:00:00:00:00",
            "imageFormatVersion": "1.0",
            "imageOptimization": "None",
            "internalBuildId": "9d8310d2-cc5a-4c85-b6ef-08ce13f0255f",
            "internalVersion": "4.31.2F-35442146.4312F",
            "isIntlVersion": false,
            "memFree": 791188,
            "memTotal": 1979896,
            "mfgName": "Arista",
            "modelName": "vEOS-lab",
            "serialNumber": "A71651D2A2FCA4E3B45AFC452C440CDF",
            "systemMacAddress": "0c:6e:eb:30:b0:13",
            "uptime": 241323.16,
            "version": "4.31.2F"
          }
        }
      }
    ]
  }
]
root@telegraf:/etc/telegraf# 

Actual behavior

Openconfig gnmic can support space as below:

root@telegraf:/etc/telegraf# gnmic -a <ip>:6030 -u <username> -p <password> --insecure  --gzip get --path "cli:/show version"
[
  {
    "source": "10.0.0.101:6030",
    "timestamp": 1716814647867157162,
    "time": "2024-05-27T12:57:27.867157162Z",
    "updates": [
      {
        "Path": "cli:show version",
        "values": {
          "show version": {
            "architecture": "i686",
            "bootupTimestamp": 1716573325.0758307,
            "configMacAddress": "00:00:00:00:00:00",
            "hardwareRevision": "",
            "hwMacAddress": "00:00:00:00:00:00",
            "imageFormatVersion": "1.0",
            "imageOptimization": "None",
            "internalBuildId": "9d8310d2-cc5a-4c85-b6ef-08ce13f0255f",
            "internalVersion": "4.31.2F-35442146.4312F",
            "isIntlVersion": false,
            "memFree": 791188,
            "memTotal": 1979896,
            "mfgName": "Arista",
            "modelName": "vEOS-lab",
            "serialNumber": "A71651D2A2FCA4E3B45AFC452C440CDF",
            "systemMacAddress": "0c:6e:eb:30:b0:13",
            "uptime": 241323.16,
            "version": "4.31.2F"
          }
        }
      }
    ]
  }
]
root@telegraf:/etc/telegraf# 

Additional info

No response

@dangleminh dangleminh added the feature request Requests for new plugin and for new features to existing plugins label May 27, 2024
@dangleminh dangleminh changed the title Support for space in path Support for space in gnmi path May 27, 2024
@powersj
Copy link
Contributor

powersj commented May 29, 2024

Hi,

The error comes from the gnxi library we use, which checks the node name against a regex. As the code comment states, hat regex comes from RFC 6020 which states:

Identifiers are used to identify different kinds of YANG items by
   name.  Each identifier starts with an uppercase or lowercase ASCII
   letter or an underscore character, followed by zero or more ASCII
   letters, digits, underscore characters, hyphens, and dots.
   Implementations MUST support identifiers up to 64 characters in
   length.  Identifiers are case sensitive.  The identifier syntax is
   formally defined by the rule "identifier" in [Section 12](https://datatracker.ietf.org/doc/html/rfc6020#section-12).  Identifiers
   can be specified as quoted or unquoted strings.

Note, spaces or whitespace are not included in this. There is a discussion about whitespace and escaping right before this section in 6.1.3. @srebhan will ask upstream for confirmation as to the support of whitespace.

@srebhan
Copy link
Contributor

srebhan commented May 31, 2024

@dangleminh I asked for clarification of the standard in openconfig/reference#209, let's wait for an answer and then see how we continue...

@srebhan srebhan added the upstream bug or issues that rely on dependency fixes label May 31, 2024
@noredistribution
Copy link

noredistribution commented May 31, 2024

steering away from this convo a bit but any reason why you cannot use the EOS native + the OpenConfig paths to read the same info, for instance EOS version information is stored in /Eos/image


gnmic -a 10.1.1.1:6030 -u admin -p admin --gzip --insecure get --path "eos_native:/Eos/image"
[
  {
    "source": "10.1.1.1:6030",
    "timestamp": 1716995120650759369,
    "time": "2024-05-29T16:05:20.650759369+01:00",
    "prefix": "eos_native:Eos/image",
    "updates": [
      {
        "Path": "serialNum",
        "values": {
          "serialNum": "65312759-2bab-4913-9769-0aebaaf046dc"
        }
      },
      {
        "Path": "version",
        "values": {
          "version": "4.31.3M"
        }
      },
      {
        "Path": "buildHost",
        "values": {
          "buildHost": "dhcp-244-252-129.sjc.aristanetworks.com"
        }
      },
      {
        "Path": "buildTime",
        "values": {
          "buildTime": 1714379144000000000
        }
      },
      {
        "Path": "name",
        "values": {
          "name": "image"
        }
      },
      {
        "Path": "flavor",
        "values": {
          "flavor": "DEFAULT"
        }
      },
      {
        "Path": "release",
        "values": {
          "release": "36737551.4313M"
        }
      },
      {
        "Path": "variant",
        "values": {
          "variant": "US"
        }
      },
      {
        "Path": "arch",
        "values": {
          "arch": "x86_64"
        }
      },
      {
        "Path": "blessed",
        "values": {
          "blessed": true
        }
      },
      {
        "Path": "displayVersion",
        "values": {
          "displayVersion": "4.31.3M"
        }
      }
    ]
  }
]

serial number can be found in OC in /components/component/state/serial-no
system mac address in OC in /components/component/state/base-mac-address
MemAvailable and MemUtilized are in /components/component/state/memory

HTH!

@josh-silvas
Copy link

josh-silvas commented Jun 5, 2024

Just wanted to add on here, as I am running into the same issue, however, there doesn't appear to be a eos_native or openconfig spec on the information I need.

gnmic -a  10.10.10.10:6030 -u admin -p admin --insecure get --gzip --encoding json --path "cli:/show dot1x hosts"

Output:

[
  {
    "source": "10.10.10.10:6030",
    "timestamp": 1717620389701535774,
    "time": "2024-06-05T15:46:29.701535774-05:00",
    "updates": [
      {
        "Path": "cli:show dot1x hosts",
        "values": {
          "show dot1x hosts": {
            "intfSupplicantsDict": {
              "Ethernet10": {
                "supplicants": {
                  "aa:aa:de:ad:be:ef": {
                    "authMethod": "EAPOL",
                    "authStage": "SUCCESS",
                    "cachedAuthAtLinkDown": false,
                    "fallback": "NONE",
                    "reauthTimeoutSeen": false,
                    "supplicantMac": "aa:aa:de:ad:be:ef",
                    "vlanId": ""
                  }
                }
              }
            }
          }
        }
      }
    ]
  }
]

But I am receiving a similar error:

Error running agent: could not initialize input inputs.gnmi: invalid string path show dot1x hosts: invalid node name: "show dot1x hosts"

@srebhan
Copy link
Contributor

srebhan commented Jun 6, 2024

@josh-silvas you are running a get but the plugin only supports subscriptions... Did you try with subscribing to that path?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins upstream bug or issues that rely on dependency fixes
Projects
None yet
Development

No branches or pull requests

5 participants