aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-07-08 13:24:25 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-07-08 13:26:48 +0100
commite3491e80db91dc4fbf71eef789e48373c446c86a (patch)
treee98fe938acca3e3fc15bc30b001d51d9eb705dad
parent41e3d50b7c81cd23ee651e81eb0db5fb1aadd693 (diff)
downloadsos-e3491e80db91dc4fbf71eef789e48373c446c86a.tar.gz
[plugin] implement global --log-size option
Implement a global '--log-size' option that causes all plugins implementing log size limiting (via add_copy_spec_limit()) to apply the specified value as the size limit. Convert the auditd, cups, logs, nscd, rabbitmq, squid, and upstart plugins to use the new option. Fixes #306. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py2
-rw-r--r--sos/plugins/auditd.py6
-rw-r--r--sos/plugins/cups.py6
-rw-r--r--sos/plugins/logs.py6
-rw-r--r--sos/plugins/nscd.py5
-rw-r--r--sos/plugins/rabbitmq.py5
-rw-r--r--sos/plugins/squid.py11
-rw-r--r--sos/plugins/upstart.py5
-rw-r--r--sos/sosreport.py17
9 files changed, 28 insertions, 35 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 09d58172..142301fd 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', 'all_logs')
+ global_options = ('verify', 'all_logs', 'log_size')
if optionname in global_options:
return getattr(self.commons['cmdlineopts'], optionname)
diff --git a/sos/plugins/auditd.py b/sos/plugins/auditd.py
index e3aa3145..3bb022d9 100644
--- a/sos/plugins/auditd.py
+++ b/sos/plugins/auditd.py
@@ -18,10 +18,6 @@ class Auditd(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
"""Auditd related information
"""
- option_list = [
- ("logsize", "maximum size (MiB) of logs to collect", "", 15)
- ]
-
plugin_name = 'auditd'
packages = ('audit',)
@@ -32,7 +28,7 @@ class Auditd(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
"/etc/audit/audit.rules"
])
if not self.get_option("all_logs"):
- limit = self.get_option("logsize")
+ limit = self.get_option("log_size")
self.add_copy_spec_limit("/var/log/audit/audit.log", sizelimit=limit)
else:
self.add_copy_spec("/var/log/audit")
diff --git a/sos/plugins/cups.py b/sos/plugins/cups.py
index 32e28ed7..05d5fe1b 100644
--- a/sos/plugins/cups.py
+++ b/sos/plugins/cups.py
@@ -22,13 +22,9 @@ class Cups(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
packages = ('cups',)
- option_list = [
- ("logsize", "max size (MiB) to collect per log file", "", 5)
- ]
-
def setup(self):
if not self.get_option("all_logs"):
- limit = self.get_option("logsize")
+ limit = self.get_option("log_size")
self.add_copy_spec_limit("/var/log/cups/access_log", sizelimit=limit)
self.add_copy_spec_limit("/var/log/cups/error_log", sizelimit=limit)
self.add_copy_spec_limit("/var/log/cups/page_log", sizelimit=limit)
diff --git a/sos/plugins/logs.py b/sos/plugins/logs.py
index 4ea60ed5..3f0c5c28 100644
--- a/sos/plugins/logs.py
+++ b/sos/plugins/logs.py
@@ -20,17 +20,13 @@ class Logs(Plugin):
plugin_name = "logs"
- option_list = [
- ("logsize", "max size (MiB) to collect per log file", "", 15)
- ]
-
def setup(self):
self.add_copy_specs([
"/etc/syslog.conf",
"/etc/rsyslog.conf"
])
- self.limit = self.get_option("logsize")
+ self.limit = self.get_option("log_size")
self.add_copy_spec_limit("/var/log/boot.log", sizelimit = self.limit)
self.add_copy_spec_limit("/var/log/cloud-init*", sizelimit = self.limit)
diff --git a/sos/plugins/nscd.py b/sos/plugins/nscd.py
index c880e63b..b9769841 100644
--- a/sos/plugins/nscd.py
+++ b/sos/plugins/nscd.py
@@ -22,9 +22,6 @@ class Nscd(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
plugin_name = 'nscd'
- option_list = [("nscdlogsize", "max size (MiB) to collect per nscd log file",
- "", 50)]
-
files = ('/etc/nscd.conf',)
packages = ('nscd',)
@@ -36,6 +33,6 @@ class Nscd(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
for o in opt:
f = o.split()
self.add_copy_spec_limit(f[1],
- sizelimit = self.get_option("nscdlogsize"))
+ sizelimit = self.get_option("log_size"))
# vim: et ts=4 sw=4
diff --git a/sos/plugins/rabbitmq.py b/sos/plugins/rabbitmq.py
index 84a6b01e..03b696d1 100644
--- a/sos/plugins/rabbitmq.py
+++ b/sos/plugins/rabbitmq.py
@@ -22,12 +22,9 @@ class RabbitMQ(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
files = ('/etc/rabbitmq/rabbitmq.conf',)
packages = ('rabbitmq-server',)
- option_list = [("logsize", "maximum size (MiB) of logs to collect",
- "", 15)]
-
def setup(self):
self.add_cmd_output("rabbitmqctl report")
self.add_copy_spec("/etc/rabbitmq/*")
self.add_copy_spec_limit("/var/log/rabbitmq/*",
- sizelimit=self.get_option('logsize'))
+ sizelimit=self.get_option('log_size'))
# vim: et ts=4 sw=4
diff --git a/sos/plugins/squid.py b/sos/plugins/squid.py
index 1aa969af..848ab530 100644
--- a/sos/plugins/squid.py
+++ b/sos/plugins/squid.py
@@ -21,9 +21,6 @@ class Squid(Plugin):
plugin_name = 'squid'
- option_list = [("logsize", "maximum size (MiB) of logs to collect",
- "", 15)]
-
class RedHatSquid(Squid, RedHatPlugin):
"""squid Red Hat related information
@@ -34,7 +31,7 @@ class RedHatSquid(Squid, RedHatPlugin):
def setup(self):
self.add_copy_spec_limit("/etc/squid/squid.conf",
- sizelimit=self.get_option('logsize'))
+ sizelimit=self.get_option('log_size'))
class DebianSquid(Squid, DebianPlugin, UbuntuPlugin):
@@ -47,10 +44,10 @@ class DebianSquid(Squid, DebianPlugin, UbuntuPlugin):
def setup(self):
self.add_copy_spec_limit("/etc/squid3/squid.conf",
- sizelimit=self.get_option('logsize'))
+ sizelimit=self.get_option('log_size'))
self.add_copy_spec_limit("/var/log/squid3/*",
- sizelimit=self.get_option('logsize'))
+ sizelimit=self.get_option('log_size'))
self.add_copy_specs(['/etc/squid-deb-proxy'])
self.add_copy_spec_limit("/var/log/squid-deb-proxy/*",
- sizelimit=self.get_option('logsize'))
+ sizelimit=self.get_option('log_size'))
# vim: et ts=4 sw=4
diff --git a/sos/plugins/upstart.py b/sos/plugins/upstart.py
index 876ac793..b9ced84a 100644
--- a/sos/plugins/upstart.py
+++ b/sos/plugins/upstart.py
@@ -24,9 +24,6 @@ class Upstart(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
plugin_name = 'upstart'
packages = ('upstart',)
- option_list = [("logsize", "maximum size (MiB) of logs to collect",
- "", 15)]
-
def setup(self):
self.add_cmd_outputs([
'initctl --system list',
@@ -46,7 +43,7 @@ class Upstart(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
# Log files
self.add_copy_spec_limit('/var/log/upstart/*',
- sizelimit=self.get_option('logsize'))
+ sizelimit=self.get_option('log_size'))
# Session Jobs (running Upstart as a Session Init)
self.add_copy_spec('/usr/share/upstart/')
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 5426d6cf..a1ac71ff 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -206,6 +206,7 @@ class SoSOptions(object):
_plugopts = []
_usealloptions = False
_all_logs = False
+ _log_size = 10
_batch = False
_build = False
_verbosity = 0
@@ -318,6 +319,19 @@ class SoSOptions(object):
self._all_logs = value
@property
+ def log_size(self):
+ if self._options != None:
+ return self._options.log_size
+ return self._log_size
+
+ @log_size.setter
+ def log_size(self, value):
+ self._check_options_initialized()
+ if value < 0:
+ raise ValueError("SoSOptions.log_size expects a value greater than zero")
+ self._log_size = value
+
+ @property
def batch(self):
if self._options != None:
return self._options.batch
@@ -483,6 +497,9 @@ class SoSOptions(object):
dest="plugopts", type="string",
help="plugin options in plugname.option=value format (see -l)",
default = deque())
+ parser.add_option("--log-size", action="store",
+ dest="log_size", default=10, type="int",
+ help="set a limit on the size of collected logs")
parser.add_option("-a", "--alloptions", action="store_true",
dest="usealloptions", default=False,
help="enable all options for loaded plugins")