@@ -64,7 +64,10 @@ def run(self, zbx):
64
64
zbx .send ('pgsql.database.discovery[]' , zbx .json ({'data' : dbs }))
65
65
del dbs , bloat_count , invalid_indexes_count
66
66
67
- result = Pooler .run_sql_type ('count_autovacuum' )
67
+ if Pooler .server_version_greater ('10.0' ):
68
+ result = Pooler .run_sql_type ('count_autovacuum' , args = ["backend_type = 'autovacuum worker'" ])
69
+ else :
70
+ result = Pooler .run_sql_type ('count_autovacuum' , args = ["query LIKE '%%autovacuum%%' AND state <> 'idle' AND pid <> pg_catalog.pg_backend_pid()" ])
68
71
zbx .send ('pgsql.autovacumm.count[]' , int (result [0 ][0 ]))
69
72
70
73
def items (self , template , dashboard = False ):
@@ -152,8 +155,7 @@ def discovery_rules(self, template, dashboard=False):
152
155
return template .discovery_rule (rule = rule , conditions = conditions , items = items , graphs = graphs , triggers = triggers )
153
156
154
157
def keys_and_queries (self , template_zabbix ):
155
- result = ['{0},$2 $1 -c "{1}"' .format (self .key_autovacumm .format ("[*]" ), Pooler .SQL ['count_autovacuum' ][0 ]),
156
- '{0},$2 $1 -c "{1}"' .format (self .key_db_discovery .format ("[*]" ), self .query_agent_discovery ),
158
+ result = ['{0},$2 $1 -c "{1}"' .format (self .key_db_discovery .format ("[*]" ), self .query_agent_discovery ),
157
159
'{0},echo "{1}" | $3 $2 -v p1="$1"' .format (self .key_db_size .format ("[*]" ), self .query_size ),
158
160
'{0},echo "{1}" | $3 $2 -v p1="$1"' .format (self .key_db_age .format ("[*]" ), self .query_age ),
159
161
'{0},$3 $2 -d "$1" -c "{1}"' .format (self .key_db_bloating_tables .format ("[*]" ),
@@ -162,4 +164,8 @@ def keys_and_queries(self, template_zabbix):
162
164
self .plugin_config ('min_rows' ))),
163
165
'{0},$3 $2 -d "$1" -c "{1}"' .format (self .key_invalid_indexes .format ("[*]" ),
164
166
self .query_invalid_indexes )]
167
+ if LooseVersion (self .VersionPG ) >= LooseVersion ('10' ):
168
+ result .append ('{0},$2 $1 -c "{1}"' .format (self .key_autovacumm .format ("[*]" ), Pooler .SQL ['count_autovacuum' ][0 ].format ("backend_type = 'autovacuum worker'" )))
169
+ else :
170
+ result .append ('{0},$2 $1 -c "{1}"' .format (self .key_autovacumm .format ("[*]" ), Pooler .SQL ['count_autovacuum' ][0 ].format ("query LIKE '%%autovacuum%%' AND state <> 'idle' AND pid <> pg_catalog.pg_backend_pid()" )))
165
171
return template_zabbix .key_and_query (result )
0 commit comments