Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rg2-changelog-metric
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Jul 10, 2024
2 parents 0893025 + a6a60b8 commit 58b17e0
Show file tree
Hide file tree
Showing 34 changed files with 273 additions and 1,116 deletions.
20 changes: 20 additions & 0 deletions cmd/collectors/commonutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,23 @@ func ReadPluginKey(param *node.Node, key string) bool {
}
return false
}

func SplitVscanName(ontapName string) (string, string, string, bool) {
// colon separated list of fields
// svm : scanner : node
// vs_test4 : 2.2.2.2 : umeng-aff300-05
// moon-ad : 2a03:1e80:a15:60c::1:2a5 : moon-02

firstColon := strings.Index(ontapName, ":")
if firstColon == -1 {
return "", "", "", false
}
lastColon := strings.LastIndex(ontapName, ":")
if lastColon == -1 {
return "", "", "", false
}
if firstColon == lastColon {
return "", "", "", false
}
return ontapName[:firstColon], ontapName[firstColon+1 : lastColon], ontapName[lastColon+1:], true
}
62 changes: 62 additions & 0 deletions cmd/collectors/commonutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,65 @@ func populateInstance(data *matrix.Matrix, instanceName, healthy, schedule, last
}
return instance
}

func Test_SplitVscanName(t *testing.T) {
tests := []struct {
name string
ontapName string
svm string
scanner string
node string
isValid bool
}{
{
name: "valid",
ontapName: "svm:scanner:node",
svm: "svm",
scanner: "scanner",
node: "node",
isValid: true,
},
{
name: "ipv6",
ontapName: "moon-ad:2a03:1e80:a15:60c::1:2a5:moon-02",
svm: "moon-ad",
scanner: "2a03:1e80:a15:60c::1:2a5",
node: "moon-02",
isValid: true,
},
{
name: "invalid zero colon",
ontapName: "svm",
svm: "",
scanner: "",
node: "",
isValid: false,
},
{
name: "invalid one colon",
ontapName: "svm:scanner",
svm: "",
scanner: "",
node: "",
isValid: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotSVM, gotScanner, gotNode, ok := SplitVscanName(tt.ontapName)
if gotSVM != tt.svm {
t.Errorf("splitOntapName() got = %v, want %v", gotSVM, tt.svm)
}
if gotScanner != tt.scanner {
t.Errorf("splitOntapName() got = %v, want %v", gotScanner, tt.scanner)
}
if gotNode != tt.node {
t.Errorf("splitOntapName() got = %v, want %v", gotNode, tt.node)
}
if ok != tt.isValid {
t.Errorf("splitOntapName() got = %v, want %v", ok, tt.isValid)
}
})
}
}
12 changes: 6 additions & 6 deletions cmd/collectors/rest/plugins/securityaccount/securityaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ func (s *SecurityAccount) Init() error {
}

