Skip to content

Metric conditions evaluation hotfix and check_drivesize tests#428

Closed
inqrphl wants to merge 9 commits into
mainfrom
metric-conditions-evaluation-hotfix
Closed

Metric conditions evaluation hotfix and check_drivesize tests#428
inqrphl wants to merge 9 commits into
mainfrom
metric-conditions-evaluation-hotfix

Conversation

@inqrphl

@inqrphl inqrphl commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

metric: fix CheckMetric.CheckForThresholds

it performed short-circuiting tests over the ConditionList, which leads to maximum of one correct resulting condition.

the result thould then be len(corrects) > 0 , not > 1 which is always false

checks: CheckData.CheckMetrics uses the metric's condition list, which is fresher and canonical

The metrics condition list may be modified during the check.

When using the default check.warnCond and check.critCond , they might be stale.

check_drivesize: support keywords using "used %" , "free %" "inodes_used %" "inodes_free %" literally in thresholds

check if these exist, then add metrics accordingly

add tests that check for different keyword usage:
'[drive] used %'
'[drive] used_pct'
'used %'

also add test for the specialzation, where having a "drive" keyword containing condition in the threshold, applies a filter for the metrics originating from that entry

Ahmet Oeztuerk and others added 8 commits July 23, 2026 16:56
it performed short-circuiting tests over the ConditionList, which leads to maximum of one correct resulting condition.

the result thould then be len(corrects) > 0 , not > 1 which is always false
…h is fresher and canonical

The metrics condition list may be modified during the check.

When using the default check.warnCond and check.critCond , they might be stale.
…sed %" "inodes_free %" literally in thresholds

check if these exist, then add metrics accordingly

add tests that check for different keyword usage:
'[drive] used %'
'[drive] used_pct'
'used %'

also add test for the specialzation, where having a "drive" keyword containing condition in the threshold, applies a filter for the metrics originating from that entry
…ition, check if perfdata is specialized according to the conditions
… and darwin

it uses both / and /tmp drives and those are not mounted as drives, or unavailable in those platforms
…data tests

it is failing even on linux systems in github ci since /tmp is not a drive there
Comment thread pkg/snclient/checkdata.go Outdated

// CheckMetrics tries warn/crit/ok conditions against given metrics and sets final state accordingly
func (cd *CheckData) CheckMetrics(warnCond, critCond, okCond ConditionList) {
func (cd *CheckData) CheckMetrics(_, _, okCond ConditionList) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is only used from one place, if 2 of 3 arguments are not used at all, they should be removed and the description should be adjusted. Otherwise it is misleading.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

minVal := utils.ToPrecision(sensor.Min, 3)
maxVal := utils.ToPrecision(sensor.High, 3)
var warning, critical ConditionList
if sensor.Min != 0 || sensor.Critical != 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is the expansion of temp and temperature related to Min/Critical? I don't understand why this is necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expansion has nothing to do with it, I am only adding the modified warning/critical thresholds if sensor.Min != 0 or sensor.Critical != 0

Some sensors report min==0 and then get added, only to fail directly in the check_temperature_test

Of course that problem only started happening after the CheckMetric.CheckForThresholds was fixed in the pr.

… CheckMetrics call

metrics save their own warning and critical thresholds inside a ConditionList in the CheckMetric object.
while saving these, the thresholds may be modified, including filtering and keyword transformations

only the okCondition is supplied directly from the check itself.
@sni sni closed this Jul 23, 2026
@sni

sni commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

merged manually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants