-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
169 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
cmd/collectors/zapi/plugins/snapshotpolicy/snapshotpolicy.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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"), ",") | ||
schedules := strings.Split(instance.GetLabel("schedules"), ",") | ||
|
||
var scheduleVal string | ||
var copiesValue int | ||
if len(copies) > 1 { | ||
for index, copiesData := range copies { | ||
countVal, _ := strconv.Atoi(copiesData) | ||
schedule := schedules[index] | ||
scheduleVal = scheduleVal + schedule + ":" + copiesData + "," | ||
copiesValue += countVal | ||
} | ||
instance.SetLabel("schedules", strings.TrimSuffix(scheduleVal, ",")) | ||
instance.SetLabel("copies", strconv.Itoa(copiesValue)) | ||
} | ||
} | ||
|
||
return nil, nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.