Skip to content

Commit 718d958

Browse files
committed
fix: don't cache max_connections value
1 parent 7f87b0a commit 718d958

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

mamonsu/plugins/pgsql/connections.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class Connections(Plugin):
3737
WHERE (backend_type NOT IN ('{0}'));
3838
""".format("', '".join(default_backend_types))
3939

40-
Max_connections = None
41-
4240
query_agent = """
4341
SELECT count(*)
4442
FROM pg_catalog.pg_stat_activity
@@ -125,14 +123,13 @@ def run(self, zbx):
125123
"(backend_type = 'client backend' OR backend_type = 'parallel worker')" if Pooler.server_version_greater(
126124
"10.0") else "state IS NOT NULL"))
127125
zbx.send("pgsql.connections[waiting]", int(result[0][0]))
128-
if self.Max_connections is None:
129-
result = Pooler.query("""
130-
SELECT setting
131-
FROM pg_settings
132-
WHERE name = 'max_connections';
133-
""")
134-
self.Max_connections = result[0][0]
135-
zbx.send("pgsql.connections[max_connections]", int(self.Max_connections))
126+
127+
result = Pooler.query("""
128+
SELECT setting
129+
FROM pg_settings
130+
WHERE name = 'max_connections';
131+
""")
132+
zbx.send("pgsql.connections[max_connections]", int(result[0][0]))
136133

137134
if Pooler.server_version_greater("10.0"):
138135
result = Pooler.query(self.query_other_connections)

0 commit comments

Comments
 (0)