Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: collection of other counters for fcvi perf object #2096

Merged
merged 7 commits into from
May 25, 2023
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
71 changes: 71 additions & 0 deletions cmd/collectors/restperf/plugins/fcvi/fcvi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package fcvi

import (
"github.com/netapp/harvest/v2/cmd/poller/plugin"
"github.com/netapp/harvest/v2/cmd/tools/rest"
"github.com/netapp/harvest/v2/pkg/conf"
"github.com/netapp/harvest/v2/pkg/matrix"
"strings"
"time"
)

type FCVI struct {
*plugin.AbstractPlugin
client *rest.Client
}

func New(p *plugin.AbstractPlugin) plugin.Plugin {
return &FCVI{AbstractPlugin: p}
}

func (f *FCVI) Init() error {
var err error
if err = f.InitAbc(); err != nil {
return err
}

timeout, _ := time.ParseDuration(rest.DefaultTimeout)
if f.client, err = rest.New(conf.ZapiPoller(f.ParentParams), timeout, f.Auth); err != nil {
f.Logger.Error().Stack().Err(err).Msg("connecting")
return err
}

if err = f.client.Init(5); err != nil {
return err
}
return nil
}

func (f *FCVI) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error) {
data := dataMap[f.Object]
query := "api/private/cli/metrocluster/interconnect/adapter"
fields := []string{"node", "adapter", "port_name"}
href := rest.BuildHref("", strings.Join(fields, ","), nil, "", "", "", "", query)

records, err := rest.Fetch(f.client, href)
if err != nil {
f.Logger.Error().Err(err).Str("href", href).Msg("Failed to fetch data")
return nil, err
}

if len(records) == 0 {
return nil, nil
}

for _, adapterData := range records {
if !adapterData.IsObject() {
f.Logger.Warn().Str("type", adapterData.Type.String()).Msg("adapter is not object, skipping")
continue
}
node := adapterData.Get("node").String()
adapter := adapterData.Get("adapter").String()
port := adapterData.Get("port_name").String()

// Fetch instance and add port label
if instance := data.GetInstance(node + ":" + adapter); instance != nil {
instance.SetLabel("port", port)
}
}

return nil, nil
}
3 changes: 3 additions & 0 deletions cmd/collectors/restperf/restperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/disk"
"github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/fabricpool"
"github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/fcp"
"github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/fcvi"
"github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/headroom"
"github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/nic"
"github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/volume"
Expand Down Expand Up @@ -1231,6 +1232,8 @@ func (r *RestPerf) LoadPlugin(kind string, p *plugin.AbstractPlugin) plugin.Plug
return vscan.New(p)
case "FabricPool":
return fabricpool.New(p)
case "FCVI":
return fcvi.New(p)
default:
r.Logger.Info().Str("kind", kind).Msg("no Restperf plugin found")
}
Expand Down
81 changes: 81 additions & 0 deletions cmd/collectors/zapiperf/plugins/fcvi/fcvi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package fcvi

import (
"github.com/netapp/harvest/v2/cmd/poller/plugin"
"github.com/netapp/harvest/v2/pkg/api/ontapi/zapi"
"github.com/netapp/harvest/v2/pkg/conf"
"github.com/netapp/harvest/v2/pkg/errs"
"github.com/netapp/harvest/v2/pkg/matrix"
"github.com/netapp/harvest/v2/pkg/tree/node"
)

const batchSize = "500"

type FCVI struct {
*plugin.AbstractPlugin
client *zapi.Client
}

func New(p *plugin.AbstractPlugin) plugin.Plugin {
return &FCVI{AbstractPlugin: p}
}

func (f *FCVI) Init() error {
var err error
if err = f.InitAbc(); err != nil {
return err
}

if f.client, err = zapi.New(conf.ZapiPoller(f.ParentParams), f.Auth); err != nil {
f.Logger.Error().Stack().Err(err).Msg("connecting")
return err
}
if err = f.client.Init(5); err != nil {
return err
}
return nil
}

