diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2013-05-01 18:00:13 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2013-05-01 18:00:13 +0100 |
commit | b3ae26a01eb12f2ac2d6df11f169a37ba65a5595 (patch) | |
tree | 6ea9c6250677677ee9a58f6dd3c8f9f2258f0e59 | |
parent | fb2258183a527fe89756fc499571fdcc3bb2486e (diff) | |
download | sos-b3ae26a01eb12f2ac2d6df11f169a37ba65a5595.tar.gz |
Remove syslog collection from general and add new logs plug-in
Move all the syslog collection from the general plug-in to a new
logs plug-in and factor out the all_logs support from the
RedHatLogs class into the Logs superclass.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/general.py | 47 | ||||
-rw-r--r-- | sos/plugins/logs.py | 85 |
2 files changed, 90 insertions, 42 deletions
diff --git a/sos/plugins/general.py b/sos/plugins/general.py index 8728c064..cebbbbee 100644 --- a/sos/plugins/general.py +++ b/sos/plugins/general.py @@ -20,9 +20,6 @@ class General(Plugin): plugin_name = "general" - option_list = [("syslogsize", "max size (MiB) to collect per syslog file", "", 15), - ("all_logs", "collect all log files defined in syslog.conf", "", False)] - def setup(self): self.add_copy_specs([ "/etc/init", # upstart @@ -40,10 +37,6 @@ class General(Plugin): "/etc/localtime", "/root/anaconda-ks.cfg"]) - limit = self.get_option("syslogsize") - self.add_copy_spec_limit("/var/log/messages*", sizelimit = limit) - self.add_copy_spec_limit("/var/log/secure*", sizelimit = limit) - self.add_cmd_output("hostid") self.add_cmd_output("hostname", root_symlink="hostname") self.add_cmd_output("date", root_symlink="date") self.add_cmd_output("uptime", root_symlink="uptime") @@ -65,22 +58,6 @@ class RedHatGeneral(General, RedHatPlugin): "/etc/fedora-release", ]) - if self.get_option('all_logs'): - print "doing all_logs..." - limit = self.option_enabled("syslogsize") - logs = self.do_regex_find_all("^\S+\s+(-?\/.*$)\s+", - "/etc/syslog.conf") - print logs - if self.policy().pkg_by_name("rsyslog") \ - or os.path.exists("/etc/rsyslog.conf"): - logs += self.do_regex_find_all("^\S+\s+(-?\/.*$)\s+", "/etc/rsyslog.conf") - print logs - for i in logs: - if i.startswith("-"): - i = i[1:] - if os.path.isfile(i): - self.add_copy_spec_limit(i, sizelimit = limit) - def postproc(self): self.do_file_sub("/etc/sysconfig/rhn/up2date", @@ -93,29 +70,15 @@ class DebianGeneral(General, DebianPlugin): def setup(self): super(DebianGeneral, self).setup() self.add_copy_specs([ - "/etc/debian_version", "/etc/default", "/etc/lsb-release" + "/etc/debian_version", ]) -class UbuntuGeneral(General, UbuntuPlugin): + + +class UbuntuGeneral(DebianGeneral): """Basic system information for Ubuntu based distributions""" def setup(self): super(UbuntuGeneral, self).setup() - self.add_copy_specs([ - "/etc/default", - "/etc/lsb-release", - "/etc/os-release", - "/var/log/apport.log", - "/var/log/syslog", - "/var/log/udev", - "/var/log/boot*", - "/var/log/kern*", - "/var/log/mail*", - "/var/log/dist-upgrade", - "/var/log/landscape", - "/var/log/installer", - "/var/log/unattended-upgrades", - "/var/log/upstart" - ]) - + self.add_copy_spec("/etc/os-release") diff --git a/sos/plugins/logs.py b/sos/plugins/logs.py new file mode 100644 index 00000000..8fdb9185 --- /dev/null +++ b/sos/plugins/logs.py @@ -0,0 +1,85 @@ +### This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. + +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. + +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import os +from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin + +class Logs(Plugin): + """log data """ + + 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) + ] + + def setup(self): + self.limit = self.get_option("syslogsize") + self.add_copy_spec_limit("/var/log/boot*", sizelimit = self.limit) + + if self.get_option('all_logs'): + print "doing all_logs..." + logs = self.do_regex_find_all("^\S+\s+(-?\/.*$)\s+", + "/etc/syslog.conf") + print logs + if self.policy().pkg_by_name("rsyslog") \ + or os.path.exists("/etc/rsyslog.conf"): + logs += self.do_regex_find_all("^\S+\s+(-?\/.*$)\s+", "/etc/rsyslog.conf") + print logs + for i in logs: + if i.startswith("-"): + i = i[1:] + if os.path.isfile(i): + self.add_copy_spec_limit(i, sizelimit = self.limit) + + +class RedHatLogs(Logs, RedHatPlugin): + """Basic system information for RedHat based distributions""" + + def setup(self): + super(RedHatLogs, self).setup() + self.add_copy_spec_limit("/var/log/secure*", sizelimit = self.limit) + self.add_copy_spec_limit("/var/log/messages*", sizelimit = self.limit) + + +class DebianLogs(Logs, DebianPlugin): + """Basic system information for Debian based distributions""" + + def setup(self): + super(DebianLogs, self).setup() + self.add_copy_specs([ + "/var/log/syslog", + "/var/log/udev", + "/var/log/kern*", + "/var/log/mail*", + "/var/log/dist-upgrade", + "/var/log/installer", + "/var/log/unattended-upgrades" + ]) + + +class UbuntuLogs(Logs, UbuntuPlugin): + """Basic system information for Ubuntu based distributions""" + + def setup(self): + super(UbuntuLogs, self).setup() + self.add_copy_specs([ + "/var/log/apport.log", + "/var/log/landscape", + ]) + |