Skip to content

Commit

Permalink
feat: update dashboard with local policy settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardikl committed Dec 16, 2024
1 parent 3dd554d commit 7e2ebf3
Show file tree
Hide file tree
Showing 5 changed files with 594 additions and 6 deletions.
40 changes: 40 additions & 0 deletions cmd/collectors/rest/plugins/snapshotpolicy/snapshotpolicy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright NetApp Inc, 2024 All rights reserved
*/

package snapshotpolicy

import (
"github.com/netapp/harvest/v2/cmd/poller/plugin"
"github.com/netapp/harvest/v2/pkg/matrix"
"github.com/netapp/harvest/v2/pkg/util"
"strconv"
"strings"
)

type SnapshotPolicy struct {
*plugin.AbstractPlugin
}

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

func (m *SnapshotPolicy) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) {
// Purge and reset data
data := dataMap[m.Object]

for _, instance := range data.GetInstances() {
copies := strings.Split(instance.GetLabel("copies"), ",")
if len(copies) > 1 {
var copiesValue int
for _, c := range copies {
val, _ := strconv.Atoi(c)
copiesValue += val
}
instance.SetLabel("copies", strconv.Itoa(copiesValue))
}
}

return nil, nil, nil
}
3 changes: 3 additions & 0 deletions cmd/collectors/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/securityaccount"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/shelf"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/snapmirror"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/snapshotpolicy"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/svm"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/systemnode"
"github.com/netapp/harvest/v2/cmd/collectors/rest/plugins/volume"
Expand Down Expand Up @@ -498,6 +499,8 @@ func (r *Rest) LoadPlugin(kind string, abc *plugin.AbstractPlugin) plugin.Plugin
return collectors.NewSensor(abc)
case "Shelf":
return shelf.New(abc)
case "SnapshotPolicy":
return snapshotpolicy.New(abc)
case "SecurityAccount":
return securityaccount.New(abc)
case "QosPolicyFixed":
Expand Down
23 changes: 17 additions & 6 deletions conf/rest/9.12.0/snapshotpolicy.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
name: SnapshotPolicy
query: api/private/cli/snapshot/policy
query: api/storage/snapshot-policies
object: snapshot_policy

counters:
- ^^policy => snapshot_policy
- ^^vserver => svm
- ^^uuid => uuid
- ^comment => comment
- ^copies.#.count => copies
- ^enabled => status
- ^name => snapshot_policy
- ^schedules => schedules
- total_schedules => total_schedules
- ^scope => scope
- ^svm.name => svm

plugins:
- SnapshotPolicy

export_options:
instance_keys:
- snapshot_policy
instance_labels:
- comment
- copies
- schedules
- snapshot_policy
- svm
- scope
- status
- svm

2 changes: 2 additions & 0 deletions conf/rest/9.6.0/snapmirrorpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ object: snapmirror_policy

counters:
- ^^uuid => uuid
- ^comment => comment
- ^name => policy_name
- ^scope
- ^svm.name => svm
Expand All @@ -16,6 +17,7 @@ export_options:
- policy_name
- svm
instance_labels:
- comment
- policy_name
- schedule_name
- scope
Expand Down
Loading

0 comments on commit 7e2ebf3

Please sign in to comment.