diff options
-rw-r--r-- | sos/plugins/kernel.py | 31 | ||||
-rw-r--r-- | sos/plugins/landscape.py | 4 | ||||
-rw-r--r-- | sos/plugins/memory.py | 3 | ||||
-rw-r--r-- | sos/plugins/named.py | 4 | ||||
-rw-r--r-- | sos/plugins/networking.py | 4 | ||||
-rw-r--r-- | sos/plugins/sar.py | 28 | ||||
-rw-r--r-- | sos/plugins/selinux.py | 29 | ||||
-rw-r--r-- | sos/policies/windows.py | 7 |
8 files changed, 58 insertions, 52 deletions
diff --git a/sos/plugins/kernel.py b/sos/plugins/kernel.py index 4ebf3575..8c50da2d 100644 --- a/sos/plugins/kernel.py +++ b/sos/plugins/kernel.py @@ -18,22 +18,20 @@ import os class kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): """kernel related information """ - option_list = [("modinfo", 'gathers information on all kernel modules', 'fast', True)] - module_file = "" + + sys_module = '/sys/module' def setup(self): + # compat self.add_cmd_output("uname -a", root_symlink = "uname") - self.module_file = self.get_cmd_output_now("lsmod", root_symlink = "lsmod") - - if self.get_option('modinfo'): - runcmd = "" - ret, mods, rtime = self.call_ext_prog('lsmod | cut -f1 -d" " 2>/dev/null | grep -v Module 2>/dev/null') - for kmod in mods.split('\n'): - if '' != kmod.strip(): - runcmd = runcmd + " " + kmod - if len(runcmd): - self.add_cmd_output("modinfo " + runcmd) - + self.add_cmd_output("lsmod", root_symlink = "lsmod") + + try: + modules = os.listdir(sys_module) + self.add_cmd_output("modinfo " + " ".join(modules)) + except OSError: + self.soslog.error("could not list %s" % sys_module) + self.add_cmd_output("sysctl -a") self.add_copy_specs([ "/proc/sys/kernel/random/boot_id", @@ -41,9 +39,10 @@ class kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): "/sys/module/*/initstate", "/sys/module/*/refcnt", "/sys/module/*/taint", - "/proc/filesystems", - "/proc/ksyms", + "/proc/kallsyms", + "/proc/buddyinfo", "/proc/slabinfo", + "/proc/zoneinfo", "/lib/modules/%s/modules.dep" % self.policy().kernel_version(), "/etc/conf.modules", "/etc/modules.conf", @@ -54,9 +53,7 @@ class kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): "/lib/sysctl.d", "/proc/cmdline", "/proc/driver", - "/proc/zoneinfo", "/proc/sys/kernel/tainted", - "/proc/buddyinfo", "/proc/softirqs", "/proc/timer*", "/proc/lock*"]) diff --git a/sos/plugins/landscape.py b/sos/plugins/landscape.py index c31dea70..9861281f 100644 --- a/sos/plugins/landscape.py +++ b/sos/plugins/landscape.py @@ -60,10 +60,10 @@ class Landscape(Plugin, UbuntuPlugin): packages = ('landscape-client',) def setup(self): - self.addCopySpec("/etc/landscape/client.conf") + self.add_copy_spec("/etc/landscape/client.conf") def postproc(self): - self.doFileSub("/etc/landscape/client.conf", + self.do_file_sub("/etc/landscape/client.conf", r"registration_password(.*)", r"registration_password[***]" ) diff --git a/sos/plugins/memory.py b/sos/plugins/memory.py index 1124b575..088b79b2 100644 --- a/sos/plugins/memory.py +++ b/sos/plugins/memory.py @@ -25,6 +25,7 @@ class memory(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): "/proc/slabinfo", "/proc/pagetypeinfo"]) - self.add_cmd_output("dmesg | grep -e 'e820.' -e 'aperature.'") + self.add_cmd_output("dmesg | grep -e 'e820.' -e 'aperature.'", + suggest_filename="dmesg.e820-map") self.add_cmd_output("free", root_symlink = "free") self.add_cmd_output("free -m") diff --git a/sos/plugins/named.py b/sos/plugins/named.py index 8a347f8e..a3f6b003 100644 --- a/sos/plugins/named.py +++ b/sos/plugins/named.py @@ -13,7 +13,9 @@ ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +from os.path import exists, join, normpath import commands +import pdb class Named(Plugin): """named related information @@ -24,7 +26,7 @@ class Named(Plugin): config_files = named_conf def setup(self): - for cfg in config_files: + for cfg in self.config_files: if exists(cfg): self.add_copy_spec(cfg) self.add_copy_spec(self.get_dns_dir(cfg)) diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py index a7e07a80..90b740ca 100644 --- a/sos/plugins/networking.py +++ b/sos/plugins/networking.py @@ -116,7 +116,7 @@ class Networking(Plugin): self.add_cmd_output("brctl showstp "+br_name) if self.get_option("traceroute"): - self.add_cmd_output("/bin/traceroute -n %s" % trace_host) + self.add_cmd_output("/bin/traceroute -n %s" % self.trace_host) return @@ -148,5 +148,5 @@ class UbuntuNetworking(Networking, UbuntuPlugin): self.add_cmd_output("/usr/sbin/ufw status") self.add_cmd_output("/usr/sbin/ufw app list") if self.get_option("traceroute"): - self.add_cmd_output("/usr/sbin/traceroute -n %s" % trace_host) + self.add_cmd_output("/usr/sbin/traceroute -n %s" % self.trace_host) diff --git a/sos/plugins/sar.py b/sos/plugins/sar.py index 2d977ae9..4e6cf51c 100644 --- a/sos/plugins/sar.py +++ b/sos/plugins/sar.py @@ -15,24 +15,42 @@ from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin import os -class Sar(Plugin, RedHatPlugin): +class Sar(Plugin,): """ Collect system activity reporter data """ packages = ('sysstat',) sa_path = '/var/log/sa' + def check_enabled(self): + # check to see if we are force-enabled with no sar installation + if not os.path.exists(self.sa_path) or not os.path.isdir(self.sa_path): + self.soslog.info("sar directory %s does not exist" % self.sa_path + + " or is not a directory") + return False + return True + def setup(self): dirList = os.listdir(self.sa_path) # find all the sa file that don't have an existing sar file for fname in dirList: if fname[0:2] == 'sa' and fname[2] != 'r': sar_filename = 'sar' + fname[2:4] + sa_data_path = os.path.join(self.sa_path, fname) if sar_filename not in dirList: - sar_path = os.path.join(self.sa_path, fname) - sar_command = 'sh -c "LANG=C sar -A -f %s"' % sar_path - self.collectOutputNow(sar_command, sar_filename, - root_symlink=sar_filename) + sar_cmd = 'sh -c "LANG=C sar -A -f %s"' % sa_data_path + self.add_cmd_output(sar_cmd, sar_filename) + sadf_cmd = "sadf -x %s" % sa_data_path + self.add_cmd_output(sadf_cmd, "%s.xml" % fname) + self.add_copy_spec(os.path.join(self.sa_path, "sar*")) + + +class RedHatSar(Sar, RedHatPlugin): + """ Collect system activity reporter data + """ + + sa_path = '/var/log/sa' + class DebianSar(Sar, DebianPlugin, UbuntuPlugin): """ Collect system activity reporter data diff --git a/sos/plugins/selinux.py b/sos/plugins/selinux.py index c3501eec..d35010a7 100644 --- a/sos/plugins/selinux.py +++ b/sos/plugins/selinux.py @@ -17,30 +17,17 @@ from sos.plugins import Plugin, RedHatPlugin class selinux(Plugin, RedHatPlugin): """selinux related information """ + option_list = [("fixfiles", 'Print incorrect file context labels', 'slow', False)] + packages = ('libselinux',) + def setup(self): # sestatus is always collected in check_enabled() self.add_copy_spec("/etc/selinux") if self.get_option('fixfiles'): - self.add_cmd_output("fixfiles check") - self.add_forbidden_path("/etc/selinux/targeted") - - if not self.policy().pkg_by_name('setroubleshoot'): - return + self.add_cmd_output("fixfiles -v check") + self.add_cmd_output("sestatus -b") + self.add_cmd_output("selinuxdefcon root") + self.add_cmd_output("selinuxconlist root") + self.add_cmd_output("selinuxexeccon /bin/passwd") - # Check for SELinux denials and capture raw output from sealert - if self.policy().default_runlevel() in self.policy().runlevel_by_service("setroubleshoot"): - # TODO: fixup regex for more precise matching - sealert=do_regex_findall(r"^.*setroubleshoot:.*(sealert\s-l\s.*)","/var/log/messages") - if sealert: - for i in sealert: - self.add_cmd_output("%s" % i) - self.add_alert("There are numerous selinux errors present and "+ - "possible fixes stated in the sealert output.") - def check_enabled(self): - try: - if self.get_cmd_output_now("sestatus", root_symlink = "sestatus").split(":")[1].strip() == "disabled": - return False - except: - pass - return True diff --git a/sos/policies/windows.py b/sos/policies/windows.py index 0424a3f0..f2ce48c4 100644 --- a/sos/policies/windows.py +++ b/sos/policies/windows.py @@ -27,10 +27,11 @@ class WindowsPolicy(Policy): is_windows = False try: from java.lang import System - is_windows = "win" in System.getProperty('os.name').lower() + os_name = System.getProperty('os.name').lower() except: - is_windows = "win" in platform.system().lower() - return is_windows + os_name = platform.system().lower() + + return "win" in os_name and "darwin" not in os_name def is_root(self): if "S-1-16-12288" in shell_out("whoami /groups"): |