diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2014-07-08 12:42:00 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2014-07-08 12:42:00 +0100 |
commit | 41e3d50b7c81cd23ee651e81eb0db5fb1aadd693 (patch) | |
tree | 3b9ffe599411ee1954df088cf67ba3f9d74426eb | |
parent | 9f2c21d78f60c27b5497eb09a5919b13ed2f8062 (diff) | |
download | sos-41e3d50b7c81cd23ee651e81eb0db5fb1aadd693.tar.gz |
[plugin] implement global --all-logs option
Implement a global '--all-logs' option that causes all active
plugins to attempt to collect all logs present regardles of
rotation or size limiting. This replaces the numerous per-plugin
'all_logs' options and avoids the need for clumsy command lines
like:
-k audit.all_logs,cron.all_logs,logs.all_logs,pcp.all_logs,...
The audit, cron, cups, libvirt, logs, mysql, and pcp plugins have
been converted to use the new option.
Fixes #305.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/__init__.py | 2 | ||||
-rw-r--r-- | sos/plugins/auditd.py | 5 | ||||
-rw-r--r-- | sos/plugins/cron.py | 6 | ||||
-rw-r--r-- | sos/plugins/cups.py | 5 | ||||
-rw-r--r-- | sos/plugins/libvirt.py | 3 | ||||
-rw-r--r-- | sos/plugins/logs.py | 6 | ||||
-rw-r--r-- | sos/plugins/mysql.py | 3 | ||||
-rw-r--r-- | sos/plugins/pcp.py | 5 | ||||
-rw-r--r-- | sos/sosreport.py | 17 |
9 files changed, 32 insertions, 20 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index b3a2ebac..09d58172 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -367,7 +367,7 @@ class Plugin(object): matches any of the option names is returned. """ - global_options = ('verify',) + global_options = ('verify', 'all_logs') if optionname in global_options: return getattr(self.commons['cmdlineopts'], optionname) diff --git a/sos/plugins/auditd.py b/sos/plugins/auditd.py index 1f9c7c4d..e3aa3145 100644 --- a/sos/plugins/auditd.py +++ b/sos/plugins/auditd.py @@ -18,8 +18,9 @@ class Auditd(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): """Auditd related information """ - option_list = [("logsize", "maximum size (MiB) of logs to collect", "", 15), - ("all_logs", "collect all logs regardless of size", "", False)] + option_list = [ + ("logsize", "maximum size (MiB) of logs to collect", "", 15) + ] plugin_name = 'auditd' diff --git a/sos/plugins/cron.py b/sos/plugins/cron.py index ae2b479a..ca3bedec 100644 --- a/sos/plugins/cron.py +++ b/sos/plugins/cron.py @@ -25,9 +25,13 @@ class Cron(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): def setup(self): self.add_copy_specs([ "/etc/cron*", - "/var/log/cron*", + "/var/log/cron", "/var/spool/cron" ]) + + if self.get_option("all_logs"): + self.add_copy_spec("/var/log/cron*") + self.add_cmd_output("crontab -l -u root", suggest_filename = "root_crontab") diff --git a/sos/plugins/cups.py b/sos/plugins/cups.py index a4e9c182..32e28ed7 100644 --- a/sos/plugins/cups.py +++ b/sos/plugins/cups.py @@ -22,8 +22,9 @@ class Cups(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): packages = ('cups',) - option_list = [("logsize", "max size (MiB) to collect per log file", "", 5), - ("all_logs", "collect all cups log files", "", False)] + option_list = [ + ("logsize", "max size (MiB) to collect per log file", "", 5) + ] def setup(self): if not self.get_option("all_logs"): diff --git a/sos/plugins/libvirt.py b/sos/plugins/libvirt.py index a60c3311..2c0a1d60 100644 --- a/sos/plugins/libvirt.py +++ b/sos/plugins/libvirt.py @@ -20,9 +20,6 @@ class Libvirt(Plugin, RedHatPlugin, UbuntuPlugin, DebianPlugin): """libvirt-related information """ - option_list = [( - "all_logs", "collect all logs regardless of size", "", False - )] plugin_name = 'libvirt' def setup(self): diff --git a/sos/plugins/logs.py b/sos/plugins/logs.py index 5a1ac239..4ea60ed5 100644 --- a/sos/plugins/logs.py +++ b/sos/plugins/logs.py @@ -21,11 +21,7 @@ class Logs(Plugin): plugin_name = "logs" option_list = [ - ("logsize", - "max size (MiB) to collect per syslog file", "", 15), - ("all_logs", - "collect all log files defined in syslog.conf", - "", False) + ("logsize", "max size (MiB) to collect per log file", "", 15) ] def setup(self): diff --git a/sos/plugins/mysql.py b/sos/plugins/mysql.py index b2e19cb7..71e6413c 100644 --- a/sos/plugins/mysql.py +++ b/sos/plugins/mysql.py @@ -25,8 +25,7 @@ class Mysql(Plugin): option_list = [ ("dbuser", "username for database dumps", "", "mysql"), ("dbpass", "password for database dumps", "", ""), - ("dbdump", "collect a database dump", "", False), - ("all_logs", "collect all MySQL logs", "", False) + ("dbdump", "collect a database dump", "", False) ] def setup(self): diff --git a/sos/plugins/pcp.py b/sos/plugins/pcp.py index 7639d69a..7f67358d 100644 --- a/sos/plugins/pcp.py +++ b/sos/plugins/pcp.py @@ -28,9 +28,6 @@ class Pcp(Plugin, RedHatPlugin, DebianPlugin): packages = ('pcp',) pcp_conffile = '/etc/pcp.conf' - option_list = [( - "all_pcplogs", "gather all logged archive files", "", False - )] # size-limit total PCP log data collected by default (MB) pcplog_totalsize = 100 @@ -77,7 +74,7 @@ class Pcp(Plugin, RedHatPlugin, DebianPlugin): return True def setup(self): - if self.get_option("all_pcplogs"): + if self.get_option("all_logs"): self.pcplog_totalsize = 0 if not self.pcp_parse_conffile(): diff --git a/sos/sosreport.py b/sos/sosreport.py index 7ee09292..5426d6cf 100644 --- a/sos/sosreport.py +++ b/sos/sosreport.py @@ -205,6 +205,7 @@ class SoSOptions(object): _onlyplugins = [] _plugopts = [] _usealloptions = False + _all_logs = False _batch = False _build = False _verbosity = 0 @@ -304,6 +305,19 @@ class SoSOptions(object): self._usealloptions = value @property + def all_logs(self): + if self._options != None: + return self._options.all_logs + return self._all_logs + + @all_logs.setter + def all_logs(self, value): + self._check_options_initialized() + if not isinstance(value, bool): + raise TypeError("SoSOptions.all_logs expects a boolean") + self._all_logs = value + + @property def batch(self): if self._options != None: return self._options.batch @@ -472,6 +486,9 @@ class SoSOptions(object): parser.add_option("-a", "--alloptions", action="store_true", dest="usealloptions", default=False, help="enable all options for loaded plugins") + parser.add_option("--all-logs", action="store_true", + dest="all_logs", default=False, + help="collect all available logs regardless of size") parser.add_option("--batch", action="store_true", dest="batch", default=False, help="batch mode - do not prompt interactively") |