Bug 852049

Summary: Add new Postgres Plug-in
Product: Red Hat Enterprise Linux 6 Reporter: Keith Robertson <kroberts>
Component: sosAssignee: Keith Robertson <kroberts>
Status: CLOSED ERRATA QA Contact: David Kutálek <dkutalek>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.4CC: agk, azelinka, bmr, ddumas, gavin, jmoran, mitsuhiro.tanino.gm, syeghiay
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: sos-2.2-35.el6 Doc Type: Bug Fix
Doc Text:
Cause: PostgreSQL is a popular open-source databased included in Red Hat Enterprise Linux. Prior versions of sos did not include support for collecting information about installed postrgres instances. Consequence: No diagnostic information was collected for this component. Fix: A new module psql has been included in this release that obtains information from the database. Result: Diagnostic data is now captured on appropriately configured systems when the module is enabled.
Story Points: ---
Clone Of:
: 913759 (view as bug list) Environment:
Last Closed: 2013-02-21 10:58:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 784640, 862738, 913759    
Attachments:
Description Flags
Updated plugin with some enhancements for unicode.
none
Patched plug-in
none
Set option in options list to '/var/lib/pgsql' none

Description Keith Robertson 2012-08-27 12:44:21 UTC
Description of problem:
New plug-in for Postgres SQL server. 
- Justification: Necessary plug-in for applications like RHEV though it is not specific to RHEV and could be used in the generic case to dump a local or remote PG DB.
- Features:
-- Dump local PG DB.
-- Dump remote PG DB
-- Scoop up necessary log files and conf files from $PG_HOME

Version-Release number of selected component (if applicable):
All

How reproducible:
N/A

Steps to Reproduce:
N/a
  
Actual results:
N/A

Expected results:
Collect log and conf files from $PG_HOME.  Optionally, dump a specified DB.

Additional info:
N/A

Comment 2 Keith Robertson 2012-08-27 14:27:53 UTC
Patch pushed to private-kroberts-BZ852049 branch.

Comment 6 Bryn M. Reeves 2012-10-18 17:23:21 UTC
Made a couple of changes after noticing a postproc exception when testing with --debug:

  Running plugins. Please wait ...

  Completed [54/54] ...
Traceback (most recent call last):
  File "/usr/sbin/sosreport", line 23, in <module>
    sosreport(sys.argv[1:])
  File "/usr/lib/python2.6/site-packages/sos/sosreport.py", line 824, in sosreport
    plug.postproc()
AttributeError: psql instance has no attribute 'tmp_dir'



diff -up sos-2.2/sos/plugins/psql.py.orig sos-2.2/sos/plugins/psql.py
--- sos-2.2/sos/plugins/psql.py.orig    2012-10-18 18:12:13.102139939 +0100
+++ sos-2.2/sos/plugins/psql.py 2012-10-18 18:22:09.555465593 +0100
@@ -30,6 +30,10 @@ class psql(sos.plugintools.PluginBase):
     __username = 'postgres'
     __dbport = 5432
 
+    packages = [ 'postgresql' ]
+
+    tmp_dir = None
+
     optionList = [
         ("pghome",  'PostgreSQL server home directory (default=/var/lib/pgsql)', '', False),
         ("username",  'username for pg_dump (default=postgres)', '', False),
@@ -91,6 +95,8 @@ class psql(sos.plugintools.PluginBase):
 
     def postproc(self):
         import shutil
+        if self.tmp_dir == None:
+            return
         try:
             shutil.rmtree(self.tmp_dir)
         except:

Comment 12 Keith Robertson 2012-11-13 18:08:12 UTC
Created attachment 644291 [details]
Updated plugin with some enhancements for unicode.

Comment 18 Keith Robertson 2012-11-15 14:40:08 UTC
Created attachment 645679 [details]
Patched plug-in

Comment 23 Keith Robertson 2012-12-07 21:11:17 UTC
Created attachment 659595 [details]
Set option in options list to  '/var/lib/pgsql'

Comment 24 Bryn M. Reeves 2012-12-21 09:28:33 UTC
*** Bug 887690 has been marked as a duplicate of this bug. ***

Comment 27 Bryn M. Reeves 2013-01-09 13:14:56 UTC
I've ported over Keith's suggestions (minus the unicode changes) but I'm now hitting the problem David mentioned in comment #19 (this is the first time I've seen it). Something in the psql module appears to be breaking the tarball.

Comment 28 Bryn M. Reeves 2013-01-09 13:43:16 UTC
OK, the weird tarball problem is not directly related to the postgres module; it happens whenever there are no modules collecting data (which was happening on my test box with -o psql).

This is still a problem but will not affect any real uses (since it only affects a case where no useful data is collected anyway).

I've filed bug 893570 to deal with this in 6.5.

Comment 32 errata-xmlrpc 2013-02-21 10:58:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0474.html