clientTimeout := s.ParentParams.GetChildContentS("client_timeout")
timeout, _ := time.ParseDuration(rest.DefaultTimeout)
duration, err := time.ParseDuration(clientTimeout)
if err == nil {
timeout = duration
} else {
s.Logger.Info().Str("timeout", timeout.String()).Msg("Using default timeout")
if clientTimeout == "" {
clientTimeout = rest.DefaultTimeout
}
timeout, err := time.ParseDuration(clientTimeout)
if err != nil {
s.Logger.Info().Str("timeout", rest.DefaultTimeout).Msg("Using default timeout")
}
if s.client, err = rest.New(conf.ZapiPoller(s.ParentParams), timeout, s.Auth); err != nil {
return fmt.Errorf("failed to connect err=%w", err)
Expand Down
15 changes: 7 additions & 8 deletions cmd/collectors/restperf/plugins/vscan/vscan.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vscan

import (
"github.com/netapp/harvest/v2/cmd/collectors"
"github.com/netapp/harvest/v2/cmd/poller/plugin"
"github.com/netapp/harvest/v2/pkg/matrix"
"github.com/netapp/harvest/v2/pkg/util"
Expand Down Expand Up @@ -41,16 +42,14 @@ func (v *Vscan) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.
func (v *Vscan) addSvmAndScannerLabels(data *matrix.Matrix) {
for _, instance := range data.GetInstances() {
ontapName := instance.GetLabel("id")
// colon separated list of fields
// A900-node1 : vs0 : 2.2.2.2
// node : svm : scanner
if split := strings.Split(ontapName, ":"); len(split) >= 3 {
instance.SetLabel("node", split[0])
instance.SetLabel("svm", split[1])
instance.SetLabel("scanner", split[2])
} else {
svm, scanner, node, ok := collectors.SplitVscanName(ontapName)
if !ok {
v.Logger.Warn().Str("ontapName", ontapName).Msg("Failed to parse svm and scanner labels")
continue
}
instance.SetLabel("svm", svm)
instance.SetLabel("scanner", scanner)
instance.SetLabel("node", node)
}
}

Expand Down
23 changes: 2 additions & 21 deletions cmd/collectors/zapiperf/plugins/vscan/vscan.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vscan

import (
"github.com/netapp/harvest/v2/cmd/collectors"
"github.com/netapp/harvest/v2/cmd/poller/plugin"
"github.com/netapp/harvest/v2/pkg/matrix"
"github.com/netapp/harvest/v2/pkg/util"
Expand Down Expand Up @@ -44,7 +45,7 @@ func (v *Vscan) addSvmAndScannerLabels(data *matrix.Matrix) {
continue
}
ontapName := instance.GetLabel("instance_uuid")
svm, scanner, node, ok := splitOntapName(ontapName)
svm, scanner, node, ok := collectors.SplitVscanName(ontapName)
if !ok {
v.Logger.Warn().Str("ontapName", ontapName).Msg("Failed to parse svm and scanner labels")
continue
Expand All @@ -55,26 +56,6 @@ func (v *Vscan) addSvmAndScannerLabels(data *matrix.Matrix) {
}
}

func splitOntapName(ontapName string) (string, string, string, bool) {
// colon separated list of fields
// svm : scanner : node
// vs_test4 : 2.2.2.2 : umeng-aff300-05
// moon-ad : 2a03:1e80:a15:60c::1:2a5 : moon-02

firstColon := strings.Index(ontapName, ":")
if firstColon == -1 {
return "", "", "", false
}
lastColon := strings.LastIndex(ontapName, ":")
if lastColon == -1 {
return "", "", "", false
}
if firstColon == lastColon {
return "", "", "", false
}
return ontapName[:firstColon], ontapName[firstColon+1 : lastColon], ontapName[lastColon+1:], true
}

func (v *Vscan) aggregatePerScanner(data *matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) {
// When isPerScanner=true, Harvest 1.6 uses this form:
// netapp.perf.dev.nltl-fas2520.vscan.scanner.10_64_30_62.scanner_stats_pct_mem_used 18 1501765640
Expand Down
65 changes: 0 additions & 65 deletions cmd/collectors/zapiperf/plugins/vscan/vscan_test.go

This file was deleted.

10 changes: 0 additions & 10 deletions cmd/harvest/harvest.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,6 @@ func doManageCmd(cmd *cobra.Command, args []string) {
os.Exit(0)
}

table := tw.NewWriter(os.Stdout)
table.SetBorder(false)
table.SetAutoFormatHeaders(false)
if opts.longStatus {
table.SetHeader([]string{"Datacenter", "Poller", "PID", "PromPort", "Profiling", "Status"})
} else {
table.SetHeader([]string{"Datacenter", "Poller", "PID", "PromPort", "Status"})
}
table.SetColumnAlignment([]int{tw.ALIGN_LEFT, tw.ALIGN_LEFT, tw.ALIGN_RIGHT, tw.ALIGN_RIGHT, tw.ALIGN_RIGHT})

statusesByName := getPollersStatus()
switch opts.command {
case "restart":
Expand Down
5 changes: 4 additions & 1 deletion cmd/poller/collector/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (c *AbstractCollector) ImportSubTemplate(model, filename, jitter string, ve
customTemplateErr error
finalTemplate *node.Node
customTemplate *node.Node
importErrs []error
)

if filename == "" {
Expand Down Expand Up @@ -100,6 +101,7 @@ nextFile:
finalTemplate.PreprocessTemplate()
continue nextFile
}
importErrs = append(importErrs, fmt.Errorf("failed to import template: %s file: %w", templatePath, err))
} else {
// any errors w.r.t customTemplate are warnings and should not be returned to caller
customTemplate, customTemplateErr = tree.ImportYaml(templatePath)
Expand All @@ -119,7 +121,8 @@ nextFile:
if c.Object == "Status_7mode" && model == "cdot" {
return nil, "", errs.New(errs.ErrWrongTemplate, "unable to load status_7.yaml on cdot")
}
return nil, "", fmt.Errorf("no best-fit template for %s on %s", filename, c.Options.ConfPath)
return nil, "", fmt.Errorf("no best-fit template for %s on confPath %s %w",
filename, c.Options.ConfPath, errors.Join(importErrs...))
}
}

Expand Down
7 changes: 4 additions & 3 deletions docs/prepare-fsx-clusters.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ some panels may be missing information.

The dashboards that work with FSx are tagged with `fsx` and listed below:

* ONTAP: cDOT
* ONTAP: Cluster
* ONTAP: Compliance
* ONTAP: Data Protection Snapshots
* ONTAP: Datacenter
* ONTAP: FlexGroup
* ONTAP: LUN
* ONTAP: NFS Troubleshooting
* ONTAP: SVM
* ONTAP: Quota
* ONTAP: Security
* ONTAP: SVM
* ONTAP: Volume
* ONTAP: Volume Deep Dive
* ONTAP: Volume by SVM
* ONTAP: cDOT
* ONTAP: Volume Deep Dive
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ go 1.22
require (
github.com/go-openapi/spec v0.21.0
github.com/google/go-cmp v0.6.0
github.com/mattn/go-runewidth v0.0.15
github.com/rivo/uniseg v0.4.7
github.com/rs/zerolog v1.33.0
github.com/shirou/gopsutil/v4 v4.24.6
github.com/spf13/cobra v1.8.1
github.com/tidwall/gjson v1.17.1
github.com/zekroTJA/timedmap/v2 v2.0.0
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
golang.org/x/sys v0.21.0
golang.org/x/term v0.21.0
golang.org/x/exp v0.0.0-20240707233637-46b078467d37
golang.org/x/sys v0.22.0
golang.org/x/term v0.22.0
golang.org/x/text v0.16.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
Expand All @@ -31,7 +31,6 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tidwall/match v1.1.1 // indirect
Expand Down
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
Expand Down Expand Up @@ -81,6 +78,8 @@ github.com/zekroTJA/timedmap/v2 v2.0.0 h1:Bo9oq8AExd0GuDFbcPXm3xoidUAtrnNsZN1d1H
github.com/zekroTJA/timedmap/v2 v2.0.0/go.mod h1:xHDLg687zASqLBJqoysF+WORHxL/kYNphVD36CRJxhM=
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w=
golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -89,8 +88,12 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
3 changes: 2 additions & 1 deletion grafana/dashboards/cmode/quotaReport.json
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,8 @@
"tags": [
"harvest",
"ontap",
"cdot"
"cdot",
"fsx"
],
"templating": {
"list": [
Expand Down
Loading

0 comments on commit 58b17e0

Please sign in to comment.