Skip to content

Commit d81fd25

Browse files
AlexandrAlexandr
authored andcommitted
feat: add columns support for PostgreSQL 18
1 parent 634ae07 commit d81fd25

File tree

5 files changed

+286
-11
lines changed

5 files changed

+286
-11
lines changed

documentation/metrics.md

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,69 @@ Default config:
23742374

23752375
*Buffers Written During Checkpoints* maps `buffers_written`.
23762376

2377+
- **Done Checkpoints**
2378+
2379+
Zabbix item:
2380+
<table>
2381+
<tr>
2382+
<th>Name</th>
2383+
<td>PostgreSQL Checkpoints: Done (in hour)</td>
2384+
</tr>
2385+
<tr>
2386+
<th>Key</th>
2387+
<td>pgsql.checkpoint[count_done]</td>
2388+
</tr>
2389+
<tr>
2390+
<th>Type</th>
2391+
<td>Numeric (float)</td>
2392+
</tr>
2393+
<tr>
2394+
<th>Units</th>
2395+
<td></td>
2396+
</tr>
2397+
<tr>
2398+
<th>Delta</th>
2399+
<td>Speed Per Second</td>
2400+
</tr>
2401+
<tr>
2402+
<th>Supported Version</th>
2403+
<td>18+</td>
2404+
</tr>
2405+
</table>
2406+
2407+
*Done Checkpoints* maps `num_done`.
2408+
2409+
- **SLRU Written**
2410+
2411+
Zabbix item:
2412+
<table>
2413+
<tr>
2414+
<th>Name</th>
2415+
<td>PostgreSQL Checkpoints: SLRU Written (in hour)</td>
2416+
</tr>
2417+
<tr>
2418+
<th>Key</th>
2419+
<td>pgsql.checkpoint[slru_written]</td>
2420+
</tr>
2421+
<tr>
2422+
<th>Type</th>
2423+
<td>Numeric (float)</td>
2424+
</tr>
2425+
<tr>
2426+
<th>Units</th>
2427+
<td></td>
2428+
</tr>
2429+
<tr>
2430+
<th>Delta</th>
2431+
<td>Speed Per Second</td>
2432+
</tr>
2433+
<tr>
2434+
<th>Supported Version</th>
2435+
<td>18+</td>
2436+
</tr>
2437+
</table>
2438+
2439+
*SLRU Written* maps `slru_written`.
23772440

23782441
### Graphs
23792442

@@ -2920,6 +2983,70 @@ Default config:
29202983

29212984
*Checksum Failures* maps `checksum_failures`.
29222985

2986+
- **Parallel Workers To Launch**
2987+
2988+
Zabbix item:
2989+
<table>
2990+
<tr>
2991+
<th>Name</th>
2992+
<td>PostgreSQL Instance: Parallel Workers To Launch</td>
2993+
</tr>
2994+
<tr>
2995+
<th>Key</th>
2996+
<td>pgsql.instance_parallel[to_launch]</td>
2997+
</tr>
2998+
<tr>
2999+
<th>Type</th>
3000+
<td>Numeric (float)</td>
3001+
</tr>
3002+
<tr>
3003+
<th>Units</th>
3004+
<td></td>
3005+
</tr>
3006+
<tr>
3007+
<th>Delta</th>
3008+
<td>Simple Change</td>
3009+
</tr>
3010+
<tr>
3011+
<th>Supported Version</th>
3012+
<td>18+</td>
3013+
</tr>
3014+
</table>
3015+
3016+
*Parallel Workers To Launch* maps `parallel_workers_to_launch`.
3017+
3018+
- **Parallel Workers Launched**
3019+
3020+
Zabbix item:
3021+
<table>
3022+
<tr>
3023+
<th>Name</th>
3024+
<td>PostgreSQL Instance: Parallel Workers Launched</td>
3025+
</tr>
3026+
<tr>
3027+
<th>Key</th>
3028+
<td>pgsql.instance_parallel[launched]</td>
3029+
</tr>
3030+
<tr>
3031+
<th>Type</th>
3032+
<td>Numeric (float)</td>
3033+
</tr>
3034+
<tr>
3035+
<th>Units</th>
3036+
<td></td>
3037+
</tr>
3038+
<tr>
3039+
<th>Delta</th>
3040+
<td>Simple Change</td>
3041+
</tr>
3042+
<tr>
3043+
<th>Supported Version</th>
3044+
<td>18+</td>
3045+
</tr>
3046+
</table>
3047+
3048+
*Parallel Workers Launched* maps `parallel_workers_launched`.
3049+
29233050
### Graphs
29243051
<table>
29253052
<tr>
@@ -4001,6 +4128,37 @@ Default config:
40014128

