Skip to content

Global flags

address#

The address flag [-a | --address] is used to specify the target's gNMI server address in address:port format, for e.g: 192.168.113.11:57400

Multiple target addresses can be specified, either as comma separated values:

gnmic --address 192.168.113.11:57400,192.168.113.12:57400 

or by using the --address flag multiple times:

gnmic -a 192.168.113.11:57400 --address 192.168.113.12:57400

auth-scheme#

The auth-scheme flag --auth-scheme is used to specify the authorization header type. For example, if auth-scheme is set to Basic, the gNMI requests headers will include an Authorization header with value Basic base64enc(username:password).

cluster-name#

The [--cluster-name] flag is used to specify the cluster name the gnmic instance will join.

The cluster name is used as part of the locked keys to share targets between multiple gnmic instances.

Defaults to default-cluster

config#

The --config flag specifies the location of a configuration file that gnmic will read.

If not specified, gnmic searches for a file named .gnmic with extensions yaml, yml, toml or json in the following locations:

  • $PWD
  • $HOME
  • $XDG_CONFIG_HOME
  • $XDG_CONFIG_HOME/gnmic

debug#

The debug flag [-d | --debug] enables the printing of extra information when sending/receiving an RPC

dir#

A path to a directory which gnmic would recursively traverse in search for the additional YANG files which may be required by YANG files specified with --file to build the YANG tree.

Can also point to a single YANG file instead of a directory.

Multiple --dir flags can be supplied.

encoding#

The encoding flag [-e | --encoding] is used to specify the gNMI encoding of the Update part of a Notification message.

It is case insensitive and must be one of: JSON, BYTES, PROTO, ASCII, JSON_IETF

exclude#

The --exclude flag specifies the YANG module names to be excluded from the tree generation when YANG modules names clash.

Multiple --exclude flags can be supplied.

file#

A path to a YANG file or a directory with YANG files which gnmic will use with prompt, generate and path commands.

Multiple --file flags can be supplied.

format#

Five output formats can be configured by means of the --format flag. [proto, protojson, prototext, json, event] The default format is json.

The proto format outputs the gnmi message as raw bytes, this value is not allowed when the output type is file (file system, stdout or stderr) see outputs

The prototext and protojson formats are the message representation as defined in prototext and protojson

The event format emits the received gNMI SubscribeResponse updates and deletes as a list of events tagged with the keys present in the subscribe path (as well as some metadata) and a timestamp

Here goes an example of the same response emitted to stdout in the respective formats:

{
  "update": {
  "timestamp": "1595584408456503938",
  "prefix": {
    "elem": [
      {
        "name": "state"
      },
      {
        "name": "system"
      },
      {
        "name": "version"
      }
    ]
  },
    "update": [
      {
        "path": {
          "elem": [
            {
             "name": "version-string"
           }
          ]
        },
        "val": {
          "stringVal": "TiMOS-B-20.5.R1 both/x86_64 Nokia 7750 SR Copyright (c) 2000-2020 Nokia.\r\nAll rights reserved. All use subject to applicable license agreements.\r\nBuilt on Wed May 13 14:08:50 PDT 2020 by builder in /builds/c/205B/R1/panos/main/sros"
        }
      }
    ]
  }
}
update: {
  timestamp: 1595584168675434221
  prefix: {
    elem: {
      name: "state"
    }
    elem: {
      name: "system"
    }
    elem: {
      name: "version"
    }
  }
  update: {
    path: {
      elem: {
        name: "version-string"
      }
    }
    val: {
      string_val: "TiMOS-B-20.5.R1 both/x86_64 Nokia 7750 SR Copyright (c) 2000-2020 Nokia.\r\nAll rights reserved. All use subject to applicable license agreements.\r\nBuilt on Wed May 13 14:08:50 PDT 2020 by builder in /builds/c/205B/R1/panos/main/sros"
    }
  }
}
{
  "source": "172.17.0.100:57400",
  "subscription-name": "default",
  "timestamp": 1595584326775141151,
  "time": "2020-07-24T17:52:06.775141151+08:00",
  "prefix": "state/system/version",
  "updates": [
    {
      "Path": "version-string",
      "values": {
        "version-string": "TiMOS-B-20.5.R1 both/x86_64 Nokia 7750 SR Copyright (c) 2000-2020 Nokia.\r\nAll rights reserved. All use subject to applicable license agreements.\r\nBuilt on Wed May 13 14:08:50 PDT 2020 by builder in /builds/c/205B/R1/panos/main/sros"
      }
    }
  ]
}
[
  {
    "name": "default",
    "timestamp": 1595584587725708234,
    "tags": {
      "source": "172.17.0.100:57400",
      "subscription-name": "default"
    },
    "values": {
      "/state/system/version/version-string": "TiMOS-B-20.5.R1 both/x86_64 Nokia 7750 SR Copyright (c) 2000-2020 Nokia.\r\nAll rights reserved. All use subject to applicable license agreements.\r\nBuilt on Wed May 13 14:08:50 PDT 2020 by builder in /builds/c/205B/R1/panos/main/sros"
    }
  }
]

