Skip to content

Commit

Permalink
Merge pull request #5 from automixer/huawei
Browse files Browse the repository at this point in the history
Add Huawei NE8000 series support
  • Loading branch information
automixer authored May 3, 2024
2 parents baa9efb + 6b6ea0b commit d54e81f
Show file tree
Hide file tree
Showing 20 changed files with 336 additions and 157 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
APP_NAME := gtexporter
SRC_PATH := cmd/gtexporter/
BUILD_DIR := build
YGOT_GEN_VER := 'v0.29.18'
YGOT_GEN_VER := 'v0.29.19'
BUILD_DATE := $(shell date -u +%FT%TZ)
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ docker run -p 9456:9456/tcp --mount type=bind,source=.,target=/etc/gte/ automixe
The mandatory argument is a config file named ```config.yaml``` into the current folder.

### The Configuration File
This [configuration file template](config-keys.yaml) describes the supported configuration keys.
This [configuration file template](config-keys.yaml) and this [addendum](plugin-options.yaml)
describes the supported configuration keys.
The file is subdivided into three sections:
1) The ```global``` section contains application-wide settings like the Prometheus client listen address and port.
2) The ```device_template``` section contains the settings shared among all devices. This section can
Expand Down Expand Up @@ -105,7 +106,7 @@ Subscribe to these schema paths:
3) ```/interfaces/interface/subinterfaces/subinterface/state/```

Produces two Prometheus metrics:
1) ```<configured_metric_prefix>_oc_if_counters{}```.
1) ```<configured_metric_prefix>_oc_if_total{}```.
2) ```<configured_metric_prefix>_oc_if_gauges{}```.

### ```oc_lldp```
Expand All @@ -121,13 +122,13 @@ LLDP must be enabled on the target devices.
In addition to the ```schema plugins```, **GtExporter** emits several self-monitoring metrics to keep track of
the app's health and operational state.
These metrics are:
1) ```<configured_metric_prefix>_gnmi_client_counters{}```: These counters describe the state of the underlying gNMI
1) ```<configured_metric_prefix>_gnmi_client_total{}```: These counters describe the state of the underlying gNMI
client instances.
2) ```<configured_metric_prefix>_gnmi_client_gauges{}```: These gauges describe the state of the underlying gNMI
client instances.
3) ```<configured_metric_prefix>_plugin_formatter_gauges{}```: These gauges describe the operational state of the
running plugin's formatters.
4) ```<configured_metric_prefix>_plugin_parser_counters{}```: These counters describe the operational state of the
4) ```<configured_metric_prefix>_plugin_parser_total{}```: These counters describe the operational state of the
running plugin's parsers.
5) The default Go Runtime Metrics exported by the Prometheus client library.

Expand Down
3 changes: 2 additions & 1 deletion config-keys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ global:
# It must satisfy the regex ^[a-zA-Z0-9_]*$
listen_address: 0.0.0.0 # Prometheus exporter listen address. Defaults to 0.0.0.0
listen_port: 9456 # Prometheus exporter listen port. Defaults to 9456
scrape_interval: 1m # The scrape interval configured on Prometheus server. No less than 10 seconds.
scrape_interval: 1m # The scrape interval configured on Prometheus server. No less than 1 second.


# These keys are shared among all device configurations and are overridden by the device section keys.
Expand Down Expand Up @@ -44,6 +44,7 @@ devices:
# "[a-zA-Z0-9_:\\-/]". Any character in the description that doesn't match
# the pattern will be removed
options: <plugin options> # Plugin specific options. See plugin-options.yaml
vendor: generic # Can be "generic" or "huawei". If not present, "generic" is used.

# gNMI related keys:
force_encoding: proto # Force the gNMI client to use a specific encoding. Acceptable values are:
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go 1.22.0
require (
github.com/golang/glog v1.2.1
github.com/openconfig/gnmi v0.11.0
github.com/openconfig/ygot v0.29.18
github.com/openconfig/ygot v0.29.19
github.com/prometheus/client_golang v1.19.0
google.golang.org/grpc v1.63.0
google.golang.org/grpc v1.63.2
gopkg.in/yaml.v2 v2.4.0
)

