Skip to content

Commit 56c7cf8

Browse files
committed
fix(plugins): state accumulation uses = instead of += (#1070)
Both wildfly-memory-usage and starface-java-memory-usage built up their overall plugin state via `state += lib.base.get_worst(...)`. That adds the state integers together: STATE_WARN + STATE_WARN = 2 which reads as STATE_CRIT, STATE_WARN + STATE_CRIT = 3 which is outside the valid STATE range entirely. - wildfly-memory-usage: both the heap and non-heap branches combine three states (overall, used, committed). With the new variadic `lib.base.get_worst()` this is now a single clean call. - starface-java-memory-usage: the heap and non-heap branches each combine two states (accumulated, used). Standard `state = lib.base.get_worst(state, used_state)` call. Needs lib.base.get_worst variadic extension (shipped separately in lib).
1 parent 4c38fd7 commit 56c7cf8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

check-plugins/starface-java-memory-usage/starface-java-memory-usage

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import lib.txt
2424
from lib.globals import STATE_OK, STATE_UNKNOWN
2525

2626
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
27-
__version__ = '2026040801'
27+
__version__ = '2026041201'
2828

2929
DESCRIPTION = """Monitors Java heap and non-heap memory usage of a Starface PBX via its monitoring
3030
module on port 6556. Alerts when memory usage exceeds the configured thresholds.
@@ -194,7 +194,7 @@ def main():
194194
f'of {lib.human.bytes2human(mem_max)})'
195195
f'{lib.base.state2str(used_state, prefix=" ")}, '
196196
)
197-
state += lib.base.get_worst(used_state, state)
197+
state = lib.base.get_worst(state, used_state)
198198
perfdata += lib.base.get_perfdata(
199199
'heap-used-percent',
200200
used_percent,
@@ -243,7 +243,7 @@ def main():
243243
f'of {lib.human.bytes2human(mem_max)})'
244244
f'{lib.base.state2str(used_state, prefix=" ")}, '
245245
)
246-
state += lib.base.get_worst(used_state, state)
246+
state = lib.base.get_worst(state, used_state)
247247
perfdata += lib.base.get_perfdata(
248248
'non-heap-used-percent',
249249
used_percent,

check-plugins/wildfly-memory-usage/wildfly-memory-usage

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

2222
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
23-
__version__ = '2026040801'
23+
__version__ = '2026041201'
2424

2525
DESCRIPTION = """Checks Java heap and non-heap memory usage on a WildFly/JBoss AS server via its HTTP
2626
management API. Alerts when memory usage exceeds the configured thresholds."""
@@ -186,7 +186,7 @@ def main():
186186
f'{lib.base.state2str(committed_state, prefix=" ")}'
187187
f', '
188188
)
189-
state += lib.base.get_worst(used_state, committed_state)
189+
state = lib.base.get_worst(state, used_state, committed_state)
190190
perfdata += lib.base.get_perfdata(
191191
'heap-used-percent',
192192
used_percent,
@@ -247,7 +247,7 @@ def main():
247247
f'{lib.base.state2str(committed_state, prefix=" ")}'
248248
f', '
249249
)
250-
state += lib.base.get_worst(used_state, committed_state)
250+
state = lib.base.get_worst(state, used_state, committed_state)
251251
perfdata += lib.base.get_perfdata(
252252
'non-heap-used-percent',
253253
used_percent,

0 commit comments

Comments
 (0)