40024129
*Amount of WAL Records* maps `wal_records`.
40034130

4131+
- **WAL Buffers Full**
4132+
4133+
Zabbix item:
4134+
<table>
4135+
<tr>
4136+
<th>Name</th>
4137+
<td>PostgreSQL Statements: WAL Buffers Full</td>
4138+
</tr>
4139+
<tr>
4140+
<th>Key</th>
4141+
<td>pgsql.stat[wal_buffers_full]</td>
4142+
</tr>
4143+
<tr>
4144+
<th>Type</th>
4145+
<td>Numeric (float)</td>
4146+
</tr>
4147+
<tr>
4148+
<th>Units</th>
4149+
<td></td>
4150+
</tr>
4151+
<tr>
4152+
<th>Delta</th>
4153+
<td>Simple Change</td>
4154+
</tr>
4155+
<tr>
4156+
<th>Supported Version</th>
4157+
<td>18+</td>
4158+
</tr>
4159+
</table>
4160+
4161+
*WAL Buffers Full* maps `wal_buffers_full`.
40044162

40054163
- **Dirty Bytes**
40064164

@@ -4298,6 +4456,70 @@ Default config:
42984456

42994457
*pg_stat_statements.max Exceeding Count* maps `dealloc`.
43004458

4459+
- **Parallel Workers To Launch**
4460+
4461+
Zabbix item:
4462+
<table>
4463+
<tr>
4464+
<th>Name</th>
4465+
<td>PostgreSQL Statements: Parallel Workers To Launch</td>
4466+
</tr>
4467+
<tr>
4468+
<th>Key</th>
4469+
<td>pgsql.statements_parallel[to_launch]</td>
4470+
</tr>
4471+
<tr>
4472+
<th>Type</th>
4473+
<td>Numeric (float)</td>
4474+
</tr>
4475+
<tr>
4476+
<th>Units</th>
4477+
<td></td>
4478+
</tr>
4479+
<tr>
4480+
<th>Delta</th>
4481+
<td>Simple Change</td>
4482+
</tr>
4483+
<tr>
4484+
<th>Supported Version</th>
4485+
<td>18+</td>
4486+
</tr>
4487+
</table>
4488+
4489+
*Parallel Workers To Launch* maps `parallel_workers_to_launch`.
4490+
4491+
- **Parallel Workers Launched**
4492+
4493+
Zabbix item:
4494+
<table>
4495+
<tr>
4496+
<th>Name</th>
4497+
<td>PostgreSQL Statements: Parallel Workers Launched</td>
4498+
</tr>
4499+
<tr>
4500+
<th>Key</th>
4501+
<td>pgsql.statements_parallel[launched]</td>
4502+
</tr>
4503+
<tr>
4504+
<th>Type</th>
4505+
<td>Numeric (float)</td>
4506+
</tr>
4507+
<tr>
4508+
<th>Units</th>
4509+
<td></td>
4510+
</tr>
4511+
<tr>
4512+
<th>Delta</th>
4513+
<td>Simple Change</td>
4514+
</tr>
4515+
<tr>
4516+
<th>Supported Version</th>
4517+
<td>18+</td>
4518+
</tr>
4519+
</table>
4520+
4521+
*Parallel Workers Launched* maps `parallel_workers_launched`.
4522+
43014523
### Graphs
43024524

43034525
<table>

github-actions-tests/metrics.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ for metric in $(cat ${METRICS_FILE}); do
6464
GREP=$( mamonsu agent metric-get ${metric} | grep "pgsql\|sys\|mamonsu" )
6565
if [ -z "$GREP" ]; then
6666
echo "---> ERROR: Cannot found metric $metric"
67+
mamonsu agent metric-list
6768
exit 11
6869
fi
6970
done

mamonsu/plugins/pgsql/checkpoint.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ def __init__(self, config):
7676
("PostgreSQL Checkpoints: Count (in hour)", "FF5656", 0),
7777
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
7878