func (f *FCVI) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error) {
var (
result []*node.Node
err error
)

adapterPortMap := make(map[string]string)
data := dataMap[f.Object]
query := "metrocluster-interconnect-adapter-get-iter"
request := node.NewXMLS(query)
request.NewChildS("max-records", batchSize)
desired := node.NewXMLS("desired-attributes")
metroclusterInterconnectAdapterAttributes := node.NewXMLS("metrocluster-interconnect-adapter")
metroclusterInterconnectAdapterAttributes.NewChildS("adapter-name", "")
metroclusterInterconnectAdapterAttributes.NewChildS("node-name", "")
metroclusterInterconnectAdapterAttributes.NewChildS("port-name", "")
desired.AddChild(metroclusterInterconnectAdapterAttributes)
request.AddChild(desired)

if result, err = f.client.InvokeZapiCall(request); err != nil {
return nil, err
}

if len(result) == 0 || result == nil {
return nil, errs.New(errs.ErrNoInstance, "no records found")
}
f.Logger.Info().Msgf("%d", len(result))

for _, adapterData := range result {
adapter := adapterData.GetChildContentS("adapter-name")
node := adapterData.GetChildContentS("node-name")
port := adapterData.GetChildContentS("port-name")
adapterPortMap[node+adapter] = port
}

// we would not use getInstance() as key would be `sti8300mcc-215:kernel:fcvi_device_1`
for _, instance := range data.GetInstances() {
if port, ok := adapterPortMap[instance.GetLabel("node")+instance.GetLabel("fcvi")]; ok {
instance.SetLabel("port", port)
}
}
return nil, nil
}
3 changes: 3 additions & 0 deletions cmd/collectors/zapiperf/zapiperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/netapp/harvest/v2/cmd/collectors/zapiperf/plugins/disk"
"github.com/netapp/harvest/v2/cmd/collectors/zapiperf/plugins/externalserviceoperation"
"github.com/netapp/harvest/v2/cmd/collectors/zapiperf/plugins/fcp"
"github.com/netapp/harvest/v2/cmd/collectors/zapiperf/plugins/fcvi"
"github.com/netapp/harvest/v2/cmd/collectors/zapiperf/plugins/headroom"
"github.com/netapp/harvest/v2/cmd/collectors/zapiperf/plugins/nic"
"github.com/netapp/harvest/v2/cmd/collectors/zapiperf/plugins/volume"
Expand Down Expand Up @@ -128,6 +129,8 @@ func (z *ZapiPerf) LoadPlugin(kind string, abc *plugin.AbstractPlugin) plugin.Pl
return disk.New(abc)
case "ExternalServiceOperation":
return externalserviceoperation.New(abc)
case "FCVI":
return fcvi.New(abc)
default:
z.Logger.Info().Msgf("no zapiPerf plugin found for %s", kind)
}
Expand Down
28 changes: 21 additions & 7 deletions conf/restperf/9.12.0/fcvi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ query: api/cluster/counter/tables/fcvi
object: fcvi

counters:
- ^^id
- ^name => fcvi
- ^node.name => node
- rdma.write_average_latency => rdma_write_avg_latency
- rdma.write_ops => rdma_write_ops
- rdma.write_throughput => rdma_write_throughput
- ^^id => fcvi
- ^node.name => node
- firmware.invalid_crc_count => firmware_invalid_crc_count
- firmware.invalid_transmit_word_count => firmware_invalid_transmit_word_count
- firmware.link_failure_count => firmware_link_failure_count
- firmware.loss_of_signal_count => firmware_loss_of_signal_count
- firmware.loss_of_sync_count => firmware_loss_of_sync_count
- firmware.systat.discard_frames => firmware_systat_discard_frames
- hard_reset_count => hard_reset_count
- rdma.write_average_latency => rdma_write_avg_latency
- rdma.write_ops => rdma_write_ops
- rdma.write_throughput => rdma_write_throughput
- soft_reset_count => soft_reset_count

plugins:
- LabelAgent:
split:
- fcvi `:` ,fcvi
- FCVI

export_options:
instance_keys:
- fcvi
- node
- node
- port
12 changes: 12 additions & 0 deletions conf/zapiperf/cdot/9.8.0/fcvi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ object: fcvi
instance_key: uuid

counters:
- fw_SyStatDiscardFrames => firmwares_systat_discard_frames
- fw_invalid_crc => firmware_invalid_crc_count
- fw_invalid_xmit_words => firmware_invalid_transmit_word_count
- fw_link_failure => firmware_link_failure_count
- fw_loss_of_signal => firmware_loss_of_signal_count
- fw_loss_of_sync => firmware_loss_of_sync_count
- hard_reset_cnt => hard_reset_count
- instance_name => fcvi
- instance_uuid
- node_name => node
- rdma_write_avg_latency
- rdma_write_ops
- rdma_write_throughput
- soft_reset_cnt => soft_reset_count

plugins:
- FCVI

export_options:
instance_keys:
- fcvi
- node
- port
1 change: 0 additions & 1 deletion conf/zapiperf/cdot/9.8.0/iwarp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ counters:
- iw_read_ops => read_ops
- iw_write_ops => write_ops
- node_name => node
- rdma_write_throughput

export_options:
instance_keys:
Expand Down
Loading