Skip to content

Commit f895ab3

Browse files
committed
fix: added parallel workers to Connection metrics evaluating
1 parent db108e1 commit f895ab3

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

mamonsu/plugins/pgsql/connections.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ def run(self, zbx):
7474
WHERE {0}
7575
GROUP BY state;
7676
""".format(
77-
"backend_type = 'client backend'" if Pooler.server_version_greater("10.0") else "state IS NOT NULL"))
77+
"(backend_type = 'client backend' OR backend_type = 'parallel worker')" if Pooler.server_version_greater(
78+
"10.0") else "state IS NOT NULL"))
7879

7980
for item in self.Items:
8081
state, key, value = item[0], item[1], 0
@@ -109,8 +110,9 @@ def run(self, zbx):
109110
FROM pg_catalog.pg_stat_activity
110111
WHERE {0}
111112
AND wait_event_type IS NOT NULL;
112-
""".format("backend_type = 'client backend'" if Pooler.server_version_greater(
113-
"10.0") else "state IS NOT NULL"))
113+
""".format(
114+
"(backend_type = 'client backend' OR backend_type = 'parallel worker')" if Pooler.server_version_greater(
115+
"10.0") else "state IS NOT NULL"))
114116
zbx.send("pgsql.connections[waiting]", int(result[0][0]))
115117
if self.Max_connections is None:
116118
result = Pooler.query("""
@@ -197,21 +199,24 @@ def keys_and_queries(self, template_zabbix):
197199
for item in self.Items:
198200
result.append("{0}[*],$2 $1 -c \"{1}\"".format(self.key.format("." + item[1]),
199201
self.query_agent.format(item[1],
200-
"AND backend_type = 'client backend'" if LooseVersion(
202+
"AND (backend_type = 'client backend' OR backend_type = 'parallel worker')" if LooseVersion(
201203
self.VersionPG) >= LooseVersion(
202204
"10") else "")))
203205
result.append("{0}[*],$2 $1 -c \"{1}\"".format(self.key.format(".total"), self.query_agent_total.format(
204-
"backend_type = 'client backend'" if LooseVersion(self.VersionPG) >= LooseVersion(
206+
"(backend_type = 'client backend' OR backend_type = 'parallel worker')" if LooseVersion(
207+
self.VersionPG) >= LooseVersion(
205208
"10") else "state IS NOT NULL")))
206209
if LooseVersion(self.VersionPG) < LooseVersion("9.6"):
207210
result.append(
208211
"{0}[*],$2 $1 -c \"{1}\"".format(self.key.format(".waiting"), self.query_agent_waiting_old_v.format(
209-
"backend_type = 'client backend'" if LooseVersion(self.VersionPG) >= LooseVersion(
212+
"(backend_type = 'client backend' OR backend_type = 'parallel worker')" if LooseVersion(
213+
self.VersionPG) >= LooseVersion(
210214
"10") else "state IS NOT NULL")))
211215
else:
212216
result.append(
213217
"{0}[*],$2 $1 -c \"{1}\"".format(self.key.format(".waiting"), self.query_agent_waiting_new_v.format(
214-
"backend_type = 'client backend'" if LooseVersion(self.VersionPG) >= LooseVersion(
218+
"(backend_type = 'client backend' OR backend_type = 'parallel worker')" if LooseVersion(
219+
self.VersionPG) >= LooseVersion(
215220
"10") else "state IS NOT NULL")))
216221
result.append("{0}[*],$2 $1 -c \"{1}\"".format(self.key.format(".max_connections"), self.query_agent_max_conn))
217222
return template_zabbix.key_and_query(result)

mamonsu/tools/bootstrap/sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
SELECT state,
8787
{5}
8888
FROM pg_catalog.pg_stat_activity
89-
WHERE backend_type = 'client backend'
89+
WHERE (backend_type = 'client backend' OR backend_type = 'parallel worker')
9090
$$ LANGUAGE SQL SECURITY DEFINER;
9191
ELSE
9292
CREATE OR REPLACE FUNCTION mamonsu.get_connections_states()

0 commit comments

Comments
 (0)