diff --git a/CHANGELOG.md b/CHANGELOG.md index a34f969..0b6a64c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,16 +26,18 @@ deployment very soon. ### Changed -- Ensure all telegraf metrics are timestamped in microseconds. - Because output to telegraf is buffered, we can't rely on telegraf doing the - timestamping (multiple samples get timestamped with the same or very similar - times), so we add a timestamp to every metric line as soon as we see it. +- Ensure all telegraf metrics are timestamped in microseconds. Because output to + telegraf is buffered, we can't rely on telegraf doing the timestamping + (multiple samples get timestamped with the same or very similar times), so we + add a timestamp to every metric line as soon as we see it. - `ntpmon_info` metric in telegraf mode split into `ntpmon_resident_set_size_bytes`, `ntpmon_virtual_memory_size_bytes`, and `ntpmon_uptime_seconds` in prometheus mode, with tags only on `ntpmon_uptime_seconds`, to tidy metric names and reduce tag cardinality when used with prometheus. These retain their existing names in telegraf mode. - +- Make messages from log file tailer tidier and more consistent. +- Correctly flag /etc/default/ntpmon as a configuration file in the Debian + package. ## [3.0.7] - 2024-01-05 diff --git a/debian/conffiles b/debian/conffiles new file mode 100644 index 0000000..97d6788 --- /dev/null +++ b/debian/conffiles @@ -0,0 +1 @@ +/etc/default/ntpmon diff --git a/src/tailer.py b/src/tailer.py index 2e88ab0..f02607a 100755 --- a/src/tailer.py +++ b/src/tailer.py @@ -39,6 +39,7 @@ def open(self) -> None: stat = os.stat(self.file.fileno()) self.st_ino = stat.st_ino self.st_dev = stat.st_dev + print(f"{self.filename} opened, reading from pos {self.pos}", file=sys.stderr) except OSError: self.clear() finally: @@ -54,7 +55,7 @@ def readlines(self) -> List[str]: return None elif pos < self.pos: # file has been truncated; reset to beginning and read all lines - print(f"Truncated: {pos=} {self.pos=}", file=sys.stderr) + print(f"{self.filename} truncated, resetting to beginning", file=sys.stderr) self.file.seek(0, os.SEEK_SET) else: # Even if we were in the right place already, we need to set our @@ -85,12 +86,12 @@ def tail(self) -> List[str]: reopen = False if stat is None: # file deleted - read the rest of it (if any) and reopen when available - print("Deleted file", file=sys.stderr) + print(f"{self.filename} deleted, reopening", file=sys.stderr) reopen = True elif stat.st_ino != self.st_ino or stat.st_dev != self.st_dev: # It's a different file; read the rest of the open one, then open the # new one. - print(f"Different file: {stat.st_ino=} {self.st_ino=} {stat.st_dev=} {self.st_dev=}", file=sys.stderr) + print(f"{self.filename} replaced ({self.st_dev},{self.st_ino} -> {stat.st_dev},{stat.st_ino}), reopening", file=sys.stderr) reopen = True else: # Same file, just read any lines