Skip to content

Commit

Permalink
cleanup, bump version, go 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
czerwonk committed May 16, 2022
1 parent bfc3a70 commit 8c2e568
Show file tree
Hide file tree
Showing 22 changed files with 490 additions and 174 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.17.x]
go-version: [1.18.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
14 changes: 6 additions & 8 deletions bfd/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ const prefix = "junos_bfd_"
var (
bfdState *prometheus.Desc
bfdStateMap = map[string]int{
"Down": 0,
"Up": 1,
"Down": 0,
"Up": 1,
}

)

func init() {
Expand All @@ -40,18 +39,17 @@ func (*bfdCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- bfdState
}


// Collect collects metrics from JunOS
func (c *bfdCollector) Collect(client *rpc.Client, ch chan<- prometheus.Metric, labelValues []string) error {
var x = bfdRpc{}
err := client.RunCommandAndParse("show bfd session extensive", &x)
var x = bfdRpc{}
err := client.RunCommandAndParse("show bfd session extensive", &x)
if err != nil {
return err
}

for _, bfds := range x.Information.BfdSessions {
l := append(labelValues, bfds.Neighbor, bfds.Interface, bfds.Client.Name)
ch <- prometheus.MustNewConstMetric(bfdState, prometheus.GaugeValue, float64(bfdStateMap[bfds.State]), l...)
l := append(labelValues, bfds.Neighbor, bfds.Interface, bfds.Client.Name)
ch <- prometheus.MustNewConstMetric(bfdState, prometheus.GaugeValue, float64(bfdStateMap[bfds.State]), l...)
}

return nil
Expand Down
21 changes: 10 additions & 11 deletions bfd/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ package bfd

type bfdRpc struct {
Information struct {
BfdSessions []bfdSession `xml:"bfd-session"`
Sessions int64 `xml:"sessions"`
Clients int64 `xml:"clients"`
CumTransRate float64 `xml:"cumulative-transmission-rate"`
CumRecRate float64 `xml:"cumulative-reception-rate"`
BfdSessions []bfdSession `xml:"bfd-session"`
Sessions int64 `xml:"sessions"`
Clients int64 `xml:"clients"`
CumTransRate float64 `xml:"cumulative-transmission-rate"`
CumRecRate float64 `xml:"cumulative-reception-rate"`
} `xml:"bfd-session-information"`
}

type bfdSession struct {
Neighbor string `xml:"session-neighbor"`
State string `xml:"session-state"`
Interface string `xml:"session-interface"`
Client struct {
Name string `xml:"client-name"`
Neighbor string `xml:"session-neighbor"`
State string `xml:"session-state"`
Interface string `xml:"session-interface"`
Client struct {
Name string `xml:"client-name"`
} `xml:"bfd-client"`
}

1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func setDefaultValues(c *Config) {
f.MPLS_LSP = false
f.VPWS = false
f.VRRP = false
f.BFD = false
}

// FeaturesForDevice gets the feature set configured for a device
Expand Down
3 changes: 2 additions & 1 deletion fpc/rpc_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package fpc

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestParseEXOutput(t *testing.T) {
Expand Down
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
module github.com/czerwonk/junos_exporter

go 1.17
go 1.18

require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/client_golang v1.12.2
github.com/prometheus/client_model v0.2.0
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
github.com/stretchr/testify v1.7.1
golang.org/x/crypto v0.0.0-20220513210258-46612604a0f9
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
google.golang.org/protobuf v1.26.0-rc.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20220512140231-539c8e751b99 // indirect
)
Loading

0 comments on commit 8c2e568

Please sign in to comment.