Skip to content

Commit efc3c17

Browse files
committed
19772 FIX Oracle instance uptime check: handle negative uptime values
Crash-Group-ID: 3653 Jira: CMK-33556 Change-Id: Ifa37d181a46d576807a5ddf5670fa80bfcbbef3e
1 parent 6f47281 commit efc3c17

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

.werks/19772.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[//]: # (werk v3)
2+
# Oracle instance uptime check: handle negative uptime values
3+
4+
key | value
5+
---------- | ---
6+
date | 2026-04-14T12:00:00+00:00
7+
version | 2.6.0b1
8+
class | fix
9+
edition | community
10+
component | checks
11+
level | 1
12+
compatible | yes
13+
14+
The Oracle instance uptime check could crash with a `ValueError: Cannot render
15+
negative timespan` when the Oracle database reported a negative uptime value.
16+
This can happen due to clock synchronization issues or Oracle-internal anomalies.
17+
18+
The check now handles negative uptime values gracefully by reporting a warning
19+
instead of crashing.

cmk/plugins/oracle/agent_based/oracle_instance_check.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ def check_oracle_instance_uptime(
194194
if data.up_seconds is None:
195195
return
196196

197+
if data.up_seconds < 0:
198+
yield Result(
199+
state=State.WARN,
200+
summary=f"Uptime: invalid negative value ({data.up_seconds}s)",
201+
)
202+
return
203+
197204
yield Result(
198205
state=State.OK, summary=f"Up since {render.datetime(time.time() - data.up_seconds)}"
199206
)

tests/unit/cmk/plugins/oracle/agent_based/test_oracle_instance_uptime.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ def test_check_oracle_instance_uptime_error() -> None:
9090
)
9191

9292

93-
@pytest.mark.xfail(strict=True, reason="Crash group 3653: ValueError on negative up_seconds")
9493
def test_check_oracle_instance_uptime_negative_uptime() -> None:
95-
"""Negative up_seconds from Oracle causes ValueError in render.timespan."""
94+
"""Negative up_seconds from Oracle should produce a warning, not crash."""
9695
with time_machine.travel(datetime.datetime.fromtimestamp(1643360266, tz=ZoneInfo("UTC"))):
97-
results = list(
96+
assert list(
9897
check_plugin_oracle_instance_uptime.check_function(
9998
item="OBIP",
10099
params={},
@@ -108,9 +107,9 @@ def test_check_oracle_instance_uptime_negative_uptime() -> None:
108107
),
109108
},
110109
)
111-
)
112-
# Should not crash — negative uptime is an anomaly but should be handled gracefully
113-
assert any(isinstance(r, Result) for r in results)
110+
) == [
111+
Result(state=State.WARN, summary="Uptime: invalid negative value (-6689s)"),
112+
]
114113

115114

116115
def test_check_oracle_instance_uptime_pdb_mounted() -> None:

0 commit comments

Comments
 (0)