From e1ef9928307636ce3e7b98d7dbebfe4c9574f752 Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Fri, 8 Feb 2019 13:19:56 -0500 Subject: [postgresql] Use postgres 10 scl if installed Updates the plugin to check if the specified SCL is running, as some systems may have multiple SCL versions installed, but only one will be running at a time. We now use the running version for a pgdump. This is primarily aimed at RHV environments as 4.3 and later use version 10. Resolves: #1562 Signed-off-by: Jake Hunsaker Signed-off-by: Bryn M. Reeves --- sos/plugins/postgresql.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sos/plugins/postgresql.py b/sos/plugins/postgresql.py index ebd7863a..78b03fef 100644 --- a/sos/plugins/postgresql.py +++ b/sos/plugins/postgresql.py @@ -78,14 +78,25 @@ class PostgreSQL(Plugin): class RedHatPostgreSQL(PostgreSQL, SCLPlugin): - packages = ('postgresql', 'rh-postgresql95-postgresql-server', ) + packages = ( + 'postgresql', + 'rh-postgresql95-postgresql-server', + 'rh-postgresql10-postgresql-server' + ) def setup(self): super(RedHatPostgreSQL, self).setup() - scl = "rh-postgresql95" pghome = self.get_option("pghome") + scl = None + for pkg in self.packages[1:]: + # The scl name, package name, and service name all differ slightly + # but is at least consistent in doing so across versions, so we + # need to do some mangling here + if self.service_is_running(pkg.replace('-server', '')): + scl = pkg.split('-postgresql-')[0] + # Copy PostgreSQL log files. for filename in find("*.log", pghome): self.add_copy_spec(filename) @@ -109,7 +120,7 @@ class RedHatPostgreSQL(PostgreSQL, SCLPlugin): ) ) - if scl in self.scls_matched: + if scl and scl in self.scls_matched: self.do_pg_dump(scl=scl, filename="pgdump-scl-%s.tar" % scl) -- cgit