diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2012-03-06 09:55:00 +0000 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2012-03-19 17:49:05 +0000 |
commit | e0d3597810c1a4e1f70eced7ddc896884055cd43 (patch) | |
tree | b9c781b6596647a1c3d6d274b5377b0e580a05f5 | |
parent | 80550c962e9a45e4f7b77e362c830bab7449f52f (diff) | |
download | sos-e0d3597810c1a4e1f70eced7ddc896884055cd43.tar.gz |
Add symbolic links for truncated log files
Add symbolic links for truncated log files and allow modules to
create symlinks in subdirectories of the report via symlink=
Resolves: bz766583
-rw-r--r-- | sos/plugins/devicemapper.py | 2 | ||||
-rw-r--r-- | sos/plugins/filesys.py | 6 | ||||
-rw-r--r-- | sos/plugins/general.py | 8 | ||||
-rw-r--r-- | sos/plugins/hardware.py | 4 | ||||
-rw-r--r-- | sos/plugins/kernel.py | 4 | ||||
-rw-r--r-- | sos/plugins/lsbrelease.py | 2 | ||||
-rw-r--r-- | sos/plugins/memory.py | 2 | ||||
-rw-r--r-- | sos/plugins/networking.py | 6 | ||||
-rw-r--r-- | sos/plugins/process.py | 6 | ||||
-rw-r--r-- | sos/plugins/rhn.py | 6 | ||||
-rw-r--r-- | sos/plugins/rpm.py | 4 | ||||
-rw-r--r-- | sos/plugins/sar.py | 2 | ||||
-rw-r--r-- | sos/plugins/selinux.py | 2 | ||||
-rw-r--r-- | sos/plugins/startup.py | 2 | ||||
-rw-r--r-- | sos/plugintools.py | 14 |
15 files changed, 36 insertions, 34 deletions
diff --git a/sos/plugins/devicemapper.py b/sos/plugins/devicemapper.py index 5d267816..94c46b15 100644 --- a/sos/plugins/devicemapper.py +++ b/sos/plugins/devicemapper.py @@ -34,7 +34,7 @@ class devicemapper(sos.plugintools.PluginBase): self.collectExtOutput("/sbin/dmsetup status") self.collectExtOutput("/sbin/dmsetup ls --tree") - self.collectExtOutput("/sbin/vgdisplay -vv", root_symlink = "vgdisplay") + self.collectExtOutput("/sbin/vgdisplay -vv", symlink = "vgdisplay") self.collectExtOutput("/sbin/vgscan -vvv") self.collectExtOutput("/sbin/pvscan -v") self.collectExtOutput("/sbin/lvs -a -o +devices") diff --git a/sos/plugins/filesys.py b/sos/plugins/filesys.py index 54585ba1..0a204134 100644 --- a/sos/plugins/filesys.py +++ b/sos/plugins/filesys.py @@ -30,12 +30,12 @@ class filesys(sos.plugintools.PluginBase): self.addCopySpec("/proc/mounts") self.addCopySpec("/proc/mdstat") self.addCopySpec("/etc/raidtab") - mounts = self.collectOutputNow("/bin/mount -l", root_symlink = "mount") + mounts = self.collectOutputNow("/bin/mount -l", symlink = "mount") self.addCopySpec("/etc/mdadm.conf") - self.collectExtOutput("/bin/df -al", root_symlink = "df") + self.collectExtOutput("/bin/df -al", symlink = "df") if self.getOption('lsof'): - self.collectExtOutput("/usr/sbin/lsof -b +M -n -l -P", root_symlink = "lsof") + self.collectExtOutput("/usr/sbin/lsof -b +M -n -l -P", symlink = "lsof") self.collectExtOutput("/sbin/blkid -c /dev/null") self.collectExtOutput("/bin/lsblk") diff --git a/sos/plugins/general.py b/sos/plugins/general.py index 004c49bf..75df6eed 100644 --- a/sos/plugins/general.py +++ b/sos/plugins/general.py @@ -43,12 +43,12 @@ class general(sos.plugintools.PluginBase): self.addCopySpec("/var/log/pm/suspend.log") self.addCopySpec("/var/log/up2date") self.addCopySpec("/etc/exports") - self.collectExtOutput("/bin/hostname", root_symlink = "hostname") - self.collectExtOutput("/bin/date", root_symlink = "date") - self.collectExtOutput("/usr/bin/uptime", root_symlink = "uptime") + self.collectExtOutput("/bin/hostname", symlink = "hostname") + self.collectExtOutput("/bin/date", symlink = "date") + self.collectExtOutput("/usr/bin/uptime", symlink = "uptime") self.collectExtOutput("/bin/dmesg") self.addCopySpec("/root/anaconda-ks.cfg") - self.collectExtOutput("/usr/sbin/alternatives --display java", root_symlink = "java") + self.collectExtOutput("/usr/sbin/alternatives --display java", symlink = "java") self.collectExtOutput("/usr/bin/readlink -f /usr/bin/java") # new entitlement certificate support diff --git a/sos/plugins/hardware.py b/sos/plugins/hardware.py index efb7e17b..f0a251fa 100644 --- a/sos/plugins/hardware.py +++ b/sos/plugins/hardware.py @@ -38,9 +38,9 @@ class hardware(sos.plugintools.PluginBase): self.addCopySpec("/sys/bus/scsi") self.addCopySpec("/sys/state") self.collectExtOutput("python /usr/share/rhn/up2date_client/hardware.py", suggest_filename="hardware.py") - self.collectExtOutput("""/bin/echo -e "lspci:\n" ; /sbin/lspci ; /bin/echo -e "\nlspci -nvv:\n" ; /sbin/lspci -nvv ; /bin/echo -e "\nlspci -tv:\n" ; /sbin/lspci -tv""", suggest_filename = "lspci", root_symlink = "lspci") + self.collectExtOutput("""/bin/echo -e "lspci:\n" ; /sbin/lspci ; /bin/echo -e "\nlspci -nvv:\n" ; /sbin/lspci -nvv ; /bin/echo -e "\nlspci -tv:\n" ; /sbin/lspci -tv""", suggest_filename = "lspci", symlink = "lspci") - self.collectExtOutput("/usr/sbin/dmidecode", root_symlink = "dmidecode") + self.collectExtOutput("/usr/sbin/dmidecode", symlink = "dmidecode") self.collectExtOutput("/usr/bin/cpufreq-info") if self.policy().getArch().endswith("386"): diff --git a/sos/plugins/kernel.py b/sos/plugins/kernel.py index e20ee19e..a4d20677 100644 --- a/sos/plugins/kernel.py +++ b/sos/plugins/kernel.py @@ -41,8 +41,8 @@ class kernel(sos.plugintools.PluginBase): ] def setup(self): - self.collectExtOutput("/bin/uname -a", root_symlink = "uname") - self.moduleFile = self.collectOutputNow("/sbin/lsmod", root_symlink = "lsmod") + self.collectExtOutput("/bin/uname -a", symlink = "uname") + self.moduleFile = self.collectOutputNow("/sbin/lsmod", symlink = "lsmod") if self.getOption('modinfo'): runcmd = "" diff --git a/sos/plugins/lsbrelease.py b/sos/plugins/lsbrelease.py index 78a83577..74dbc344 100644 --- a/sos/plugins/lsbrelease.py +++ b/sos/plugins/lsbrelease.py @@ -25,6 +25,6 @@ class lsbrelease(sos.plugintools.PluginBase): return def setup(self): self.collectExtOutput("/usr/bin/lsb_release -a") - self.collectExtOutput("/usr/bin/lsb_release -d", suggest_filename = "lsb_release", root_symlink = "lsb-release") + self.collectExtOutput("/usr/bin/lsb_release -d", suggest_filename = "lsb_release", symlink = "lsb-release") self.addCopySpec("/etc/lsb-release*") return diff --git a/sos/plugins/memory.py b/sos/plugins/memory.py index 7fbe39c3..aa61d9da 100644 --- a/sos/plugins/memory.py +++ b/sos/plugins/memory.py @@ -24,7 +24,7 @@ class memory(sos.plugintools.PluginBase): self.addCopySpec("/proc/slabinfo") self.collectExtOutput("/bin/dmesg | grep -e 'e820.' -e 'aperature.'") - self.collectExtOutput("/usr/bin/free", root_symlink = "free") + self.collectExtOutput("/usr/bin/free", symlink = "free") self.collectExtOutput("/usr/bin/free -m") return diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py index 98a408e2..c34e109a 100644 --- a/sos/plugins/networking.py +++ b/sos/plugins/networking.py @@ -66,14 +66,14 @@ class networking(sos.plugintools.PluginBase): self.addCopySpec("/etc/xinetd.d") self.addCopySpec("/etc/host*") self.addCopySpec("/etc/resolv.conf") - ifconfigFile=self.collectOutputNow("/sbin/ifconfig -a", root_symlink = "ifconfig") - self.collectExtOutput("/sbin/route -n", root_symlink = "route") + ifconfigFile=self.collectOutputNow("/sbin/ifconfig -a", symlink = "ifconfig") + self.collectExtOutput("/sbin/route -n", symlink = "route") self.collectIPTable("filter") self.collectIPTable("nat") self.collectIPTable("mangle") self.collectExtOutput("/bin/netstat -s") self.collectExtOutput("/bin/netstat -agn") - self.collectExtOutput("/bin/netstat -neopa", root_symlink = "netstat") + self.collectExtOutput("/bin/netstat -neopa", symlink = "netstat") self.collectExtOutput("/sbin/ip route show table all") self.collectExtOutput("/sbin/ip link") self.collectExtOutput("/sbin/ip address") diff --git a/sos/plugins/process.py b/sos/plugins/process.py index a054d255..75802314 100644 --- a/sos/plugins/process.py +++ b/sos/plugins/process.py @@ -20,11 +20,11 @@ class process(sos.plugintools.PluginBase): """process information """ def setup(self): - self.collectExtOutput("/bin/ps auxwww", root_symlink = "ps") + self.collectExtOutput("/bin/ps auxwww", symlink = "ps") self.collectExtOutput("/bin/ps auxwwwm") self.collectExtOutput("/bin/ps alxwww") - self.collectExtOutput("/usr/bin/pstree", root_symlink = "pstree") - self.collectExtOutput("/usr/sbin/lsof -b +M -n -l", root_symlink = "lsof") + self.collectExtOutput("/usr/bin/pstree", symlink = "pstree") + self.collectExtOutput("/usr/sbin/lsof -b +M -n -l", symlink = "lsof") return def find_mountpoint(s): diff --git a/sos/plugins/rhn.py b/sos/plugins/rhn.py index cd8394b5..cbed6a33 100644 --- a/sos/plugins/rhn.py +++ b/sos/plugins/rhn.py @@ -64,9 +64,9 @@ class rhn(sos.plugintools.PluginBase): self.addCopySpec("/var/log/nocpulse/TSDBLocalQueue/TSDBLocalQueue.log") self.addCopySpec("/root/ssl-build") - self.collectExtOutput("rpm -qa --last", root_symlink = "rpm-manifest") - self.collectExtOutput("/usr/bin/rhn-schema-version", root_symlink = "database-schema-version") - self.collectExtOutput("/usr/bin/rhn-charsets", root_symlink = "database-character-sets") + self.collectExtOutput("rpm -qa --last", symlink = "rpm-manifest") + self.collectExtOutput("/usr/bin/rhn-schema-version", symlink = "database-schema-version") + self.collectExtOutput("/usr/bin/rhn-charsets", symlink = "database-character-sets") if self.satellite: self.addCopySpec("/etc/tnsnames.ora") diff --git a/sos/plugins/rpm.py b/sos/plugins/rpm.py index 55183b25..148f6170 100644 --- a/sos/plugins/rpm.py +++ b/sos/plugins/rpm.py @@ -24,9 +24,9 @@ class rpm(sos.plugintools.PluginBase): self.addCopySpec("/var/log/rpmpkgs") if self.getOption("rpmq"): - self.collectExtOutput("/bin/rpm -qa --qf=\"%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}~~%{INSTALLTIME:date}\n\" --nosignature --nodigest|/bin/awk -F ~~ '{printf \"%-59s %s\\n\",$1,$2}'|sort", root_symlink = "installed-rpms") + self.collectExtOutput("/bin/rpm -qa --qf=\"%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}~~%{INSTALLTIME:date}\n\" --nosignature --nodigest|/bin/awk -F ~~ '{printf \"%-59s %s\\n\",$1,$2}'|sort", symlink = "installed-rpms") if self.getOption("rpmva"): - self.collectExtOutput("/bin/rpm -Va", root_symlink = "rpm-Va", timeout = 3600) + self.collectExtOutput("/bin/rpm -Va", symlink = "rpm-Va", timeout = 3600) return diff --git a/sos/plugins/sar.py b/sos/plugins/sar.py index 5867f10b..042989f1 100644 --- a/sos/plugins/sar.py +++ b/sos/plugins/sar.py @@ -27,7 +27,7 @@ class sar(sos.plugintools.PluginBase): sar_filename = 'sar' + fname[2:4] if sar_filename not in dirList: sar_command = "/bin/sh -c \"LANG=C /usr/bin/sar -A -f /var/log/sa/" + fname + "\"" - self.collectOutputNow(sar_command, sar_filename, root_symlink=sar_filename) + self.collectOutputNow(sar_command, sar_filename, symlink=sar_filename) return def checkenabled(self): diff --git a/sos/plugins/selinux.py b/sos/plugins/selinux.py index 7ca70712..138c62ec 100644 --- a/sos/plugins/selinux.py +++ b/sos/plugins/selinux.py @@ -31,7 +31,7 @@ class selinux(sos.plugintools.PluginBase): def checkenabled(self): # is selinux enabled ? try: - if self.collectOutputNow("/usr/sbin/sestatus", root_symlink = "sestatus").split(":")[1].strip() == "disabled": + if self.collectOutputNow("/usr/sbin/sestatus", symlink = "sestatus").split(":")[1].strip() == "disabled": return False except: pass diff --git a/sos/plugins/startup.py b/sos/plugins/startup.py index 320bcd82..b3ac9204 100644 --- a/sos/plugins/startup.py +++ b/sos/plugins/startup.py @@ -22,7 +22,7 @@ class startup(sos.plugintools.PluginBase): def setup(self): self.addCopySpec("/etc/rc.d") - self.collectExtOutput("/sbin/chkconfig --list", root_symlink = "chkconfig") + self.collectExtOutput("/sbin/chkconfig --list", symlink = "chkconfig") if self.getOption('servicestatus'): self.collectExtOutput("/sbin/service --status-all") self.collectExtOutput("/sbin/runlevel") diff --git a/sos/plugintools.py b/sos/plugintools.py index 42f5f8d7..a6fb330e 100644 --- a/sos/plugintools.py +++ b/sos/plugintools.py @@ -302,7 +302,7 @@ class PluginBase: # ensuring we get at least some logs if flog == files[0] and limit_reached: self.collectExtOutput("tail -c%d %s" % (sizelimit, flog), - "tail_" + os.path.basename(flog)) + "tail_" + os.path.basename(flog), flog[1:]) def addCopySpec(self, copyspec): """ Add a file specification (can be file, dir,or shell glob) to be @@ -324,11 +324,11 @@ class PluginBase: status, shout, runtime = sosGetCommandOutput(prog) return (status, shout, runtime) - def collectExtOutput(self, exe, suggest_filename = None, root_symlink = None, timeout = 300): + def collectExtOutput(self, exe, suggest_filename = None, symlink = None, timeout = 300): """ Run a program and collect the output """ - self.collectProgs.append( (exe, suggest_filename, root_symlink, timeout) ) + self.collectProgs.append( (exe, suggest_filename, symlink, timeout) ) def fileGrep(self, regexp, fname): try: @@ -360,7 +360,7 @@ class PluginBase: return outfn - def collectOutputNow(self, exe, suggest_filename = None, root_symlink = False, timeout = 300): + def collectOutputNow(self, exe, suggest_filename = None, symlink = False, timeout = 300): """ Execute a command and save the output to a file for inclusion in the report """ @@ -385,11 +385,13 @@ class PluginBase: outfd.write(shout+"\n") outfd.close() - if root_symlink: + if symlink: + dst_from_root = outfn[len(self.cInfo['dstroot'])+1:] + target = ("../" * string.count(symlink, "/")) + dst_from_root curdir = os.getcwd() os.chdir(self.cInfo['dstroot']) try: - os.symlink(outfn[len(self.cInfo['dstroot'])+1:], root_symlink.strip("/.")) + os.symlink(target, symlink.strip("/.")) except: pass os.chdir(curdir) |