Skip to content

Commit c24193f

Browse files
committed
fix(plugins): threshold checks use the right metric (#1070)
Three plugins ran their get_state() / oao() call against the wrong value, silently discarding the check result: - wildfly-non-xa-datasource-stats and wildfly-xa-datasource-stats: the "max used" threshold check passed `active_pct` to `lib.base.get_state(...)` instead of `max_used_pct`, so the plugin alerted on the wrong metric. The output text already showed `max_used_pct` correctly, so this only shifts which value is compared against the thresholds. - network-connections: the final `lib.base.oao()` call passed a hardcoded `STATE_OK` instead of the accumulated `state`, discarding all WARN/CRIT decisions from the loop. The plugin now exits with the correct accumulated state. matomo-reporting, mysql-sorts and starface-channel-status were also flagged in the audit backlog but turned out to be false positives on closer reading: matomo's no-METRIC branch is an informational "list everything" mode where STATE_OK is the intended behavior, mysql-sorts does combine state via `get_worst(state, sort_state)` correctly, and starface-channel-status passes string thresholds which `lib.base.get_state()` converts to float internally.
1 parent 56c7cf8 commit c24193f

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
* Fix `--require-hashes` pip install in pre-commit autoupdate workflow by using pinned version instead
1414
* tox.ini: disable the sdist build (`no_package = true`) so `tox` no longer trips over the flat top-level layout with "Multiple top-level packages discovered". The repo is a collection of plugin scripts, not a Python package
1515
* tools/run-unit-tests: skip the `example` plugin in default runs. Its unit test is a template meant to be copy-pasted into new plugins and does not correspond to a real check. Explicit `python tools/run-unit-tests example` still runs it
16+
* starface-java-memory-usage: the heap and non-heap state checks used `state += lib.base.get_worst(used_state, state)` which adds state integers together and corrupts the accumulated state (e.g. WARN+WARN=2 reads as CRIT, WARN+CRIT=3 is outside the valid range). Replaced with `state = lib.base.get_worst(state, used_state)` so the accumulated state remains a valid STATE_OK / STATE_WARN / STATE_CRIT value ([#1070](https://github.com/Linuxfabrik/monitoring-plugins/issues/1070))
17+
* wildfly-memory-usage: same `state += get_worst(...)` accumulation bug in both the heap and non-heap branches. Replaced with the new variadic `lib.base.get_worst(state, used_state, committed_state)` so the heap/non-heap used/committed states can be combined in a single call ([#1070](https://github.com/Linuxfabrik/monitoring-plugins/issues/1070))
18+
* wildfly-non-xa-datasource-stats, wildfly-xa-datasource-stats: the "max used" threshold check passed `active_pct` to `lib.base.get_state(...)` instead of `max_used_pct`, so the plugin alerted on the wrong metric. The output text already showed `max_used_pct` correctly ([#1070](https://github.com/Linuxfabrik/monitoring-plugins/issues/1070))
19+
* network-connections: the final `lib.base.oao()` call passed a hardcoded `STATE_OK` instead of the accumulated `state`, discarding all WARN/CRIT decisions from the loop. The plugin now exits with the correct accumulated state ([#1070](https://github.com/Linuxfabrik/monitoring-plugins/issues/1070))
1620
* `.github/workflows/docs.yml`: pin all GitHub Actions by commit SHA (with the version as a trailing comment) instead of by tag, clearing the four OpenSSF Scorecard `PinnedDependenciesID` alerts. Dependabot is already configured for `github-actions` and updates hash-pinned actions natively
1721
* deb-updates: add missing `lib.txt` import so the "N update(s) available" summary no longer crashes with `AttributeError` at runtime
1822
* mysql-memory: fix `get_other_process_memory()` fallback path for psutil older than 5.3.0 (referenced an undefined `cmdline` variable and the wrong attribute on the process dict) and drop an unreachable `break` after `return` in `get_pfs_memory()`

check-plugins/network-connections/network-connections

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ except ImportError:
2525

2626

2727
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
28-
__version__ = '2026040801'
28+
__version__ = '2026041201'
2929

3030
DESCRIPTION = """Counts system-wide socket connections by type (TCP, TCP6, UDP, UDP6) and state.
3131
Alerts when the total number of connections in a specific state exceeds the configured
@@ -175,7 +175,7 @@ def main():
175175
)
176176

177177
# over and out
178-
lib.base.oao(msg[:-2], STATE_OK, perfdata)
178+
lib.base.oao(msg[:-2], state, perfdata)
179179

180180

181181
if __name__ == '__main__':

check-plugins/wildfly-non-xa-datasource-stats/wildfly-non-xa-datasource-stats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import lib.wildfly
1919
from lib.globals import STATE_OK, STATE_UNKNOWN
2020

2121
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
22-
__version__ = '2026040801'
22+
__version__ = '2026041201'
2323

2424
DESCRIPTION = """Monitors non-XA datasource connection pool metrics on a WildFly/JBoss AS server via
2525
its HTTP management API. Reports active, available, and idle connections. Alerts when
@@ -221,7 +221,7 @@ def check_non_xa_datasource(args):
221221
msg += f'{active_pct}% active used ({active}/{available}){lib.base.state2str(local_state, prefix=" ")}, '
222222
state = lib.base.get_worst(local_state, state)
223223

224-
local_state = lib.base.get_state(active_pct, args.WARN, args.CRIT)
224+
local_state = lib.base.get_state(max_used_pct, args.WARN, args.CRIT)
225225
msg += f'{max_used_pct}% max used ({max_used}/{available}){lib.base.state2str(local_state, prefix=" ")}, '
226226
state = lib.base.get_worst(local_state, state)
227227

check-plugins/wildfly-xa-datasource-stats/wildfly-xa-datasource-stats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import lib.wildfly
1919
from lib.globals import STATE_OK, STATE_UNKNOWN
2020

2121
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
22-
__version__ = '2026040801'
22+
__version__ = '2026041201'
2323

2424
DESCRIPTION = """Monitors XA datasource connection pool metrics on a WildFly/JBoss AS server via its
2525
HTTP management API. Reports active, available, and idle connections. Alerts when pool
@@ -221,7 +221,7 @@ def check_xa_datasource(args):
221221
msg += f'{active_pct}% active used ({active}/{available}){lib.base.state2str(local_state, prefix=" ")}, '
222222
state = lib.base.get_worst(local_state, state)
223223

224-
local_state = lib.base.get_state(active_pct, args.WARN, args.CRIT)
224+
local_state = lib.base.get_state(max_used_pct, args.WARN, args.CRIT)
225225
msg += f'{max_used_pct}% max used ({max_used}/{available}){lib.base.state2str(local_state, prefix=" ")}, '
226226
state = lib.base.get_worst(local_state, state)
227227

0 commit comments

Comments
 (0)