Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/snclient/check_drivesize.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,18 @@ func (l *CheckDrivesize) addMetrics(drive string, check *CheckData, usage *disk.
total = usage.Used + usage.Free // use this total instead of usage.Total to account in the root reserved space
}

// need to detect conditions where the operand is named '<drive> used %', this is the default way snclient names percent usage metrics.
// if there is a condition using that as an operand, add usage metrics for that drive as well. these metrics will be added for that drive only.
// this helps to check usage metrics specific to drives.
percentageUsageMetric := fmt.Sprintf("%s used %%", drive)

if check.HasThreshold("free") || check.HasThreshold("free_pct") || check.HasThreshold("free_bytes") {
check.warnThreshold = check.TransformMultipleKeywords([]string{"free_pct", "free_bytes"}, "free", check.warnThreshold)
check.critThreshold = check.TransformMultipleKeywords([]string{"free_pct", "free_bytes"}, "free", check.critThreshold)
check.AddBytePercentMetrics("free", drive+" free", magic*float64(usage.Free), magic*float64(total))
}
if check.HasThreshold("used") || check.HasThreshold("used_pct") || check.HasThreshold("used_bytes") {

if check.HasThreshold(percentageUsageMetric) || check.HasThreshold("used") || check.HasThreshold("used_pct") || check.HasThreshold("used_bytes") {
check.warnThreshold = check.TransformMultipleKeywords([]string{"used_pct", "used_bytes"}, "used", check.warnThreshold)
check.critThreshold = check.TransformMultipleKeywords([]string{"used_pct", "used_bytes"}, "used", check.critThreshold)
check.AddBytePercentMetrics("used", drive+" used", magic*float64(usage.Used), magic*float64(total))
Expand Down
Loading