Expand All @@ -21,8 +21,8 @@ require (
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/protobuf v1.33.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ github.com/openconfig/goyang v1.4.5 h1:+s3p3MeiPQ/QNsC5DL3MXhCp5cv4dag3vlGKCtszs
github.com/openconfig/goyang v1.4.5/go.mod h1:sdNZi/wdTZyLNBNfgLzmmbi7kISm7FskMDKKzMY+x1M=
github.com/openconfig/grpctunnel v0.0.0-20220819142823-6f5422b8ca70/go.mod h1:OmTWe7RyZj2CIzIgy4ovEBzCLBJzRvWSZmn7u02U9gU=
github.com/openconfig/ygot v0.6.0/go.mod h1:o30svNf7O0xK+R35tlx95odkDmZWS9JyWWQSmIhqwAs=
github.com/openconfig/ygot v0.29.18 h1:vgG2r7RVwaVDXgHtpsCNW+qdSGSdxqRxUfRN2rPCy7M=
github.com/openconfig/ygot v0.29.18/go.mod h1:sp6roPPmVDcTCF2E3qTjILA+jzJMkZ9d6spC9KLMqpc=
github.com/openconfig/ygot v0.29.19 h1:3bbAWbCBVjyjHgeROvT38LQ7pAxcjtm7C2vNVj/rvEE=
github.com/openconfig/ygot v0.29.19/go.mod h1:8/FXt4tc5wSfYDEJbGGumxmxwJ55Xuv12oO/jCyEins=
github.com/pborman/getopt v1.1.0/go.mod h1:FxXoW1Re00sQG/+KIkuSqRL/LwQgSkv7uyac+STFsbk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -112,8 +112,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -130,8 +130,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down Expand Up @@ -169,8 +169,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8=
google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand Down
3 changes: 2 additions & 1 deletion pkg/core/confmgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

const (
minScrapeInterval = 10 * time.Second
minScrapeInterval = time.Second
minSessionTTL = 10 * time.Minute
)

Expand Down Expand Up @@ -159,6 +159,7 @@ func (c *Core) buildGnmiClientCfg(yCfg *yamlConfig, index int) {
TLSCa: src.Keys["tls_ca"],
ForceEncoding: src.Keys["force_encoding"],
DevName: src.Keys["name"],
Vendor: src.Keys["vendor"],
}
// Bool values
flag, _ := strconv.ParseBool(src.Keys["tls"])
Expand Down
22 changes: 21 additions & 1 deletion pkg/datamodels/ysocif/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ of structs which represent a YANG schema. The generated schema can be
compressed by a series of transformations (compression was true
in this case).
This package was generated by /Users/luca/go/pkg/mod/github.com/openconfig/ygot@v0.29.18/genutil/names.go
This package was generated by /Users/luca/go/pkg/mod/github.com/openconfig/ygot@v0.29.19/genutil/names.go
using the following YANG input files:
- openconfig-interfaces.yang
- openconfig-if-aggregate.yang
Expand Down Expand Up @@ -86,6 +86,16 @@ func (t *Interface) NewSubinterface(Index uint32) (*Interface_Subinterface, erro
return t.Subinterface[key], nil
}

// GetOrCreateSubinterfaceMap returns the list (map) from Interface.
//
// It initializes the field if not already initialized.
func (t *Interface) GetOrCreateSubinterfaceMap() map[uint32]*Interface_Subinterface {
if t.Subinterface == nil {
t.Subinterface = make(map[uint32]*Interface_Subinterface)
}
return t.Subinterface
}

// GetOrCreateSubinterface retrieves the value with the specified keys from
// the receiver Interface. If the entry does not exist, then it is created.
// It returns the existing or new list member.
Expand Down Expand Up @@ -2201,6 +2211,16 @@ func (t *Root) NewInterface(Name string) (*Interface, error) {
return t.Interface[key], nil
}

// GetOrCreateInterfaceMap returns the list (map) from Root.
//
// It initializes the field if not already initialized.
func (t *Root) GetOrCreateInterfaceMap() map[string]*Interface {
if t.Interface == nil {
t.Interface = make(map[string]*Interface)
}
return t.Interface
}

// GetOrCreateInterface retrieves the value with the specified keys from
// the receiver Root. If the entry does not exist, then it is created.
// It returns the existing or new list member.
Expand Down
42 changes: 41 additions & 1 deletion pkg/datamodels/ysoclldp/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ of structs which represent a YANG schema. The generated schema can be
compressed by a series of transformations (compression was true
in this case).
This package was generated by /Users/luca/go/pkg/mod/github.com/openconfig/ygot@v0.29.18/genutil/names.go
This package was generated by /Users/luca/go/pkg/mod/github.com/openconfig/ygot@v0.29.19/genutil/names.go
using the following YANG input files:
- openconfig-lldp.yang
Expand Down Expand Up @@ -75,6 +75,16 @@ func (t *Lldp) NewInterface(Name string) (*Lldp_Interface, error) {
return t.Interface[key], nil
}

// GetOrCreateInterfaceMap returns the list (map) from Lldp.
//
// It initializes the field if not already initialized.
func (t *Lldp) GetOrCreateInterfaceMap() map[string]*Lldp_Interface {
if t.Interface == nil {
t.Interface = make(map[string]*Lldp_Interface)
}
return t.Interface
}

// GetOrCreateInterface retrieves the value with the specified keys from
// the receiver Lldp. If the entry does not exist, then it is created.
// It returns the existing or new list member.
Expand Down Expand Up @@ -495,6 +505,16 @@ func (t *Lldp_Interface) NewNeighbor(Id string) (*Lldp_Interface_Neighbor, error
return t.Neighbor[key], nil
}

// GetOrCreateNeighborMap returns the list (map) from Lldp_Interface.
//
// It initializes the field if not already initialized.
func (t *Lldp_Interface) GetOrCreateNeighborMap() map[string]*Lldp_Interface_Neighbor {
if t.Neighbor == nil {
t.Neighbor = make(map[string]*Lldp_Interface_Neighbor)
}
return t.Neighbor
}

// GetOrCreateNeighbor retrieves the value with the specified keys from
// the receiver Lldp_Interface. If the entry does not exist, then it is created.
// It returns the existing or new list member.
Expand Down Expand Up @@ -861,6 +881,16 @@ func (t *Lldp_Interface_Neighbor) NewCapability(Name E_OpenconfigLldpTypes_LLDP_
return t.Capability[key], nil
}

// GetOrCreateCapabilityMap returns the list (map) from Lldp_Interface_Neighbor.
//
// It initializes the field if not already initialized.
func (t *Lldp_Interface_Neighbor) GetOrCreateCapabilityMap() map[E_OpenconfigLldpTypes_LLDP_SYSTEM_CAPABILITY]*Lldp_Interface_Neighbor_Capability {
if t.Capability == nil {
t.Capability = make(map[E_OpenconfigLldpTypes_LLDP_SYSTEM_CAPABILITY]*Lldp_Interface_Neighbor_Capability)
}
return t.Capability
}

// GetOrCreateCapability retrieves the value with the specified keys from
// the receiver Lldp_Interface_Neighbor. If the entry does not exist, then it is created.
// It returns the existing or new list member.
Expand Down Expand Up @@ -940,6 +970,16 @@ func (t *Lldp_Interface_Neighbor) NewTlv(Type int32, Oui string, OuiSubtype stri
return t.Tlv[key], nil
}

// GetOrCreateTlvMap returns the list (map) from Lldp_Interface_Neighbor.
//
// It initializes the field if not already initialized.
func (t *Lldp_Interface_Neighbor) GetOrCreateTlvMap() map[Lldp_Interface_Neighbor_Tlv_Key]*Lldp_Interface_Neighbor_Tlv {
if t.Tlv == nil {
t.Tlv = make(map[Lldp_Interface_Neighbor_Tlv_Key]*Lldp_Interface_Neighbor_Tlv)
}
return t.Tlv
}

// GetOrCreateTlv retrieves the value with the specified keys from
// the receiver Lldp_Interface_Neighbor. If the entry does not exist, then it is created.
// It returns the existing or new list member.
Expand Down
6 changes: 3 additions & 3 deletions pkg/exporter/gmetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ func getLabelValues(m GMetric) []string {
return labelValues
}

// buildFQName builds a fully-qualified metric name using the provided prefix and MetricCommons.
// buildFQName builds a fully qualified metric name using the provided prefix and MetricCommons.
// It appends "_counters" or "_gauges" to the metric name based on its Type.
// Parameters:
// - pfx: the prefix for the metric name
// - mc: the MetricCommons object containing the metric name and type
// Returns the fully-qualified metric name as a string.
// Returns the fully qualified metric name as a string.
func buildFQName(pfx string, mc MetricCommons) string {
fqName := prometheus.BuildFQName(pfx, "", mc.Name)
switch mc.getCommons().Type {
case prometheus.CounterValue:
fqName += "_counters"
fqName += "_total"
case prometheus.GaugeValue:
fqName += "_gauges"
case prometheus.UntypedValue:
Expand Down
Loading

0 comments on commit d54e81f

Please sign in to comment.