diff --git a/agents/plugins/mk_postgres.py b/agents/plugins/mk_postgres.py index ae174167774..88186e83845 100755 --- a/agents/plugins/mk_postgres.py +++ b/agents/plugins/mk_postgres.py @@ -125,7 +125,8 @@ def __init__(self, db_user, instance, process_match_patterns): self.pg_passfile = instance.get("pg_passfile", "") self.pg_version = instance.get("pg_version") self.my_env = os.environ.copy() - self.my_env["PGPASSFILE"] = instance.get("pg_passfile", "") + if instance.get("pg_passfile", ""): + self.my_env["PGPASSFILE"] = instance.get("pg_passfile", "") self.sep = os.sep self.psql_binary_name = "psql" self.psql_binary_path = self.get_psql_binary_path() @@ -720,13 +721,16 @@ def get_bloat(self, databases, numeric_version): query = "\\pset footer off \\\\" cur_rows_only = False + output = "" for idx, database in enumerate(databases): query = "%s \\c %s \\\\ %s" % (query, database, bloat_query) if idx == 0: query = "%s \\pset tuples_only on" % query - - return self.run_sql_as_db_user(query, mixed_cmd=True, rows_only=cur_rows_only) + output += self.run_sql_as_db_user(query, mixed_cmd=True, rows_only=cur_rows_only) + cur_rows_only = True + query = "\\pset footer off \\\\" + return output class PostgresLinux(PostgresBase):