-
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.
feat: add policy tables in data protection dashboard
- Loading branch information
Showing
8 changed files
with
516 additions
and
190 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
60 changes: 60 additions & 0 deletions
60
cmd/collectors/rest/plugins/clusterschedule/clusterschedule.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,60 @@ | ||
package clusterschedule | ||
|
||
import ( | ||
"github.com/netapp/harvest/v2/cmd/collectors" | ||
"github.com/netapp/harvest/v2/cmd/poller/plugin" | ||
"github.com/netapp/harvest/v2/pkg/matrix" | ||
"github.com/netapp/harvest/v2/pkg/util" | ||
"github.com/netapp/harvest/v2/third_party/tidwall/gjson" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
type ClusterScheule struct { | ||
*plugin.AbstractPlugin | ||
} | ||
|
||
func New(p *plugin.AbstractPlugin) plugin.Plugin { | ||
return &ClusterScheule{AbstractPlugin: p} | ||
} | ||
|
||
func (c *ClusterScheule) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) { | ||
for _, instance := range dataMap[c.Object].GetInstances() { | ||
intervalVal := collectors.HandleDuration(instance.GetLabel("interval")) | ||
instance.SetLabel("interval", strconv.FormatFloat(intervalVal, 'f', -1, 64)) | ||
|
||
cron := instance.GetLabel("cron") | ||
updateDetailsJSON := gjson.Result{Type: gjson.JSON, Raw: cron} | ||
var cronVal, minStr, hourStr, weekDayStr string | ||
if minutes := updateDetailsJSON.Get("minutes"); minutes.Exists() { | ||
for _, m := range minutes.Array() { | ||
minStr = minStr + m.String() + ", " | ||
} | ||
minStr = strings.TrimSuffix(minStr, ", ") | ||
} | ||
if hours := updateDetailsJSON.Get("hours"); hours.Exists() { | ||
for _, h := range hours.Array() { | ||
hourStr = hourStr + h.String() + ", " | ||
} | ||
hourStr = strings.TrimSuffix(hourStr, ", ") | ||
} | ||
if weekdays := updateDetailsJSON.Get("weekdays"); weekdays.Exists() { | ||
for _, w := range weekdays.Array() { | ||
weekDayStr = weekDayStr + w.String() + ", " | ||
} | ||
weekDayStr = strings.TrimSuffix(weekDayStr, ", ") | ||
} | ||
|
||
if minStr != "" { | ||
cronVal = cronVal + "minutes: " + "[" + minStr + "] " | ||
} | ||
if hourStr != "" { | ||
cronVal = cronVal + "hours: " + "[" + hourStr + "] " | ||
} | ||
if weekDayStr != "" { | ||
cronVal = cronVal + "weekdays: " + "[" + weekDayStr + "]" | ||
} | ||
instance.SetLabel("cron", cronVal) | ||
} | ||
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
Oops, something went wrong.