aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-03-25 17:28:31 +0000
committerBryn M. Reeves <bmr@redhat.com>2014-03-25 17:28:31 +0000
commit4553f0942c00b47342deea7fc47bb9822484a65e (patch)
tree70dd0280794a4e89feca914617059115b65bd366
parenteb2b77cc38130882db71b73a5a026a454d261684 (diff)
downloadsos-4553f0942c00b47342deea7fc47bb9822484a65e.tar.gz
Remove --profile support
The handrolled profile logging support in sos hasn't been widely used in a long time and is a problem better solved with external profiling and coverage tools. Rip out all the support and documentation. This shortens and simplifies numerous Plugin class methods. Fixes Issue #244. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--man/en/sosreport.15
-rw-r--r--sos/plugins/__init__.py30
-rw-r--r--sos/sosreport.py35
-rw-r--r--tests/plugin_tests.py4
4 files changed, 3 insertions, 71 deletions
diff --git a/man/en/sosreport.1 b/man/en/sosreport.1
index c8005768..e1894335 100644
--- a/man/en/sosreport.1
+++ b/man/en/sosreport.1
@@ -11,7 +11,7 @@ sosreport \- Collect and package diagnostic and support data
[--report] [--config-file conf] [--batch]\fR
[--build] [--name name] [--ticket-number number]
[--debug] [--tmp-dir directory]\fR
- [--profile] [--help]\fR
+ [--help]\fR
.SH DESCRIPTION
\fBsosreport\fR generates a compressed tar archive of diagnostic
information from the running system. The archive may be stored
@@ -84,9 +84,6 @@ archive as a temporary file or directory tree.
Enable interactive debugging using the python debugger. Exceptions in
sos or plug-in code will cause a trap to the pdb shell.
.TP
-.B \--profile
-Enable profiler logging.
-.TP
.B \--help
Display usage message.
.SH MAINTAINER
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index efb69500..cf2a7101 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -137,7 +137,6 @@ class Plugin(object):
self.collect_cmds = []
self.soslog = self.commons['soslog'] if 'soslog' in self.commons else logging.getLogger('sos')
- self.proflog = self.commons['proflog'] if 'proflog' in self.commons else logging.getLogger('sosprofile')
# get the option list into a dictionary
for opt in self.option_list:
@@ -171,9 +170,6 @@ class Plugin(object):
This function returns the number of replacements made.
'''
- if self.commons['cmdlineopts'].profiler:
- start_time = time()
-
globstr = '*' + cmd + '*'
self.soslog.debug("substituting '%s' for '%s' in commands matching %s"
% (subst, regexp, globstr))
@@ -200,11 +196,6 @@ class Plugin(object):
msg = 'regex substitution failed for %s in plugin %s with: "%s"'
self.soslog.error(msg % (called['exe'], self.name(), e))
replacements = None
-
- if self.commons['cmdlineopts'].profiler:
- time_passed = time() - start_time
- self.proflog.debug("subst: %-75s time: %f"
- % (globstr, time_passed))
return replacements
def do_file_sub(self, srcpath, regexp, subst):
@@ -215,9 +206,6 @@ class Plugin(object):
This function returns the number of replacements made.
'''
- if self.commons['cmdlineopts'].profiler:
- start_time = time()
-
try:
path = self._get_dest_for_srcpath(srcpath)
self.soslog.debug("substituting '%s' for '%s' in %s"
@@ -234,10 +222,6 @@ class Plugin(object):
msg = 'regex substitution failed for %s in plugin %s with: "%s"'
self.soslog.error(msg % (path, self.name(), e))
replacements = 0
- if self.commons['cmdlineopts'].profiler:
- time_passed = time() - start_time
- self.proflog.debug("subst : %-75s time: %f"
- % (srcpath, time_passed))
return replacements
def do_regex_find_all(self, regex, fname):
@@ -314,10 +298,6 @@ class Plugin(object):
/etc/my_file.conf the file would end up at
/configurations/my_file.conf.
'''
-
- if self.commons['cmdlineopts'].profiler:
- start_time = time()
-
if self._path_in_path_list(srcpath, self.forbidden_paths):
self.soslog.debug("%s is in the forbidden path list" % srcpath)
return ''
@@ -358,9 +338,6 @@ class Plugin(object):
'dstpath':dest,
'symlink':"no"})
- if self.commons['cmdlineopts'].profiler:
- time_passed = time() - start_time
- self.proflog.debug("copied: %-75s time: %f" % (srcpath, time_passed))
except Exception as e:
self.soslog.error("Unable to copy %s to %s" % (srcpath, dest))
self.soslog.error(traceback.format_exc())
@@ -560,9 +537,6 @@ class Plugin(object):
"""Execute a command and save the output to a file for inclusion in the
report.
"""
- if self.commons['cmdlineopts'].profiler:
- start_time = time()
-
# pylint: disable-msg = W0612
status, shout, runtime = self.get_command_output(exe, timeout=timeout)
if (status == 127):
@@ -582,10 +556,6 @@ class Plugin(object):
self.executed_commands.append({'exe': exe, 'file':outfn_strip}) # save in our list
self.commons['xmlreport'].add_command(cmdline=exe,exitcode=status,f_stdout=outfn_strip,runtime=runtime)
- if self.commons['cmdlineopts'].profiler:
- time_passed = time() - start_time
- self.proflog.debug("output: %-75s time: %f" % (exe, time_passed))
-
return os.path.join(self.archive.get_archive_path(), outfn)
# For adding output
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 13a46bfd..afa5371c 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -220,7 +220,6 @@ class SoSOptions(object):
_config_file = ""
_tmp_dir = ""
_report = True
- _profiler = False
_compression_type = 'auto'
_options = None
@@ -431,19 +430,6 @@ class SoSOptions(object):
self._report = value
@property
- def profiler(self):
- if self._options != None:
- return self._options.profiler
- return self._profiler
-
- @profiler.setter
- def profiler(self, value):
- self._check_options_initialized()
- if not isinstance(value, bool):
- raise TypeError("SoSOptions.profiler expects a boolean")
- self._profiler = value
-
- @property
def compression_type(self):
if self._options != None:
return self._options.compression_type
@@ -508,9 +494,6 @@ class SoSOptions(object):
parser.add_option("--no-report", action="store_true",
dest="report",
help="Disable HTML/XML reporting", default=False)
- parser.add_option("--profile", action="store_true",
- dest="profiler",
- help="turn on profiling", default=False)
parser.add_option("-z", "--compression-type", dest="compression_type",
help="compression technology to use [auto, zip, gzip, bzip2, xz] (default=auto)",
default="auto")
@@ -563,7 +546,6 @@ class SoSReport(object):
'rptdir': self.rptdir,
'tmpdir': self.tmpdir,
'soslog': self.soslog,
- 'proflog' : self.proflog,
'policy': self.policy,
'verbosity': self.opts.verbosity,
'xmlreport': self.xml_report,
@@ -680,32 +662,17 @@ class SoSReport(object):
ui_console.setLevel(logging.INFO)
self.ui_log.addHandler(ui_console)
- # profile logging
- if self.opts.profiler:
- self.proflog = logging.getLogger('sosprofile')
- self.proflog.setLevel(logging.DEBUG)
- self.sos_profile_log_file = self.get_temp_file()
- plog = logging.FileHandler(self.sos_profile_log_file.name)
- plog.setFormatter(logging.Formatter('%(message)s'))
- plog.setLevel(logging.DEBUG)
- self.proflog.addHandler(plog)
- else:
- self.proflog = logging.getLogger('sosprofile')
- self.proflog.setLevel(logging.FATAL)
-
def _finish_logging(self):
logging.shutdown()
# the logging module seems to persist in the jython/jboss/eap world
# so the handlers need to be removed
- for logger in [logging.getLogger(x) for x in ('sos', 'sosprofile', 'sos_ui')]:
+ for logger in [logging.getLogger(x) for x in ('sos', 'sos_ui')]:
for h in logger.handlers:
logger.removeHandler(h)
if getattr(self, "sos_log_file", None):
self.archive.add_file(self.sos_log_file.name, dest=os.path.join('sos_logs', 'sos.log'))
- if getattr(self, "sos_profile_log_file", None):
- self.archive.add_file(self.sos_profile_log_file.name, dest=os.path.join('sos_logs', 'profile.log'))
if getattr(self, "sos_ui_log_file", None):
self.archive.add_file(self.sos_ui_log_file.name, dest=os.path.join('sos_logs', 'ui.log'))
diff --git a/tests/plugin_tests.py b/tests/plugin_tests.py
index 31ffae40..0f8ef5da 100644
--- a/tests/plugin_tests.py
+++ b/tests/plugin_tests.py
@@ -89,9 +89,7 @@ class EnablerPlugin(Plugin):
class MockOptions(object):
-
- profiler = False
-
+ pass
class PluginToolTests(unittest.TestCase):