Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/release-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bin/harvest generate metrics --poller POLLERNAME

### The day of the release

- [ ] Create a new build from [Jenkins](http://harvest-jenkins.rtp.openenglab.netapp.com:8080/job/harvest2_0/job/BuildHarvestArtifacts/) ([details](https://github.com/NetApp/harvest-private/wiki/Release-Checklist#jenkins))
- [ ] Create a new build from [Jenkins](http://harvest-ci.rtp.openenglab.netapp.com:8080/job/harvest2_0/job/BuildHarvestArtifacts/) ([details](https://github.com/NetApp/harvest-private/wiki/Release-Checklist#jenkins))
- [ ] Click `Build with Parameters` and fill in the appropriate fields. Here's an example, where `RELEASE=23.02.0`

| Field | Value |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
persist-credentials: false

- name: Install the latest version of uv
uses: astral-sh/setup-uv@0d20755a2389f8ddbd3ad4f8a536309a4db22de9
uses: astral-sh/setup-uv@b49dc9e8821aa6e5df06b85779f66761402a1787

- name: Run zizmor 🌈
run: uvx zizmor --format sarif . > results.sarif
Expand Down
2 changes: 1 addition & 1 deletion .harvest.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
GO_VERSION=1.25.3
GO_VERSION=1.25.4
200 changes: 198 additions & 2 deletions CHANGELOG.md

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions cmd/collectors/cisco/plugins/lldp/lldp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/netapp/harvest/v2/pkg/collector"
"github.com/netapp/harvest/v2/pkg/conf"
"github.com/netapp/harvest/v2/pkg/matrix"
"github.com/netapp/harvest/v2/pkg/slogx"
"github.com/netapp/harvest/v2/third_party/tidwall/gjson"
"log/slog"
"slices"
Expand All @@ -23,6 +24,7 @@ type LLDP struct {
matrix *matrix.Matrix
client *rest.Client
templateObject string // object name from the template
RemoteSerial string
}

func New(p *plugin.AbstractPlugin) plugin.Plugin {
Expand Down Expand Up @@ -50,6 +52,7 @@ func (l *LLDP) Init(remote conf.Remote) error {
}

l.client = client
l.RemoteSerial = client.Remote().Serial
l.templateObject = l.ParentParams.GetChildContentS("object")

l.matrix = matrix.New(l.Parent+".LLDP", l.templateObject, l.templateObject)
Expand Down Expand Up @@ -118,10 +121,10 @@ func (l *LLDP) parseLLDP(output gjson.Result, mat *matrix.Matrix) {
})

for _, model := range models {
instanceKey := model.ChassisID
instanceKey := model.ChassisID + "-" + model.LocalPort
instance, err := mat.NewInstance(instanceKey)
if err != nil {
l.SLogger.Warn("Failed to create lldp instance", slog.String("key", instanceKey))
l.SLogger.Warn("Failed to create lldp instance", slog.String("key", instanceKey), slogx.Err(err))
continue
}

Expand All @@ -131,7 +134,7 @@ func (l *LLDP) parseLLDP(output gjson.Result, mat *matrix.Matrix) {
instance.SetLabel("local_port", model.LocalPort)
instance.SetLabel("remote_port", model.RemotePort)
instance.SetLabel("capabilities", strings.Join(model.Capabilities, ","))
instance.SetLabel("local_platform", l.client.Remote().Serial)
instance.SetLabel("local_platform", l.RemoteSerial)

mat.GetMetric(labels).SetValueFloat64(instance, 1.0)
}
Expand Down
20 changes: 20 additions & 0 deletions cmd/collectors/cisco/plugins/lldp/lldp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package lldp
import (
"github.com/google/go-cmp/cmp"
"github.com/netapp/harvest/v2/assert"
"github.com/netapp/harvest/v2/cmd/poller/plugin"
"github.com/netapp/harvest/v2/pkg/matrix"
"github.com/netapp/harvest/v2/third_party/tidwall/gjson"
"log/slog"
"os"
"testing"
)
Expand Down Expand Up @@ -43,3 +46,20 @@ func TestNewLLDPModel(t *testing.T) {
})
}
}

func TestParse(t *testing.T) {
// Read the file from the testdata directory
filename := "testdata/lldp2.json"
data, err := os.ReadFile(filename)
assert.Nil(t, err)

result := gjson.ParseBytes(data)
output := result.Get("ins_api.outputs")
l := New(&plugin.AbstractPlugin{SLogger: slog.Default()}).(*LLDP)

m := matrix.New("lldp", "lldp", "lldp")
_, _ = m.NewMetricFloat64("labels")
l.parseLLDP(output, m)

assert.Equal(t, len(m.GetInstances()), 13)
}
Loading
Loading