aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2019-08-16 13:13:23 +0100
committerBryn M. Reeves <bmr@redhat.com>2019-08-16 14:17:37 +0100
commitf2e7ac47eb96f59362c0e2c0271642377562d746 (patch)
treeecb0b0225d84a884668b050747739e161b448299
parente758e9708aa8b204289a52f81749242b5524a8e6 (diff)
downloadsos-f2e7ac47eb96f59362c0e2c0271642377562d746.tar.gz
[Plugin] log reason for commands skipped by predicate
Automatically log the reason that a command was skipped by predicate, and optionally include a message indicating that it may alter system configuration and that collection can be enabled by specifying --allow-system-changes. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 9157fafb..533fa3c4 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -941,14 +941,15 @@ class Plugin(object):
self.collect_cmds.append(soscmd)
self._log_info("added cmd output '%s'" % soscmd.cmd)
else:
- self._log_info("skipped cmd output '%s' due to predicate (%s)" %
- (soscmd.cmd,
- self.get_predicate(cmd=True, pred=pred)))
+ self.log_skipped_cmd(pred, soscmd.cmd, kmods=bool(pred.kmods),
+ services=bool(pred.services),
+ changes=soscmd.changes)
def add_cmd_output(self, cmds, suggest_filename=None,
root_symlink=None, timeout=300, stderr=True,
chroot=True, runat=None, env=None, binary=False,
- sizelimit=None, pred=None, subdir=None):
+ sizelimit=None, pred=None, subdir=None,
+ changes=False):
"""Run a program or a list of programs and collect the output"""
if isinstance(cmds, six.string_types):
cmds = [cmds]
@@ -961,7 +962,8 @@ class Plugin(object):
root_symlink=root_symlink, timeout=timeout,
stderr=stderr, chroot=chroot, runat=runat,
env=env, binary=binary, sizelimit=sizelimit,
- pred=pred, subdir=subdir)
+ pred=pred, subdir=subdir,
+ changes=changes)
def get_cmd_output_path(self, name=None, make=True):
"""Return a path into which this module should store collected
@@ -1050,7 +1052,8 @@ class Plugin(object):
def _get_cmd_output_now(self, cmd, suggest_filename=None,
root_symlink=False, timeout=300, stderr=True,
chroot=True, runat=None, env=None,
- binary=False, sizelimit=None, subdir=None):
+ binary=False, sizelimit=None, subdir=None,
+ changes=False):
"""Execute a command and save the output to a file for inclusion in the
report.
"""
@@ -1063,8 +1066,8 @@ class Plugin(object):
chroot=chroot, runat=runat,
env=env, binary=binary,
sizelimit=sizelimit)
- self._log_debug("collected output of '%s' in %s"
- % (cmd.split()[0], time() - start))
+ self._log_debug("collected output of '%s' in %s (changes=%s)"
+ % (cmd.split()[0], time() - start, changes))
if suggest_filename:
outfn = self._make_command_filename(suggest_filename, subdir)