sos/0014-postgresql-allow-use-TCP-socket.patch
Bryn M. Reeves 5261563507 Update sos to 3.1
Update sos to the 3.1 upstream release and add post-release patches
from the development tree.
2014-04-01 12:25:00 +01:00

57 lines
2.1 KiB
Diff

From cfef4d7ee758bffe6242c0d342261300a0e8194c Mon Sep 17 00:00:00 2001
From: Sandro Bonazzola <sbonazzo@redhat.com>
Date: Tue, 4 Feb 2014 15:19:19 +0000
Subject: [PATCH 14/61] postgresql: allow use TCP socket
allow to use TCP socket and not only UNIX socket
for connecting to postgresql database
Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
sos/plugins/postgresql.py | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/sos/plugins/postgresql.py b/sos/plugins/postgresql.py
index df14f86..cc51195 100644
--- a/sos/plugins/postgresql.py
+++ b/sos/plugins/postgresql.py
@@ -38,19 +38,29 @@ class PostgreSQL(Plugin):
('username', 'username for pg_dump', '', 'postgres'),
('password', 'password for pg_dump', '', ''),
('dbname', 'database name to dump for pg_dump', '', ''),
+ ('dbhost', 'database hostname/IP (do not use unix socket)', '', ''),
+ ('dbport', 'database server port number', '', '5432')
]
def pg_dump(self):
dest_file = os.path.join(self.tmp_dir, "sos_pgdump.tar")
old_env_pgpassword = os.environ.get("PGPASSWORD")
os.environ["PGPASSWORD"] = self.get_option("password")
- (status, output, rtime) = self.call_ext_prog(
- "pg_dump %s -U %s -w -f %s -F t" % (
- self.get_option("dbname"),
+ if self.get_option("dbhost"):
+ cmd = "pg_dump -U %s -h %s -p %s -w -f %s -F t %s" % (
self.get_option("username"),
- dest_file
+ self.get_option("dbhost"),
+ self.get_option("dbport"),
+ dest_file,
+ self.get_option("dbname")
)
- )
+ else:
+ cmd = "pg_dump -C -U %s -w -f %s -F t %s " % (
+ self.get_option("username"),
+ dest_file,
+ self.get_option("dbname")
+ )
+ (status, output, rtime) = self.call_ext_prog(cmd)
if old_env_pgpassword is not None:
os.environ["PGPASSWORD"] = str(old_env_pgpassword)
if (status == 0):
--
1.7.11.7