Skip to content

Commit

Permalink
feat: Harvest should collect adaptive QOS policy groups (#1847)
Browse files Browse the repository at this point in the history
* feat: Harvest should collect adaptive QOS policy groups

Thanks to faguayot for reporting

* feat: Harvest should collect adaptive QOS policy groups

Thanks to faguayot for reporting
  • Loading branch information
cgrinds authored Mar 23, 2023
1 parent f7297a4 commit 07bd392
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 1 deletion.
36 changes: 36 additions & 0 deletions cmd/collectors/rest/plugins/qospolicyadaptive/qospolicyadaptive.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package qospolicyadaptive

import (
"github.com/netapp/harvest/v2/cmd/collectors/zapi/plugins/qospolicyfixed"
"github.com/netapp/harvest/v2/cmd/poller/plugin"
"github.com/netapp/harvest/v2/pkg/matrix"
)

type QosPolicyAdaptive struct {
*plugin.AbstractPlugin
}

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

func (p *QosPolicyAdaptive) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error) {
data := dataMap[p.Object]
for _, instance := range data.GetInstances() {
p.setIOPs(instance, "absolute_min_iops")
p.setIOPs(instance, "expected_iops")
p.setIOPs(instance, "peak_iops")
}

return nil, nil
}

func (p *QosPolicyAdaptive) setIOPs(instance *matrix.Instance, labelName string) {
val := instance.GetLabel(labelName)
xput, err := qospolicyfixed.ZapiXputToRest(val)
if err != nil {
p.Logger.Warn().Str("label", labelName).Str("val", val).Msg("Unable to convert label, skipping")
return
}
instance.SetLabel(labelName, xput.IOPS)
}
4 changes: 4 additions & 0 deletions cmd/collectors/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/certificate"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/disk"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/netroute"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/qospolicyadaptive"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/qospolicyfixed"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/qtree"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/securityaccount"
Expand Down Expand Up @@ -387,6 +388,9 @@ func (r *Rest) LoadPlugin(kind string, abc *plugin.AbstractPlugin) plugin.Plugin
return securityaccount.New(abc)
case "QosPolicyFixed":
return qospolicyfixed.New(abc)
case "QosPolicyAdaptive":
return qospolicyadaptive.New(abc)

default:
r.Logger.Warn().Str("kind", kind).Msg("no rest plugin found ")
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/collectors/zapi/collector/zapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package zapi
import (
"fmt"
"github.com/netapp/harvest/v2/cmd/collectors/zapi/plugins/certificate"
"github.com/netapp/harvest/v2/cmd/collectors/zapi/plugins/qospolicyadaptive"
"github.com/netapp/harvest/v2/cmd/collectors/zapi/plugins/qospolicyfixed"
"github.com/netapp/harvest/v2/cmd/collectors/zapi/plugins/qtree"
"github.com/netapp/harvest/v2/cmd/collectors/zapi/plugins/security"
Expand Down Expand Up @@ -153,6 +154,8 @@ func (z *Zapi) LoadPlugin(kind string, abc *plugin.AbstractPlugin) plugin.Plugin
return security.New(abc)
case "QosPolicyFixed":
return qospolicyfixed.New(abc)
case "QosPolicyAdaptive":
return qospolicyadaptive.New(abc)

default:
z.Logger.Info().Msgf("no zapi plugin found for %s", kind)
Expand Down
36 changes: 36 additions & 0 deletions cmd/collectors/zapi/plugins/qospolicyadaptive/qospolicyadaptive.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package qospolicyadaptive

import (
"github.com/netapp/harvest/v2/cmd/collectors/zapi/plugins/qospolicyfixed"
"github.com/netapp/harvest/v2/cmd/poller/plugin"
"github.com/netapp/harvest/v2/pkg/matrix"
)

type QosPolicyAdaptive struct {
*plugin.AbstractPlugin
}

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

func (p *QosPolicyAdaptive) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error) {
data := dataMap[p.Object]
for _, instance := range data.GetInstances() {
p.setIOPs(instance, "absolute_min_iops")
p.setIOPs(instance, "expected_iops")
p.setIOPs(instance, "peak_iops")
}

return nil, nil
}