79+
("num_done", "count_done",
80+
"Done (in hour)",
81+
("PostgreSQL Checkpoints: Done (in hour)", "00CC00", 0),
82+
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
83+
84+
("slru_written", "slru_written",
85+
"SLRU Written (in hour)",
86+
("PostgreSQL Checkpoints: SLRU Written (in hour)", "00CC00", 0),
87+
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
88+
7989
("write_time", "write_time",
8090
"Write Time",
8191
("PostgreSQL Checkpoints: Write/Sync", "00CC00", 1),
@@ -175,11 +185,12 @@ def triggers(self, template, dashboard=False):
175185
def keys_and_queries(self, template_zabbix):
176186
result = []
177187
for num, item in enumerate(self.Items):
178-
if num > 1:
188+
if num > 3:
179189
result.append(
180190
"{0}[*],$2 $1 -c \"{1}\"".format(self.key.format("." + item[1]), self.query.format(item[0])))
181191
else:
182192
result.append(
183193
"{0}[*],$2 $1 -c \"{1}\"".format(self.key.format("." + item[1]),
184194
self.query_interval.format(item[0])))
185195
return template_zabbix.key_and_query(result)
196+

mamonsu/plugins/pgsql/instance.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ class Instance(Plugin):
6868
("PostgreSQL Instance: Events", "006AAE", 0),
6969
Plugin.UNITS.none, Plugin.DELTA.simple_change)
7070
]
71+
Items_pg_18 = [
72+
# key, zbx_key, description,
73+
# ('graph name', color, side), units, delta
74+
("parallel_workers_to_launch", "instance_parallel[to_launch]", "",
75+
("PostgreSQL Instance: Parallel Workers To Launch", "00CC00", 0),
76+
Plugin.UNITS.none, Plugin.DELTA.simple_change),
77+
78+
("parallel_workers_launched", "instance_parallel[launched]", "",
79+
("PostgreSQL Instance: Parallel Workers Launched", "00CC00", 0),
80+
Plugin.UNITS.none, Plugin.DELTA.simple_change)
81+
]
7182

7283
key_server_mode = "pgsql.server_mode{0}"
7384
query_server_mode = """
@@ -86,8 +97,9 @@ class Instance(Plugin):
8697
def run(self, zbx):
8798
all_items = self.Items
8899
if Pooler.server_version_greater("12.0"):
89-
all_items = self.Items + self.Items_pg_12
90-
100+
all_items += self.Items_pg_12
101+
if Pooler.server_version_greater("18.0"):
102+
all_items += self.Items_pg_18
91103
columns = ["sum(COALESCE({0}, 0)) as {0}".format(x[0]) for x in all_items]
92104
result = Pooler.query("""
93105
SELECT {0}
@@ -102,7 +114,7 @@ def run(self, zbx):
102114

103115
def items(self, template, dashboard=False):
104116
result = ""
105-
for num, item in enumerate(self.Items + self.Items_pg_12):
117+
for num, item in enumerate(self.Items + self.Items_pg_12 + self.Items_pg_18):
106118
if self.Type == "mamonsu":
107119
delta = Plugin.DELTA.as_is
108120
else:
@@ -154,7 +166,7 @@ def graphs(self, template, dashboard=False):
154166
result = ""
155167
for name in self.graphs_name.values():
156168
items = []
157-
for num, item in enumerate(self.Items + self.Items_pg_12):
169+
for num, item in enumerate(self.Items + self.Items_pg_12 + self.Items_pg_18):
158170
if item[3][0] == name:
159171
# split each item to get values for keys of both agent type and mamonsu type
160172
keys = item[1].split("[")
@@ -201,10 +213,11 @@ def triggers(self, template, dashboard=False):
201213

202214
def keys_and_queries(self, template_zabbix):
203215
result = []
204-
if Pooler.server_version_less("11"):
205-
all_items = self.Items
206-
else:
207-
all_items = self.Items + self.Items_pg_12
216+
all_items = self.Items
217+
if Pooler.server_version_greater("12.0"):
218+
all_items += self.Items_pg_12
219+
if Pooler.server_version_greater("18.0"):
220+
all_items += self.Items_pg_18
208221
for item in all_items:
209222
# split each item to get values for keys of both agent type and mamonsu type
210223
keys = item[1].split("[")

0 commit comments

Comments
 (0)