Skip to content

Commit

Permalink
fix: enable root aggregate power (#2363)
Browse files Browse the repository at this point in the history
* fix: enable root aggregate power
  • Loading branch information
rahulguptajss authored Sep 15, 2023
1 parent 81418c4 commit ae6de6c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 102 deletions.
44 changes: 18 additions & 26 deletions cmd/collectors/restperf/plugins/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ type aggregate struct {
isShared bool
power float64
derivedType RaidAggrDerivedType
export bool
}

type disk struct {
Expand Down Expand Up @@ -408,7 +407,6 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix)
if totalTransfers == nil {
return output, errs.New(errs.ErrNoMetric, "total_transfer_count")
}
totaliops := make(map[string]float64)

// calculate power for returned disks in perf response
for _, instance := range data.GetInstances() {
Expand All @@ -433,9 +431,7 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix)
sh, ok := d.ShelfMap[shelfID]
if ok {
diskPower := v * sh.power / sh.iops
totaliops[shelfID] = totaliops[shelfID] + v
aggrPower := a.power + diskPower
a.power = aggrPower
a.power += diskPower
}
} else {
d.Logger.Warn().Str("diskUUID", diskUUID).
Expand Down Expand Up @@ -485,25 +481,24 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix)

// fill aggr power matrix with power calculated above
for k, v := range d.aggrMap {
if v.export {
instanceKey := k
instance, err := aggrData.NewInstance(instanceKey)
if err != nil {
d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to add instance")
continue
}
instance.SetLabel("aggr", k)
instance.SetLabel("derivedType", string(v.derivedType))
instance.SetLabel("node", v.node)

m := aggrData.GetMetric("power")
err = m.SetValueFloat64(instance, v.power)
if err != nil {
d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to set value")
continue
}
instanceKey := k
instance, err := aggrData.NewInstance(instanceKey)
if err != nil {
d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to add instance")
continue
}
instance.SetLabel("aggr", k)
instance.SetLabel("derivedType", string(v.derivedType))
instance.SetLabel("node", v.node)

m := aggrData.GetMetric("power")
err = m.SetValueFloat64(instance, v.power)
if err != nil {
d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to set value")
continue
}
}

output = append(output, aggrData)
return output, nil

Expand Down Expand Up @@ -605,7 +600,7 @@ func (d *Disk) getAggregates() error {

query := "api/private/cli/aggr"

href := rest.BuildHref("", "aggregate,composite,node,uses_shared_disks,root,storage_type", nil, "", "", "", "", query)
href := rest.BuildHref("", "aggregate,composite,node,uses_shared_disks,storage_type", nil, "", "", "", "", query)

records, err := rest.Fetch(d.client, href)
if err != nil {
Expand All @@ -625,19 +620,16 @@ func (d *Disk) getAggregates() error {
aggrName := aggr.Get("aggregate").String()
usesSharedDisks := aggr.Get("uses_shared_disks").String()
isC := aggr.Get("composite").String()
isR := aggr.Get("root").String()
aggregateType := aggr.Get("storage_type").String()
nodeName := aggr.Get("node").String()
isShared := usesSharedDisks == "true"
isRootAggregate := isR == "true"
isComposite := isC == "true"
derivedType := getAggregateDerivedType(aggregateType, isComposite, isShared)
d.aggrMap[aggrName] = &aggregate{
name: aggrName,
isShared: isShared,
derivedType: derivedType,
node: nodeName,
export: !isRootAggregate,
}
}
return nil
Expand Down
43 changes: 16 additions & 27 deletions cmd/collectors/zapiperf/plugins/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ type aggregate struct {
isShared bool
power float64
derivedType RaidAggrDerivedType
export bool
}

type disk struct {
Expand Down Expand Up @@ -313,7 +312,6 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix)
if totalTransfers == nil {
return output, errs.New(errs.ErrNoMetric, "total_transfers")
}
totaliops := make(map[string]float64)

// calculate power for returned disks in zapiperf response
for _, instance := range data.GetInstances() {
Expand All @@ -335,9 +333,7 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix)
sh, ok := d.ShelfMap[shelfID]
if ok {
diskPower := v * sh.power / sh.iops
totaliops[shelfID] = totaliops[shelfID] + v
aggrPower := a.power + diskPower
a.power = aggrPower
a.power += diskPower
}
} else {
d.Logger.Warn().Str("diskUUID", diskUUID).Msg("Missing disk info")
Expand Down Expand Up @@ -385,23 +381,21 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix)

// fill aggr power matrix with power calculated above
for k, v := range d.aggrMap {
if v.export {
instanceKey := k
instance, err := aggrData.NewInstance(instanceKey)
if err != nil {
d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to add instance")
continue
}
instance.SetLabel("aggr", k)
instance.SetLabel("derivedType", string(v.derivedType))
instance.SetLabel("node", v.node)

m := aggrData.GetMetric("power")
err = m.SetValueFloat64(instance, v.power)
if err != nil {
d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to set value")
continue
}
instanceKey := k
instance, err := aggrData.NewInstance(instanceKey)
if err != nil {
d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to add instance")
continue
}
instance.SetLabel("aggr", k)
instance.SetLabel("derivedType", string(v.derivedType))
instance.SetLabel("node", v.node)

m := aggrData.GetMetric("power")
err = m.SetValueFloat64(instance, v.power)
if err != nil {
d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to set value")
continue
}
}
output = append(output, aggrData)
Expand Down Expand Up @@ -553,7 +547,6 @@ func (d *Disk) getAggregates() error {
aggrRaidAttributes.NewChildS("uses-shared-disks", "")
aggrRaidAttributes.NewChildS("aggregate-type", "")
aggrRaidAttributes.NewChildS("is-composite", "")
aggrRaidAttributes.NewChildS("is-root-aggregate", "")
aggrAttributes.AddChild(aggrRaidAttributes)
aggrAttributes.AddChild(aggrOwnerAttributes)
desired.AddChild(aggrAttributes)
Expand Down Expand Up @@ -584,21 +577,17 @@ func (d *Disk) getAggregates() error {
nodeName = aggrOwnerAttr.GetChildContentS("home-name")
}
if aggrRaidAttr != nil {
isR := aggrRaidAttr.GetChildContentS("is-root-aggregate")

usesSharedDisks := aggrRaidAttr.GetChildContentS("uses-shared-disks")
aggregateType := aggrRaidAttr.GetChildContentS("aggregate-type")
isC := aggrRaidAttr.GetChildContentS("is-composite")
isComposite := isC == "true"
isShared := usesSharedDisks == "true"
isRootAggregate := isR == "true"
derivedType := getAggregateDerivedType(aggregateType, isComposite, isShared)
d.aggrMap[aggrName] = &aggregate{
name: aggrName,
isShared: isShared,
derivedType: derivedType,
node: nodeName,
export: !isRootAggregate,
}
}
}
Expand Down
59 changes: 10 additions & 49 deletions grafana/dashboards/cmode/power.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"gnetId": null,
"graphTooltip": 1,
"id": null,
"iteration": 1694453038642,
"iteration": 1694717870555,
"links": [
{
"asDropdown": true,
Expand Down Expand Up @@ -1353,15 +1353,15 @@
"targets": [
{
"exemplar": false,
"expr": "sum(aggr_disk_user_reads{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"} and on(aggr,cluster,node) aggr_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"}) by (aggr,cluster,node)",
"expr": "sum(aggr_disk_user_reads{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"}) by (aggr,cluster,node)",
"hide": false,
"interval": "",
"legendFormat": "Reads - {{aggr}} ({{cluster}})",
"refId": "B"
},
{
"exemplar": false,
"expr": "sum(aggr_disk_user_writes{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"} and on(aggr,cluster,node) aggr_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"}) by (aggr,cluster,node)",
"expr": "sum(aggr_disk_user_writes{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"}) by (aggr,cluster,node)",
"hide": false,
"interval": "",
"legendFormat": "Writes - {{aggr}} ({{cluster}})",
Expand Down Expand Up @@ -1635,7 +1635,7 @@
"h": 8,
"w": 24,
"x": 0,
"y": 52
"y": 57
},
"id": 91,
"interval": "1m",
Expand Down Expand Up @@ -1664,37 +1664,7 @@
},
{
"exemplar": false,
"expr": "aggr_space_total{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}",
"format": "table",
"hide": false,
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "D"
},
{
"exemplar": false,
"expr": "aggr_space_used{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}",
"format": "table",
"hide": false,
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "E"
},
{
"exemplar": false,
"expr": "aggr_space_used_percent{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}",
"format": "table",
"hide": false,
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "F"
},
{
"exemplar": false,
"expr": "sum(aggr_disk_total_transfers{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"} and on(aggr,cluster,node) aggr_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}) by (aggr,cluster,node)",
"expr": "sum(aggr_disk_total_transfers{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}) by (aggr,cluster,node)",
"format": "table",
"hide": false,
"instant": true,
Expand All @@ -1704,23 +1674,13 @@
},
{
"exemplar": false,
"expr": "sum(aggr_disk_total_data{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"} and on(aggr,cluster,node) aggr_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}) by (aggr,cluster,node)",
"expr": "sum(aggr_disk_total_data{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}) by (aggr,cluster,node)",
"format": "table",
"hide": false,
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "G"
},
{
"exemplar": false,
"expr": "aggr_new_status{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}",
"format": "table",
"hide": false,
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
Expand Down Expand Up @@ -2849,7 +2809,7 @@
"h": 7,
"w": 24,
"x": 0,
"y": 58
"y": 60
},
"id": 81,
"interval": "1m",
Expand All @@ -2861,6 +2821,7 @@
"pluginVersion": "8.1.8",
"targets": [
{
"exemplar": false,
"expr": "shelf_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}",
"format": "table",
"instant": true,
Expand Down Expand Up @@ -2890,7 +2851,7 @@
},
{
"exemplar": false,
"expr": "shelf_power{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}",
"expr": "shelf_power{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"} * on(datacenter,cluster,shelf) shelf_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",isEmbedded=\"No\"}",
"format": "table",
"hide": false,
"instant": true,
Expand Down Expand Up @@ -3399,5 +3360,5 @@
"timezone": "",
"title": "ONTAP: Power",
"uid": "",
"version": 11
"version": 12
}

0 comments on commit ae6de6c

Please sign in to comment.