gzip#

The [--gzip] flag enables gRPC gzip compression.

insecure#

The insecure flag [--insecure] is used to indicate that the client wishes to establish an non-TLS enabled gRPC connection.

To disable certificate validation in a TLS-enabled connection use skip-verify flag.

instance-name#

The [--instance-name] flag is used to give a unique name to the running gnmic instance. This is useful when there are multiple instances of gnmic running at the same time, either for high-availability and/or scalability

log#

The --log flag enables log messages to appear on stderr output. By default logging is disabled.

log-file#

The log-file flag [--log-file <path>] sets the log output to a file referenced by the path. This flag supersede the --log flag

log-max-size#

The [--log-max-size] flag enables log rotation and sets the maximum size of the log file in megabytes before it gets rotated.

log-max-backups#

The [--log-max-backups] flag sets the maximum number of old log files to retain. The default is to retain all old log files.

log-compress#

The [--log-compress] flag determines if the rotated log files should be compressed using gzip. The default is not to perform compression.

no-prefix#

The no prefix flag [--no-prefix] disables prefixing the json formatted responses with [ip:port] string.

Note that in case a single target is specified, the prefix is not added.

password#

The password flag [-p | --password] is used to specify the target password as part of the user credentials.

Note that in case multiple targets are used, all should use the same credentials.

proto-dir#

The [--proto-dir] flag is used to specify a list of directories where gnmic will search for the proto file names specified with --proto-file.

proto-file#

The [--proto-file] flag is used to specify a list of proto file names that gnmic will use to decode ProtoBytes values. only Nokia SROS proto is currently supported.

proxy-from-env#

The proxy-from-env flag [--proxy-from-env] indicates that the gnmic should use the HTTP/HTTPS proxy addresses defined in the environment variables http_proxy and https_proxy to reach the targets specified using the --address flag.

retry#

The retry flag [--retry] specifies the wait time before each retry.

Valid formats: 10s, 1m30s, 1h. Defaults to 10s

skip-verify#

The skip verify flag [--skip-verify] indicates that the target should skip the signature verification steps, in case a secure connection is used.

targets-file#

The [--targets-file] flag is used to configure a file target loader

timeout#

The timeout flag [--timeout] specifies the gRPC timeout after which the connection attempt fails.

Valid formats: 10s, 1m30s, 1h. Defaults to 10s

tls-ca#

The TLS CA flag [--tls-ca] specifies the root certificates for verifying server certificates encoded in PEM format.

tls-cert#

The TLS cert flag [--tls-cert] specifies the public key for the client encoded in PEM format.

tls-key#

The TLS key flag [--tls-key] specifies the private key for the client encoded in PEM format.

tls-max-version#

The TLS max version flag [--tls-max-version] specifies the maximum supported TLS version supported by gNMIc when creating a secure gRPC connection.

tls-min-version#

The tls min version flag [--tls-min-version] specifies the minimum supported TLS version supported by gNMIc when creating a secure gRPC connection.

tls-server-name#

The TLS server name flag [--tls-server-name] sets the server name to be used when verifying the hostname on the returned certificates unless --skip-verify is set.

This global flag applies to all targets.

tls-version#

The tls version flag [--tls-version] specifies a single supported TLS version gNMIc when creating a secure gRPC connection.

This flag overwrites the previously listed flags --tls-max-version and --tls-min-version.

log-tls-secret#

The log TLS secret flag [--log-tls-secret] makes gnmic to log the per-session pre-master secret so that it can be used to decrypt TLS secured gNMI communications with, for example, Wireshark.

The secret will be saved to a file named <target-name>.tlssecret.log.

token#

The token flag [--token] sets a token value to be added to each RPC as an Authorization Bearer Token.

Applied only in the case of a secure gRPC connection.

username#

The username flag [-u | --username] is used to specify the target username as part of the user credentials.

calculate-latency#

The --calculate-latency flag augments subscribe et get responses by calculating the delta between the message timestamp and the receive timestamp. The resulting message will include 4 extra fields:

  • recv-timestamp:The receive timestamp in nanoseconds.
  • recv-time: The receive time in ISO 8601 date and time representation, extended to include fractional seconds and a time zone offset..
  • latency-nano: The difference between the message timestamp and the receive time in nanoseconds.
  • latency-milli: The difference between the message timestamp and the receive time in milliseconds.

metadata#

The [-H | --metadata] flag adds custom headers to any gRPC request. gnmic -H header1=value1 -H header2=value2