diff --git a/README.md b/README.md
index df7611c..a4f3076 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,8 @@ Supported platforms:
- Windows;
Supported Zabbix server versions: 4.0.44 - 6.4.13
-Supported PostgreSQL versions: 12 - 16
+
+Supported PostgreSQL versions: 12 - 17
***
***Table of Contents***
diff --git a/documentation/metrics.md b/documentation/metrics.md
index a157eab..15ef4a1 100644
--- a/documentation/metrics.md
+++ b/documentation/metrics.md
@@ -1997,7 +1997,7 @@ Default config:
Supported Version |
- 9.5+ |
+ 9.5 - 16 |
@@ -2030,7 +2030,7 @@ Default config:
Supported Version |
- 9.5+ |
+ 9.5 - 16 |
@@ -2096,7 +2096,7 @@ Default config:
Supported Version |
- 9.5+ |
+ 9.5 - 16 |
@@ -2208,7 +2208,7 @@ Default config:
### Items
-*Checkpoints metrics* use information from `pg_stat_bgwriter`.
+*Checkpoints metrics* use information from `pg_stat_bgwriter`. Starting from Postgres 17 this information is pulled from view `pg_stat_checkpointer`.
- **Checkpoints Sync Time**
@@ -2341,6 +2341,40 @@ Default config:
*Requested Checkpoints* maps `checkpoints_req`.
+
+- **Buffers Written During Checkpoints**
+
+ Zabbix item:
+
+
+ Name |
+ PostgreSQL bgwriter: Buffers Written During Checkpoints |
+
+
+ Key |
+ pgsql.checkpoint[buffers_written] |
+
+
+ Type |
+ Numeric (float) |
+
+
+ Units |
+ |
+
+
+ Delta |
+ Simple Change |
+
+
+ Supported Version |
+ 17+ |
+
+
+
+ *Buffers Written During Checkpoints* maps `buffers_written`.
+
+
### Graphs
diff --git a/mamonsu/plugins/pgsql/bgwriter.py b/mamonsu/plugins/pgsql/bgwriter.py
index 6d95013..2ca2d70 100644
--- a/mamonsu/plugins/pgsql/bgwriter.py
+++ b/mamonsu/plugins/pgsql/bgwriter.py
@@ -12,44 +12,68 @@ class BgWriter(Plugin):
SELECT {0}
FROM pg_catalog.pg_stat_bgwriter;
"""
- Items = [
- # key, zbx_key, description,
- # ('graph name', color, side), units, delta
-
- ("buffers_checkpoint", "bgwriter[buffers_checkpoint]",
- "Buffers Written During Checkpoints",
- ("PostgreSQL bgwriter", "006AAE", 1),
- Plugin.DELTA.simple_change),
-
- ("buffers_clean", "bgwriter[buffers_clean]",
- "Buffers Written",
- ("PostgreSQL bgwriter", "00CC00", 1),
- Plugin.DELTA.simple_change),
-
- ("maxwritten_clean", "bgwriter[maxwritten_clean]",
- "Number of bgwriter Stopped by Max Write Count",
- ("PostgreSQL bgwriter", "FF5656", 0),
- Plugin.DELTA.simple_change),
-
- ("buffers_backend", "bgwriter[buffers_backend]",
- "Buffers Written Directly by a Backend",
- ("PostgreSQL bgwriter", "9C8A4E", 1),
- Plugin.DELTA.simple_change),
-
- ("buffers_backend_fsync", "bgwriter[buffers_backend_fsync]",
- "Times a Backend Execute Its Own Fsync",
- ("PostgreSQL bgwriter", "00CC00", 0),
- Plugin.DELTA.simple_change),
-
- ("buffers_alloc", "bgwriter[buffers_alloc]",
- "Buffers Allocated",
- ("PostgreSQL bgwriter", "FF5656", 1),
- Plugin.DELTA.simple_change)
- ]
graph_name_buffers = "PostgreSQL bgwriter: Buffers"
graph_name_ws = "PostgreSQL bgwriter: Write/Sync"
+ def __init__(self, config):
+ super(BgWriter, self).__init__(config)
+ if Pooler.server_version_less("17"):
+ self.Items = [
+ # key, zbx_key, description,
+ # ('graph name', color, side), units, delta
+
+ ("buffers_checkpoint", "bgwriter[buffers_checkpoint]",
+ "Buffers Written During Checkpoints",
+ ("PostgreSQL bgwriter", "006AAE", 1),
+ Plugin.DELTA.simple_change),
+
+ ("buffers_clean", "bgwriter[buffers_clean]",
+ "Buffers Written",
+ ("PostgreSQL bgwriter", "00CC00", 1),
+ Plugin.DELTA.simple_change),
+
+ ("maxwritten_clean", "bgwriter[maxwritten_clean]",
+ "Number of bgwriter Stopped by Max Write Count",
+ ("PostgreSQL bgwriter", "FF5656", 0),
+ Plugin.DELTA.simple_change),
+
+ ("buffers_backend", "bgwriter[buffers_backend]",
+ "Buffers Written Directly by a Backend",
+ ("PostgreSQL bgwriter", "9C8A4E", 1),
+ Plugin.DELTA.simple_change),
+
+ ("buffers_backend_fsync", "bgwriter[buffers_backend_fsync]",
+ "Times a Backend Execute Its Own Fsync",
+ ("PostgreSQL bgwriter", "00CC00", 0),
+ Plugin.DELTA.simple_change),
+
+ ("buffers_alloc", "bgwriter[buffers_alloc]",
+ "Buffers Allocated",
+ ("PostgreSQL bgwriter", "FF5656", 1),
+ Plugin.DELTA.simple_change)
+ ]
+ else:
+ self.Items = [
+ # key, zbx_key, description,
+ # ('graph name', color, side), units, delta
+
+ ("buffers_clean", "bgwriter[buffers_clean]",
+ "Buffers Written",
+ ("PostgreSQL bgwriter", "00CC00", 1),
+ Plugin.DELTA.simple_change),
+
+ ("maxwritten_clean", "bgwriter[maxwritten_clean]",
+ "Number of bgwriter Stopped by Max Write Count",
+ ("PostgreSQL bgwriter", "FF5656", 0),
+ Plugin.DELTA.simple_change),
+
+ ("buffers_alloc", "bgwriter[buffers_alloc]",
+ "Buffers Allocated",
+ ("PostgreSQL bgwriter", "FF5656", 1),
+ Plugin.DELTA.simple_change)
+ ]
+
def run(self, zbx):
columns = [x[0] for x in self.Items]
result = Pooler.query(self.query.format(", ".join(columns)))
diff --git a/mamonsu/plugins/pgsql/checkpoint.py b/mamonsu/plugins/pgsql/checkpoint.py
index f4a5324..80eff40 100644
--- a/mamonsu/plugins/pgsql/checkpoint.py
+++ b/mamonsu/plugins/pgsql/checkpoint.py
@@ -9,14 +9,6 @@ class Checkpoint(Plugin):
AgentPluginType = "pg"
Interval = 60 * 5
- query = """
- SELECT {0}
- FROM pg_catalog.pg_stat_bgwriter;
- """ # for mamonsu and agent
- query_interval = """
- SELECT {0}*3600
- FROM pg_catalog.pg_stat_bgwriter;
- """ # for mamonsu and agent checkpoints in hour
key = "pgsql.checkpoint{0}"
# key: (macro, value)
@@ -24,34 +16,76 @@ class Checkpoint(Plugin):
"max_checkpoint_by_wal_in_hour": [("macro", "{$MAX_CHECKPOINT_BY_WAL_IN_HOUR}"), ("value", 12)]
}
- Items = [
- # key, zbx_key, description,
- # ('graph name', color, side), units, delta, factor
-
- ("checkpoints_timed", "count_timed",
- "by Timeout (in hour)",
- ("PostgreSQL Checkpoints: Count (in hour)", "00CC00", 0),
- Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
-
- ("checkpoints_req", "count_wal",
- "by WAL (in hour)",
- ("PostgreSQL Checkpoints: Count (in hour)", "FF5656", 0),
- Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
-
- ("checkpoint_write_time", "write_time",
- "Write Time",
- ("PostgreSQL Checkpoints: Write/Sync", "00CC00", 1),
- Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1),
-
- ("checkpoint_sync_time", "checkpoint_sync_time",
- "Sync Time",
- ("PostgreSQL Checkpoints: Write/Sync", "FF5656", 1),
- Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1)
- ]
-
graph_name_count = "PostgreSQL Checkpoints: Count (in hour)"
graph_name_ws = "PostgreSQL Checkpoints: Write/Sync"
+ def __init__(self, config):
+ super(Checkpoint, self).__init__(config)
+ if Pooler.server_version_less("17"):
+ self.query = """
+ SELECT {0}
+ FROM pg_catalog.pg_stat_bgwriter;
+ """ # for mamonsu and agent
+ self.query_interval = """
+ SELECT {0}*3600
+ FROM pg_catalog.pg_stat_bgwriter;
+ """ # for mamonsu and agent checkpoints in hour
+ self.Items = [
+ # key, zbx_key, description,
+ # ('graph name', color, side), units, delta, factor
+ ("checkpoints_timed", "count_timed",
+ "by Timeout (in hour)",
+ ("PostgreSQL Checkpoints: Count (in hour)", "00CC00", 0),
+ Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
+
+ ("checkpoints_req", "count_wal",
+ "by WAL (in hour)",
+ ("PostgreSQL Checkpoints: Count (in hour)", "FF5656", 0),
+ Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
+
+ ("checkpoint_write_time", "write_time",
+ "Write Time",
+ ("PostgreSQL Checkpoints: Write/Sync", "00CC00", 1),
+ Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1),
+
+ ("checkpoint_sync_time", "checkpoint_sync_time",
+ "Sync Time",
+ ("PostgreSQL Checkpoints: Write/Sync", "FF5656", 1),
+ Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1)
+ ]
+ else:
+ self.query = """
+ SELECT {0}
+ FROM pg_catalog.pg_stat_checkpointer;
+ """ # for mamonsu and agent
+ self.query_interval = """
+ SELECT {0}*3600
+ FROM pg_catalog.pg_stat_checkpointer;
+ """ # for mamonsu and agent checkpoints in hour
+ self.Items = [
+ # key, zbx_key, description,
+ # ('graph name', color, side), units, delta, factor
+ ("num_timed", "count_timed",
+ "by Timeout (in hour)",
+ ("PostgreSQL Checkpoints: Count (in hour)", "00CC00", 0),
+ Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
+
+ ("num_requested", "count_wal",
+ "by WAL (in hour)",
+ ("PostgreSQL Checkpoints: Count (in hour)", "FF5656", 0),
+ Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
+
+ ("write_time", "write_time",
+ "Write Time",
+ ("PostgreSQL Checkpoints: Write/Sync", "00CC00", 1),
+ Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1),
+
+ ("sync_time", "checkpoint_sync_time",
+ "Sync Time",
+ ("PostgreSQL Checkpoints: Write/Sync", "FF5656", 1),
+ Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1)
+ ]
+
def run(self, zbx):
columns = [x[0] for x in self.Items]
result = Pooler.query(self.query.format(", ".join(columns)))
@@ -146,5 +180,5 @@ def keys_and_queries(self, template_zabbix):
else:
result.append(
"{0}[*],$2 $1 -c \"{1}\"".format(self.key.format("." + item[1]),
- self.query_interval.format(item[0])))
+ self.query_interval.format(item[0])))
return template_zabbix.key_and_query(result)