Skip to content

Commit d0931d2

Browse files
committed
18975 FIX ibm_mq_queues: Support QStatus from CSQM format
Users monitoring IBM MQ on Mainframe (z/OS) systems via Piggyback encountered crashes and missing data following the changes in Werk The following problems have been resolved: Crash: "ValueError: Cannot render negative timespan": `ibm_mq_queues` check crashed with a `ValueError` when the IBM MQ system clock was ahead or due to parsing precision differences. Use absolute time difference to prevent negative timespans and crashes. Data Merging: Users reported `duplicate section definition` errors or missing service details when monitoring Mainframe queues. The agent receives split information for `QUEUE` and `QSTATUS`. The plugin now parses and merges `QUEUE` and `QSTATUS` outputs correctly. This merge combines the mq data into a single service. This resolves the crash and populates all metrics correctly. Parsing of Empty Values: The parser now handles empty values in the agent output correctly. Previously, strict parsing logic led to incomplete data parsing or missing services. Before this fix, you might have seen crashes in the `ibm_mq_queues` check or missing queue metrics. After updating, monitoring will be stable and complete without needing any changes to your configuration. JIRA-Ref: SUP-23371 | SUP-26328 | CMK-32551 Change-Id: If818fecfd866aa24c80eb45eb32284ab0f12c958
1 parent 3cb4d0d commit d0931d2

4 files changed

Lines changed: 42 additions & 4 deletions

File tree

.werks/18975.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[//]: # (werk v2)
2+
# ibm_mq_queues: Support additional QStatus informations from CSQM format
3+
4+
key | value
5+
---------- | ---
6+
date | 2025-12-15T10:00:36+00:00
7+
version | 2.3.0p46
8+
class | fix
9+
edition | cre
10+
component | checks
11+
level | 1
12+
compatible | yes
13+
14+
Users monitoring IBM MQ on Mainframe (z/OS) systems via Piggyback encountered crashes and missing data following the changes in Werk #18303.
15+
16+
The following problems have been resolved:
17+
18+
**Crash: "ValueError: Cannot render negative timespan"**: `ibm_mq_queues` check crashed with a `ValueError` when the IBM MQ system clock was ahead or due to parsing precision differences. Use absolute time difference to prevent negative timespans and crashes.
19+
20+
**Data Merging**: Users reported `duplicate section definition` errors or missing service details when monitoring Mainframe queues. The agent receives split information for `QUEUE` and `QSTATUS`.
21+
22+
The plugin now parses and merges `QUEUE` and `QSTATUS` outputs correctly. This merge combines the mq data into a single service. This resolves the crash and populates all metrics correctly.
23+
24+
**Parsing of Empty Values**: The parser now handles empty values in the agent output correctly. Previously, strict parsing logic led to incomplete data parsing or missing services.
25+
26+
Before this fix, you might have seen crashes in the `ibm_mq_queues` check or missing queue metrics. After updating, monitoring will be stable and complete without needing any changes to your configuration.

cmk/base/legacy_checks/ibm_mq_queues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def ibm_mq_last_age(mq_date, mq_time, agent_timestamp, label, key, params):
161161
return (0, label + ": n/a", [])
162162
mq_datetime = "{} {}".format(mq_date, mq_time.replace(".", ":"))
163163
input_time = dateutil.parser.parse(mq_datetime, default=agent_timestamp)
164-
age = (agent_timestamp - input_time).total_seconds()
164+
age = abs((agent_timestamp - input_time).total_seconds())
165165
return check_levels(
166166
age, None, params.get(key), human_readable_func=render.timespan, infoname=label
167167
)

cmk/base/plugins/agent_based/ibm_mq_queues.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@
1515

1616

1717
def parse_ibm_mq_queues(string_table: StringTable) -> Section:
18-
return parse_ibm_mq(string_table, "QUEUE")
18+
queue_status = parse_ibm_mq(string_table, "QSTATUS")
19+
queue = parse_ibm_mq(string_table, "QUEUE")
20+
return _deep_merge_sections(queue, queue_status)
21+
22+
23+
def _deep_merge_sections(priority_section: Section, additional_section: Section) -> Section:
24+
result = dict(additional_section)
25+
for key, value in priority_section.items():
26+
if key in result and isinstance(result[key], dict) and isinstance(value, dict):
27+
result[key] = _deep_merge_sections(value, result[key])
28+
else:
29+
result[key] = value
30+
return result
1931

2032

2133
register.agent_section(

cmk/plugins/lib/ibm_mq.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
RE_INTRO = re.compile(r"^QMNAME\((.*)\)[\s]*STATUS\((.*?)\)[\s]*NOW\((.*)\)")
1515
RE_GROUP = re.compile(r"^(AMQ\d+\w?:|CSQM\d+\w? !)")
1616
RE_KEY = re.compile(r"([\s]*|CSQM\d+\w? ![A-Z0-9.]+[\s]+)([A-Z0-9]+\()")
17-
RE_SECOND_COLUMN = re.compile(r"[A-Z]+\([^&]+\)$")
18-
RE_KEY_VALUE = re.compile(r"([A-Z0-9]+)\(([^&]+)\)")
17+
RE_SECOND_COLUMN = re.compile(r"[A-Z]+\([^&]*\)$")
18+
RE_KEY_VALUE = re.compile(r"([A-Z0-9]+)\(([^&]*)\)")
1919

2020

2121
def parse_ibm_mq(string_table: StringTable, group_by_object: str) -> Section:

0 commit comments

Comments
 (0)