Fix cluster module crm_report support

The cluster plugin used an obsolete sos-2.2 method to determine
the command output directory. This causes an excaption at runtime
since the referenced properties no longer exist.

The crm_report script also expects a --from date and will not
collect data unless this is passed. Default to passing a value 72
hours before the current time and add a 'crm_from' option to the
cluster module to allow the user to override this.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Remove obsolete diagnostics code from ldap plugin

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Ensure superclass postproc method is called in ldap plugin

Since the ldap plugins add files and post-processing methods at
multiple class levels (Ldap, RedHatLdap etc.) derived classes
must explicitly call their parent class's postproc() method to
apply all substitutions to collected data.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Fix cluster postproc regression

Commit 4ab4b08 inadvertently removed the postprocessing rules for
luci configuration. Revert that part of the commit.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Fix get_option() use in cluster plugin

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Fix verbose file logging

Prior versions of sos enable debug logging to the embedded log
file (sos_logs/sos.log) when a single '-v' is given. Restore this
behaviour and ensure that command-not-found messages are reported
at 'info' rather than 'warning' level.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Always treat rhevm vdsmlogs option as string

The rhevm plugin has a 'vdsmlogs' option to pass in a set of log
files to be collected. When run with '-a' (or with
'-krhevm.vdsmlogs) this evaluates to 'True' (a bool) and causes
an exception when this is passed to add_copy_specs().

Always treat the value as a string.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Add rhsm-debug collection to yum plugin

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Make get_cmd_output_now() behaviour match 2.2

The equivalent method in sos-2.2, collectOutputNow() returned an
absolute path to the collected file. Since the archive changes in
3.0 this now returns a path relative to the root of the archive.

This breaks existing users of the interface that try to open and
process the content of the collected file (e.g. gluster).

Return a join of the archive path and file path to the caller.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Include geo-replication status in gluster plugin

Add the output of 'gluster volume geo-replication status' for
each discovered gluster volume to the report.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
postgresql: minor fixes

- pep8 / style fixes
- Avoid redefining built-in 'file'

Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
postgresql: add logs about errors / warnings

give more info to support about what happened while
collecting the report.

Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
postgresql: added license and copyright

Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
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>
Pass --no-archive to rhsm-debug script

Versions of subscription-manager since 1.10.11-2.el7 support the
--no-archive option to disable creation of a zip archive. Pass
this to the script to have the output stored in a directory in
the archive.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Ensure unused fds are closed when calling subprocesses via Popen

When sos communicates with a child process using Popen all IO
takes place on stdin/stdout/stderr (or a subset). No other open
file descriptors should be inherited by the child.

Make all calls to Popen set close_fds=True.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Fix gluster volume name extraction

The get_volume_names() function in the gluster plugin tries to
extract volume names from the output of the "gluster volume info"
command using a slice range. The range start should be 12 to
account for the "Volume Name:" label at the start of the line.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Add distupgrade plugin

Add a new plugin to collect data relating to completed or
attempted distribution upgrades. Currently supports the Red Hat
set of tools and files but other distributions can supply their
own filelists or override setup() to perform other distribution
specific actions.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Fix command output substitution exception

If a comand has a substitution registered via do_cmd_output_sub()
but no data was collected (e.g. command not found) the postproc
code will throw an exception as the return value ('replacements')
is never assigned.

Initialise replacements to None before scanning the list of run
commands and return this if no substitutions were made.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Improve error message when cluster.crm_from is invalid

If a user passes a non-date string value as the crm_from parameter
of the cluster plugin an error message is logged:

  crm_from parameter 'True' is not a valid date

The plugin continues to run and uses the default value (T-72hrs)
as the value of crm_from. Make this clear in the message displayed
to users:

  crm_from parameter 'True' is not a valid date: using default

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>