func (p *QosPolicyAdaptive) setIOPs(instance *matrix.Instance, labelName string) {
val := instance.GetLabel(labelName)
xput, err := qospolicyfixed.ZapiXputToRest(val)
if err != nil {
p.Logger.Warn().Str("label", labelName).Str("val", val).Msg("Unable to convert label, skipping")
return
}
instance.SetLabel(labelName, xput.IOPS)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ func Test_zapiXputToRest(t *testing.T) {
want MaxXput
isErr bool
}{
// Adaptive QOS uses this form, test it here too
{zapi: "6144IOPS/TB", want: MaxXput{IOPS: "6144", Mbps: "0"}},

{zapi: "100IOPS", want: MaxXput{IOPS: "100", Mbps: "0"}},
{zapi: "100iops", want: MaxXput{IOPS: "100", Mbps: "0"}},
{zapi: "111111IOPS", want: MaxXput{IOPS: "111111", Mbps: "0"}},
Expand Down
30 changes: 30 additions & 0 deletions conf/rest/9.12.0/qos_policy_adaptive.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

name: QosPolicyAdaptive
query: api/private/cli/qos/adaptive-policy-group
object: qos_policy_adaptive

counters:
- ^^uuid => uuid
- ^policy_group => name
- ^vserver => svm
- ^absolute_min_iops => absolute_min_iops
- ^expected_iops => expected_iops
- ^expected_iops_allocation => expected_iops_allocation
- ^num_workloads => object_count
- ^peak_iops => peak_iops
- ^peak_iops_allocation => peak_iops_allocation

plugins:
- QosPolicyAdaptive

export_options:
instance_keys:
- svm
instance_labels:
- name
- absolute_min_iops
- expected_iops
- expected_iops_allocation
- object_count
- peak_iops
- peak_iops_allocation
1 change: 1 addition & 0 deletions conf/rest/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ objects:
NtpServer: ntpserver.yaml
OntapS3: ontap_s3.yaml
Port: port.yaml
QosPolicyAdaptive: qos_policy_adaptive.yaml
QosPolicyFixed: qos_policy_fixed.yaml
Qtree: qtree.yaml
Security: security.yaml
Expand Down
33 changes: 33 additions & 0 deletions conf/zapi/cdot/9.8.0/qos_policy_adaptive.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

name: QosPolicyAdaptive
query: qos-adaptive-policy-group-get-iter
object: qos_policy_adaptive

counters:
qos-adaptive-policy-group-info:
- ^^uuid => uuid
- ^policy-group => name
- ^vserver => svm
- ^absolute-min-iops => absolute_min_iops
- ^expected-iops => expected_iops
- ^expected-iops-allocation => expected_iops_allocation
- ^num-workloads => object_count
- ^peak-iops => peak_iops
- ^peak-iops-allocation => peak_iops_allocation

collect_only_labels: true

plugins:
- QosPolicyAdaptive

export_options:
instance_keys:
- svm
instance_labels:
- name
- absolute_min_iops
- expected_iops
- expected_iops_allocation
- object_count
- peak_iops
- peak_iops_allocation
3 changes: 2 additions & 1 deletion conf/zapi/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ objects:
# NetPort: netPort.yaml
Node: node.yaml
NtpServer: ntpserver.yaml
QosPolicy: qos_policy_fixed.yaml
QosPolicyAdaptive: qos_policy_adaptive.yaml
QosPolicyFixed: qos_policy_fixed.yaml
Qtree: qtree.yaml
Security: security.yaml
SecurityAccount: security_account.yaml
Expand Down

0 comments on commit 07bd392

Please sign in to comment.