Skip to content

Commit

Permalink
15349 FIX oracle: Do not discover uptime service for template databases
Browse files Browse the repository at this point in the history
Template databases return `-1` for the uptime, which crashes the
services.

Databases having `-1` for uptime are no longer discovered.

You have to execute service discovery to make the broken uptime services
vanish.

SUP-21457

Change-Id: Ia4a422882013d662b124548f301fca69e2300e3b
  • Loading branch information
BenediktSeidl committed Dec 3, 2024
1 parent 81f12bf commit 9c2019d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .werks/15349.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[//]: # (werk v2)
# oracle: Do not discover uptime service for template databases

key | value
---------- | ---
date | 2024-11-27T09:55:10+00:00
version | 2.4.0b1
class | fix
edition | cre
component | checks
level | 1
compatible | yes

Template databases return `-1` for the uptime, which crashes the services.

Databases having `-1` for uptime are no longer discovered.

You have to execute service discovery to make the broken uptime services vanish.
2 changes: 1 addition & 1 deletion cmk/plugins/oracle/agent_based/oracle_instance_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def discover_oracle_instance_uptime(section: Section) -> DiscoveryResult:
yield from (
Service(item=item)
for item, data in section.items()
if isinstance(data, Instance) and data.up_seconds is not None
if isinstance(data, Instance) and data.up_seconds is not None and data.up_seconds != -1
)


Expand Down
10 changes: 10 additions & 0 deletions tests/unit/cmk/plugins/oracle/agent_based/test_oracle_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from cmk.agent_based.v2 import CheckResult, InventoryResult, Result, Service, State, TableRow
from cmk.plugins.lib.oracle_instance import GeneralError, Instance, InvalidData
from cmk.plugins.oracle.agent_based import oracle_instance_check
from cmk.plugins.oracle.agent_based.oracle_instance_inventory import inventory_oracle_instance
from cmk.plugins.oracle.agent_based.oracle_instance_section import parse_oracle_instance

Expand Down Expand Up @@ -775,3 +776,12 @@ def test_inv_oracle_instance_multiline() -> None:
assert sort_inventory_result(
inventory_oracle_instance(parse_oracle_instance(lines))
) == sort_inventory_result(expected_data)


def test_discover_template_database_negative_uptime():
# SUP-21457
instance_line = "OOOOOOOO|19.17.0.0.0|OPEN|ALLOWED|STARTED|111111|2222222222|ARCHIVELOG|PRIMARY|NO|OOOOOOOO|333333333333|TRUE|3|TTTT|4444444444|MOUNTED||5555555555|ENABLED|-1|6666|HHHHHHHH"
string_table = [instance_line.split("|")]
section = parse_oracle_instance(string_table)
items = list(oracle_instance_check.discover_oracle_instance_uptime(section))
assert not items

0 comments on commit 9c2019d

Please sign in to comment.