Skip to content

Commit c50d8c6

Browse files
committed
Merge branch 'dev'
2 parents bf4d514 + 973a30f commit c50d8c6

File tree

3 files changed

+142
-119
lines changed

3 files changed

+142
-119
lines changed

documentation/configuration_file.md

+21
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ All parameters must be specified in the `parameter = value` format.
1010

1111
> **_NOTE:_** It is necessary to check permissions to the _mamonsu_ user to directories/files for correct interaction of agent with them. By default configuration file _agent.conf_ should have read/write permissions for _mamonsu_ user only.
1212
13+
> **_NOTE:_** Config file supports string interpolation via _%()s_ syntax in parameter values. please see “[Parameter Values Interpolation](#parameter-values-interpolation)” below.
14+
1315
***
1416

1517
### Connection Parameters
@@ -237,3 +239,22 @@ By default this plugin is disabled. To enable it set the enabled parameter to Tr
237239
This plugin collects two metrics: *pg_probackup.dir.size[#backup_directory]* (the size of the target directory) and *pg_probackup.dir.error[#backup_directory]* (backup errors) for each specified *backup_directory*.
238240

239241
If any generated backup has bad status, like ERROR, CORRUPT, ORPHAN, а trigger is fired.
242+
243+
### Parameter Values Interpolation
244+
245+
Mamonsu uses python3 built-in configparser library which allows defining arbitary variables in any config section and then reuse it within the same config section.
246+
247+
Example:
248+
```editorconfig
249+
[postgres]
250+
pg = postgres
251+
enabled = True
252+
user = %(pg)s
253+
password = %(pg)s
254+
database = %(pg)s
255+
port = 5432
256+
application_name = %(pg)s
257+
query_timeout = 10
258+
```
259+
260+
What is important to note here is that you cannot use symbol _%_ in any parameter's value since it will be treated as an interolation syntax.

mamonsu/plugins/pgsql/bgwriter.py

+56-55
Original file line numberDiff line numberDiff line change
@@ -18,61 +18,62 @@ class BgWriter(Plugin):
1818

1919
def __init__(self, config):
2020
super(BgWriter, self).__init__(config)
21-
if Pooler.server_version_less("17"):
22-
self.Items = [
23-
# key, zbx_key, description,
24-
# ('graph name', color, side), units, delta
25-
26-
("buffers_checkpoint", "bgwriter[buffers_checkpoint]",
27-
"Buffers Written During Checkpoints",
28-
("PostgreSQL bgwriter", "006AAE", 1),
29-
Plugin.DELTA.simple_change),
30-
31-
("buffers_clean", "bgwriter[buffers_clean]",
32-
"Buffers Written",
33-
("PostgreSQL bgwriter", "00CC00", 1),
34-
Plugin.DELTA.simple_change),
35-
36-
("maxwritten_clean", "bgwriter[maxwritten_clean]",
37-
"Number of bgwriter Stopped by Max Write Count",
38-
("PostgreSQL bgwriter", "FF5656", 0),
39-
Plugin.DELTA.simple_change),
40-
41-
("buffers_backend", "bgwriter[buffers_backend]",
42-
"Buffers Written Directly by a Backend",
43-
("PostgreSQL bgwriter", "9C8A4E", 1),
44-
Plugin.DELTA.simple_change),
45-
46-
("buffers_backend_fsync", "bgwriter[buffers_backend_fsync]",
47-
"Times a Backend Execute Its Own Fsync",
48-
("PostgreSQL bgwriter", "00CC00", 0),
49-
Plugin.DELTA.simple_change),
50-
51-
("buffers_alloc", "bgwriter[buffers_alloc]",
52-
"Buffers Allocated",
53-
("PostgreSQL bgwriter", "FF5656", 1),
54-
Plugin.DELTA.simple_change)
55-
]
56-
else:
57-
self.Items = [
58-
# key, zbx_key, description,
59-
# ('graph name', color, side), units, delta
60-
61-
("buffers_clean", "bgwriter[buffers_clean]",
62-
"Buffers Written",
63-
("PostgreSQL bgwriter", "00CC00", 1),
64-
Plugin.DELTA.simple_change),
65-
66-
("maxwritten_clean", "bgwriter[maxwritten_clean]",
67-
"Number of bgwriter Stopped by Max Write Count",
68-
("PostgreSQL bgwriter", "FF5656", 0),
69-
Plugin.DELTA.simple_change),
70-
71-
("buffers_alloc", "bgwriter[buffers_alloc]",
72-
"Buffers Allocated",
73-
("PostgreSQL bgwriter", "FF5656", 1),
74-
Plugin.DELTA.simple_change)
75-
]
21+
if self.is_enabled():
22+
if Pooler.server_version_less("17"):
23+
self.Items = [
24+
# key, zbx_key, description,
25+
# ('graph name', color, side), units, delta
26+
27+
("buffers_checkpoint", "bgwriter[buffers_checkpoint]",
28+
"Buffers Written During Checkpoints",
29+
("PostgreSQL bgwriter", "006AAE", 1),
30+
Plugin.DELTA.simple_change),
31+
32+
("buffers_clean", "bgwriter[buffers_clean]",
33+
"Buffers Written",
34+
("PostgreSQL bgwriter", "00CC00", 1),
35+
Plugin.DELTA.simple_change),
36+
37+
("maxwritten_clean", "bgwriter[maxwritten_clean]",
38+
"Number of bgwriter Stopped by Max Write Count",
39+
("PostgreSQL bgwriter", "FF5656", 0),
40+
Plugin.DELTA.simple_change),
41+
42+
("buffers_backend", "bgwriter[buffers_backend]",
43+
"Buffers Written Directly by a Backend",
44+
("PostgreSQL bgwriter", "9C8A4E", 1),
45+
Plugin.DELTA.simple_change),
46+
47+
("buffers_backend_fsync", "bgwriter[buffers_backend_fsync]",
48+
"Times a Backend Execute Its Own Fsync",
49+
("PostgreSQL bgwriter", "00CC00", 0),
50+
Plugin.DELTA.simple_change),
51+
52+
("buffers_alloc", "bgwriter[buffers_alloc]",
53+
"Buffers Allocated",
54+
("PostgreSQL bgwriter", "FF5656", 1),
55+
Plugin.DELTA.simple_change)
56+
]
57+
else:
58+
self.Items = [
59+
# key, zbx_key, description,
60+
# ('graph name', color, side), units, delta
61+
62+
("buffers_clean", "bgwriter[buffers_clean]",
63+
"Buffers Written",
64+
("PostgreSQL bgwriter", "00CC00", 1),
65+
Plugin.DELTA.simple_change),
66+
67+
("maxwritten_clean", "bgwriter[maxwritten_clean]",
68+
"Number of bgwriter Stopped by Max Write Count",
69+
("PostgreSQL bgwriter", "FF5656", 0),
70+
Plugin.DELTA.simple_change),
71+
72+
("buffers_alloc", "bgwriter[buffers_alloc]",
73+
"Buffers Allocated",
74+
("PostgreSQL bgwriter", "FF5656", 1),
75+
Plugin.DELTA.simple_change)
76+
]
7677

7778
def run(self, zbx):
7879
columns = [x[0] for x in self.Items]

mamonsu/plugins/pgsql/checkpoint.py

+65-64
Original file line numberDiff line numberDiff line change
@@ -21,70 +21,71 @@ class Checkpoint(Plugin):
2121

2222
def __init__(self, config):
2323
super(Checkpoint, self).__init__(config)
24-
if Pooler.server_version_less("17"):
25-
self.query = """
26-
SELECT {0}
27-
FROM pg_catalog.pg_stat_bgwriter;
28-
""" # for mamonsu and agent
29-
self.query_interval = """
30-
SELECT {0}*3600
31-
FROM pg_catalog.pg_stat_bgwriter;
32-
""" # for mamonsu and agent checkpoints in hour
33-
self.Items = [
34-
# key, zbx_key, description,
35-
# ('graph name', color, side), units, delta, factor
36-
("checkpoints_timed", "count_timed",
37-
"by Timeout (in hour)",
38-
("PostgreSQL Checkpoints: Count (in hour)", "00CC00", 0),
39-
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
40-
41-
("checkpoints_req", "count_wal",
42-
"by WAL (in hour)",
43-
("PostgreSQL Checkpoints: Count (in hour)", "FF5656", 0),
44-
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
45-
46-
("checkpoint_write_time", "write_time",
47-
"Write Time",
48-
("PostgreSQL Checkpoints: Write/Sync", "00CC00", 1),
49-
Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1),
50-
51-
("checkpoint_sync_time", "checkpoint_sync_time",
52-
"Sync Time",
53-
("PostgreSQL Checkpoints: Write/Sync", "FF5656", 1),
54-
Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1)
55-
]
56-
else:
57-
self.query = """
58-
SELECT {0}
59-
FROM pg_catalog.pg_stat_checkpointer;
60-
""" # for mamonsu and agent
61-
self.query_interval = """
62-
SELECT {0}*3600
63-
FROM pg_catalog.pg_stat_checkpointer;
64-
""" # for mamonsu and agent checkpoints in hour
65-
self.Items = [
66-
# key, zbx_key, description,
67-
# ('graph name', color, side), units, delta, factor
68-
("num_timed", "count_timed",
69-
"by Timeout (in hour)",
70-
("PostgreSQL Checkpoints: Count (in hour)", "00CC00", 0),
71-
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
72-
73-
("num_requested", "count_wal",
74-
"by WAL (in hour)",
75-
("PostgreSQL Checkpoints: Count (in hour)", "FF5656", 0),
76-
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
77-
78-
("write_time", "write_time",
79-
"Write Time",
80-
("PostgreSQL Checkpoints: Write/Sync", "00CC00", 1),
81-
Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1),
82-
83-
("sync_time", "checkpoint_sync_time",
84-
"Sync Time",
85-
("PostgreSQL Checkpoints: Write/Sync", "FF5656", 1),
86-
Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1)
87-
]
24+
if self.is_enabled():
25+
if Pooler.server_version_less("17"):
26+
self.query = """
27+
SELECT {0}
28+
FROM pg_catalog.pg_stat_bgwriter;
29+
""" # for mamonsu and agent
30+
self.query_interval = """
31+
SELECT {0}*3600
32+
FROM pg_catalog.pg_stat_bgwriter;
33+
""" # for mamonsu and agent checkpoints in hour
34+
self.Items = [
35+
# key, zbx_key, description,
36+
# ('graph name', color, side), units, delta, factor
37+
("checkpoints_timed", "count_timed",
38+
"by Timeout (in hour)",
39+
("PostgreSQL Checkpoints: Count (in hour)", "00CC00", 0),
40+
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
41+
42+
("checkpoints_req", "count_wal",
43+
"by WAL (in hour)",
44+
("PostgreSQL Checkpoints: Count (in hour)", "FF5656", 0),
45+
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
46+
47+
("checkpoint_write_time", "write_time",
48+
"Write Time",
49+
("PostgreSQL Checkpoints: Write/Sync", "00CC00", 1),
50+
Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1),
51+
52+
("checkpoint_sync_time", "checkpoint_sync_time",
53+
"Sync Time",
54+
("PostgreSQL Checkpoints: Write/Sync", "FF5656", 1),
55+
Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1)
56+
]
57+
else:
58+
self.query = """
59+
SELECT {0}
60+
FROM pg_catalog.pg_stat_checkpointer;
61+
""" # for mamonsu and agent
62+
self.query_interval = """
63+
SELECT {0}*3600
64+
FROM pg_catalog.pg_stat_checkpointer;
65+
""" # for mamonsu and agent checkpoints in hour
66+
self.Items = [
67+
# key, zbx_key, description,
68+
# ('graph name', color, side), units, delta, factor
69+
("num_timed", "count_timed",
70+
"by Timeout (in hour)",
71+
("PostgreSQL Checkpoints: Count (in hour)", "00CC00", 0),
72+
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
73+
74+
("num_requested", "count_wal",
75+
"by WAL (in hour)",
76+
("PostgreSQL Checkpoints: Count (in hour)", "FF5656", 0),
77+
Plugin.UNITS.none, Plugin.DELTA.speed_per_second, 60 * 60),
78+
79+
("write_time", "write_time",
80+
"Write Time",
81+
("PostgreSQL Checkpoints: Write/Sync", "00CC00", 1),
82+
Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1),
83+
84+
("sync_time", "checkpoint_sync_time",
85+
"Sync Time",
86+
("PostgreSQL Checkpoints: Write/Sync", "FF5656", 1),
87+
Plugin.UNITS.ms, Plugin.DELTA.speed_per_second, 1)
88+
]
8889

8990
def run(self, zbx):
9091
columns = [x[0] for x in self.Items]

0 commit comments

Comments
 (0)