Skip to content

Commit e00239d

Browse files
committed
Add Werk 19272 FIX Text logfiles: New messages dropped silently when reaching limit for stored messages
SUP-26490 Change-Id: Ia41e37601cb98157b6863e984c5f780c8af683f4
1 parent 5b058c1 commit e00239d

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

.werks/19272.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[//]: # (werk v3)
2+
# Text logfiles: New messages dropped silently when reaching limit for stored messages
3+
4+
key | value
5+
---------- | ---
6+
date | 2026-01-28T16:03:22+00:00
7+
version | 2.4.0p21
8+
class | fix
9+
edition | cre
10+
component | checks
11+
level | 1
12+
compatible | yes
13+
14+
The _Text logfiles_ check (_mk\_logwatch_), when reaching the maximum file size for saved messages, dropped new log messages silently without any notification.
15+
This led to a nonfunctional logfile monitoring that didn't process any new messages, and especially failed to detect WARN or CRIT patterns.
16+
17+
This is how it should have worked:
18+
During the processing of log messages with _mk\_logwatch_, relevant messages (depending on the logwatch configuration) are saved to a file on the monitoring server, and can be observed/acknowledged with the menu entry _Open log_ under the service's action menu.
19+
When this log file reaches the limit of 500 KB, _mk\_logwatch_ stops processing further messages, and the service shows the message `Unacknowledged messages have exceeded max size, new messages are dropped`, requiring the user to take action.
20+
21+
With this Werk, the maximum file size detection is functional again.
22+
23+
Please note that to resume monitoring you still must acknowledge the saved log messages.
24+
This is done by navigating to the log file via the _Open log_ entry and hitting _Clear log_.

cmk/plugins/logwatch/agent_based/logwatch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,10 @@ def _extract_blocks(
604604
*,
605605
limit: float = float("inf"),
606606
) -> Iterable[LogwatchBlock]:
607+
"""Extract logwatch blocks from the given lines.
608+
When limit is reached, stop processing further lines, but yield the current block so it can be
609+
written to file, triggering the file size limit.
610+
"""
607611
current_block = None
608612
for line in lines:
609613
line = line.rstrip("\n")
@@ -618,6 +622,7 @@ def _extract_blocks(
618622
current_block.add_line(line, reclassify)
619623
limit -= len(line.encode("utf-8"))
620624
if limit <= 0:
625+
yield current_block
621626
return
622627

623628
if current_block is not None:

0 commit comments

Comments
 (0)