diff options
author | shnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2007-08-02 14:27:28 +0000 |
---|---|---|
committer | shnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2007-08-02 14:27:28 +0000 |
commit | f21d141f346afce9f0dab6d9ebc246986311a048 (patch) | |
tree | d2fc4d2ffa2ba5ac37fe1914166eec1cc18276b1 /src/lib | |
parent | e3ea9c416a9ec70769aee4f9bdcd3904cf8b49d2 (diff) | |
download | sos-f21d141f346afce9f0dab6d9ebc246986311a048.tar.gz |
Merged navid-dev r306 into the trunk
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@307 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src/lib')
-rwxr-xr-x | src/lib/sos/helpers.py | 12 | ||||
-rw-r--r-- | src/lib/sos/plugins/amd.py | 1 | ||||
-rw-r--r-- | src/lib/sos/plugins/cluster.py | 10 | ||||
-rw-r--r-- | src/lib/sos/plugins/devicemapper.py | 2 | ||||
-rw-r--r-- | src/lib/sos/plugins/hardware.py | 5 | ||||
-rw-r--r-- | src/lib/sos/plugins/kernel.py | 4 | ||||
-rw-r--r-- | src/lib/sos/plugins/networking.py | 10 | ||||
-rw-r--r-- | src/lib/sos/plugins/process.py | 10 | ||||
-rw-r--r-- | src/lib/sos/plugins/sendmail.py | 1 | ||||
-rw-r--r-- | src/lib/sos/plugins/ssh.py | 1 | ||||
-rw-r--r-- | src/lib/sos/plugins/xinetd.py | 9 | ||||
-rw-r--r-- | src/lib/sos/plugins/yum.py | 26 | ||||
-rw-r--r-- | src/lib/sos/plugintools.py | 3 | ||||
-rwxr-xr-x | src/lib/sos/policyredhat.py | 62 |
14 files changed, 93 insertions, 63 deletions
diff --git a/src/lib/sos/helpers.py b/src/lib/sos/helpers.py index dcff1405..bcdee6fb 100755 --- a/src/lib/sos/helpers.py +++ b/src/lib/sos/helpers.py @@ -59,13 +59,15 @@ def makeNonBlocking(afd): def sosGetCommandOutput(command): """ Execute a command and gather stdin, stdout, and return status. - Adapted from Python Cookbook - O'Reilly """ stime = time() - errdata = '' - status,outdata=commands.getstatusoutput(command) - return (status, outdata, time()-stime) - + inpipe, pipe = os.popen4(command, 'r') + inpipe.close() + text = pipe.read() + sts = pipe.close() + if sts is None: sts = 0 + if text[-1:] == '\n': text = text[:-1] + return (sts, text, time()-stime) # FIXME: this needs to be made clean and moved to the plugin tools, so # that it prints nice color output like sysreport if the progress bar diff --git a/src/lib/sos/plugins/amd.py b/src/lib/sos/plugins/amd.py index 174f850b..a8e6ae13 100644 --- a/src/lib/sos/plugins/amd.py +++ b/src/lib/sos/plugins/amd.py @@ -32,6 +32,5 @@ class amd(sos.plugintools.PluginBase): self.collectExtOutput("/bin/rpm -qV am-utils") self.collectExtOutput("/bin/egrep -e 'automount|pid.*nfs' /proc/mounts") self.collectExtOutput("/bin/mount | egrep -e 'automount|pid.*nfs'") - self.collectExtOutput("/sbin/chkconfig --list amd") return diff --git a/src/lib/sos/plugins/cluster.py b/src/lib/sos/plugins/cluster.py index 62315bc6..a996d362 100644 --- a/src/lib/sos/plugins/cluster.py +++ b/src/lib/sos/plugins/cluster.py @@ -54,6 +54,7 @@ class cluster(sos.plugintools.PluginBase): try: rhelver = self.cInfo["policy"].pkgDictByName("redhat-release")[0] except: rhelver = None + # FIXME: we should only run tests specific for the version, now just do them all regardless if rhelver == "4" or True: # check that kernel module packages are installed for # running kernel version @@ -164,7 +165,7 @@ class cluster(sos.plugintools.PluginBase): # check for fs exported via nfs without nfsid attribute if len(xpathContext.xpathEval("/cluster/rm/service//fs[not(@fsid)]/nfsexport")): - self.addDiagnose("one or more nfs file-system doesn't have a fsid attribute set.") + self.addDiagnose("one or more nfs export do not have a fsid attribute set.") # cluster.conf file version and the in-memory cluster configuration version matches status, cluster_version = commands.getstatusoutput("cman_tool status | grep 'Config version'") @@ -207,6 +208,8 @@ class cluster(sos.plugintools.PluginBase): self.collectExtOutput("/usr/bin/openais-cfgtool -s") self.collectExtOutput("/usr/bin/clustat") + self.collectExtOutput("/sbin/ipvsadm -L", root_symlink = "ipvsadm_-L") + if self.isOptionEnabled('gfslockdump'): self.do_gfslockdump() if self.isOptionEnabled('lockdump'): self.do_lockdump() if self.isOptionEnabled('taskdump'): self.do_taskdump() @@ -226,7 +229,10 @@ class cluster(sos.plugintools.PluginBase): self.addCopySpec("/var/log/messages") def do_lockdump(self): - fp = open("/proc/cluster/services","r") + try: + fp = open("/proc/cluster/services","r") + except: + return for line in fp.readlines(): if line[0:14] == "DLM Lock Space": try: diff --git a/src/lib/sos/plugins/devicemapper.py b/src/lib/sos/plugins/devicemapper.py index e517aa3d..a670cae7 100644 --- a/src/lib/sos/plugins/devicemapper.py +++ b/src/lib/sos/plugins/devicemapper.py @@ -22,6 +22,8 @@ class devicemapper(sos.plugintools.PluginBase): self.collectExtOutput("/sbin/dmsetup table") self.collectExtOutput("/sbin/dmsetup status") + self.collectExtOutput("/usr/bin/systool -v -C -b scsi") + self.collectExtOutput("/usr/sbin/vgscan -vvv") self.collectExtOutput("/usr/sbin/vgdisplay -vv", root_symlink = "vgdisplay") self.collectExtOutput("/usr/sbin/pvscan -v") diff --git a/src/lib/sos/plugins/hardware.py b/src/lib/sos/plugins/hardware.py index f8eeda88..dc1d4a2c 100644 --- a/src/lib/sos/plugins/hardware.py +++ b/src/lib/sos/plugins/hardware.py @@ -38,6 +38,11 @@ class hardware(sos.plugintools.PluginBase): self.collectExtOutput("/usr/share/rhn/up2dateclient/hardware.py") self.collectExtOutput("""/bin/echo "lspci" ; /bin/echo ; /sbin/lspci ; /bin/echo ; /bin/echo ; /bin/echo "lspci -nvv" ; /bin/echo ; /sbin/lspci -nvv""", suggest_filename = "lspci", root_symlink = "lspci") + self.collectExtOutput("/usr/sbin/dmidecode", root_symlink = "dmidecode") + + # FIXME: if arch == i386: +# self.collectExtOutput("/usr/sbin/x86info -a") + # FIXME: what is this for? self.collectExtOutput("/bin/dmesg | /bin/grep -e 'e820.' -e 'agp.'") diff --git a/src/lib/sos/plugins/kernel.py b/src/lib/sos/plugins/kernel.py index 9a752c13..aab7d7f5 100644 --- a/src/lib/sos/plugins/kernel.py +++ b/src/lib/sos/plugins/kernel.py @@ -19,7 +19,7 @@ class kernel(sos.plugintools.PluginBase): """kernel related information """ optionList = [("modinfo", 'gathers module information on all modules', 'fast', True), - ('sysrq', 'trigger SysRq+t dumps', 'fast', False)] + ('sysrq', 'trigger sysrq+[m,p,t] dumps', 'fast', False)] moduleFile = "" taintList = [ {'regex':'mvfs*', 'description':'Clearcase module'}, @@ -56,6 +56,7 @@ class kernel(sos.plugintools.PluginBase): runcmd = runcmd + " " + kmod if len(runcmd): self.collectExtOutput("/sbin/modinfo " + runcmd) + self.collectExtOutput("/sbin/sysctl -a") self.collectExtOutput("/sbin/ksyms") self.addCopySpec("/sys/module") self.addCopySpec("/proc/filesystems") @@ -67,7 +68,6 @@ class kernel(sos.plugintools.PluginBase): self.addCopySpec("/etc/conf.modules") self.addCopySpec("/etc/modules.conf") self.addCopySpec("/etc/modprobe.conf") - self.collectExtOutput("/usr/sbin/dmidecode", root_symlink = "dmidecode") self.collectExtOutput("/usr/sbin/dkms status") self.addCopySpec("/proc/cmdline") self.addCopySpec("/proc/driver") diff --git a/src/lib/sos/plugins/networking.py b/src/lib/sos/plugins/networking.py index b7331849..1a450aaa 100644 --- a/src/lib/sos/plugins/networking.py +++ b/src/lib/sos/plugins/networking.py @@ -50,6 +50,7 @@ class networking(sos.plugintools.PluginBase): self.writeTextToCommand(cmd,"IPTables module "+tablename+" not loaded\n") def setup(self): + self.addCopySpec("/proc/net") self.addCopySpec("/etc/nsswitch.conf") self.addCopySpec("/etc/yp.conf") self.addCopySpec("/etc/inetd.conf") @@ -63,13 +64,16 @@ class networking(sos.plugintools.PluginBase): self.collectIPTable("filter") self.collectIPTable("nat") self.collectIPTable("mangle") - self.collectExtOutput("/bin/netstat -nap") + self.collectExtOutput("/bin/netstat -s") + self.collectExtOutput("/bin/netstat -neopa", root_symlink = "netstat") + self.collectExtOutput("/sbin/ip link") + self.collectExtOutput("/sbin/ip address") + self.collectExtOutput("/sbin/ifenslave -a") if ifconfigFile: for eth in self.get_interface_name(ifconfigFile): self.collectExtOutput("/sbin/ethtool "+eth) if self.isOptionEnabled("traceroute"): - # The semicolon prevents the browser from thinking this is a link when viewing the report - self.collectExtOutput("/bin/traceroute rhn.redhat.com;") + self.collectExtOutput("/bin/traceroute -n rhn.redhat.com") return diff --git a/src/lib/sos/plugins/process.py b/src/lib/sos/plugins/process.py index baa185b4..ce4ef227 100644 --- a/src/lib/sos/plugins/process.py +++ b/src/lib/sos/plugins/process.py @@ -21,7 +21,9 @@ class process(sos.plugintools.PluginBase): """process information """ def setup(self): - self.collectExtOutput("/bin/ps auxww", root_symlink = "ps") + self.collectExtOutput("/bin/ps auxwww", root_symlink = "ps") + self.collectExtOutput("/bin/ps auxwwwm") + self.collectExtOutput("/bin/ps alxwww") self.collectExtOutput("/usr/bin/pstree", root_symlink = "pstree") return @@ -38,11 +40,11 @@ class process(sos.plugintools.PluginBase): line = line.split() if line[0] == "D": # keep an eye on the process to see if the stat changes - for inc in range(1,10): + for inc in range(1,5): try: if len(self.fileGrep("^State: D", " /proc/%d/status" % int(line[1]))) == 0: # status is not D, good. let's get out of the loop. - time.sleep(0.1) + time.sleep(0.1 * inc) continue except IOError: # this should never happen... @@ -55,7 +57,7 @@ class process(sos.plugintools.PluginBase): # realpath if len(dpids): - self.addDiagnose("one or more processes are in state D") + self.addDiagnose("one or more processes are in state D (sosreport might hang)") return diff --git a/src/lib/sos/plugins/sendmail.py b/src/lib/sos/plugins/sendmail.py index 79713805..76b40905 100644 --- a/src/lib/sos/plugins/sendmail.py +++ b/src/lib/sos/plugins/sendmail.py @@ -28,6 +28,5 @@ class sendmail(sos.plugintools.PluginBase): def setup(self): self.addCopySpec("/etc/mail/*") self.addCopySpec("/var/log/maillog") - self.collectExtOutput("/sbin/chkconfig --list sendmail") return diff --git a/src/lib/sos/plugins/ssh.py b/src/lib/sos/plugins/ssh.py index 92a4c9e5..6352583b 100644 --- a/src/lib/sos/plugins/ssh.py +++ b/src/lib/sos/plugins/ssh.py @@ -22,6 +22,5 @@ class ssh(sos.plugintools.PluginBase): def setup(self): self.addCopySpec("/etc/ssh/ssh_config") self.addCopySpec("/etc/ssh/sshd_config") - self.collectExtOutput("/sbin/chkconfig --list sshd") return diff --git a/src/lib/sos/plugins/xinetd.py b/src/lib/sos/plugins/xinetd.py index 715c831f..f5292fb5 100644 --- a/src/lib/sos/plugins/xinetd.py +++ b/src/lib/sos/plugins/xinetd.py @@ -15,13 +15,18 @@ ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import sos.plugintools +import os class xinetd(sos.plugintools.PluginBase): """xinetd information """ + def checkenabled(self): + if self.cInfo["policy"].pkgByName("xinetd") or os.path.exists("/etc/xinetd.conf"): + return True + return False + def setup(self): self.addCopySpec("/etc/xinetd.conf") - self.addCopySpec("/etc/xinetd.d/*") - self.collectExtOutput("/sbin/chkconfig --list xinetd") + self.addCopySpec("/etc/xinetd.d") return diff --git a/src/lib/sos/plugins/yum.py b/src/lib/sos/plugins/yum.py index 89102c38..2ba5693f 100644 --- a/src/lib/sos/plugins/yum.py +++ b/src/lib/sos/plugins/yum.py @@ -18,20 +18,24 @@ class yum(sos.plugintools.PluginBase): """yum information """ - def defaultenabled(self): - # enable with -e or -o + optionList = [("yumlist", "list repositories and packages", "slow", False)] + + def checkenabled(self): + if self.cInfo["policy"].pkgByName("yum") or os.path.exists("/etc/yum.conf"): + return True return False def setup(self): - # Pull all yum related information + # Pull all yum related information self.addCopySpec("/etc/yum") - self.addCopySpec("/etc/yum.repos.d") - self.addCopySpec("/etc/yum.conf") - self.addCopySpec("/var/log/yum.log") - - # Get a list of channels the machine is subscribed to. - self.collectExtOutput("/bin/echo \"repo list\" | /usr/bin/yum shell") - # List various information about available packages - self.collectExtOutput("/usr/bin/yum list") + self.addCopySpec("/etc/yum.repos.d") + self.addCopySpec("/etc/yum.conf") + self.addCopySpec("/var/log/yum.log") + + if self.isOptionEnabled("yumlist"): + # Get a list of channels the machine is subscribed to. + self.collectExtOutput("/bin/echo \"repo list\" | /usr/bin/yum shell") + # List various information about available packages + self.collectExtOutput("/usr/bin/yum list") return diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py index f58c8151..8809100f 100644 --- a/src/lib/sos/plugintools.py +++ b/src/lib/sos/plugintools.py @@ -173,7 +173,6 @@ class PluginBase: try: dstslname, abspath = self.__copyFile(srcpath) self.copiedFiles.append({'srcpath':srcpath, 'dstpath':dstslname, 'symlink':"yes", 'pointsto':link}) - self.cInfo['xmlreport'].add_file(srcpath,os.stat(srcpath)) except SystemExit: raise SystemExit except KeyboardInterrupt: @@ -581,7 +580,7 @@ class PluginBase: html = html + "<p>Commands Executed:<br><ul>\n" # convert file name to relative path from our root for cmd in self.executedCommands: - cmdOutRelPath = sosRelPath(self.cInfo['rptdir'], cmd['file']) + cmdOutRelPath = sosRelPath(self.cInfo['rptdir'], self.cInfo['cmddir'] + "/" + cmd['file']) html = html + '<li><a href="%s">%s</a></li>\n' % (cmdOutRelPath, cmd['exe']) html = html + "</ul></p>\n" diff --git a/src/lib/sos/policyredhat.py b/src/lib/sos/policyredhat.py index 69c48e0f..fbcc32c2 100755 --- a/src/lib/sos/policyredhat.py +++ b/src/lib/sos/policyredhat.py @@ -21,10 +21,11 @@ import os import commands import sys import string -import re from tempfile import gettempdir from sos.helpers import * import random +import re +import md5 SOME_PATH = "/tmp/SomePath" @@ -94,15 +95,15 @@ class SosPolicy: return ret def runlevelDefault(self): - inittab=os.path.isfile('/etc/inittab') - if inittab is True: - f=open(inittab,'r') + try: + f=open("/etc/inittab",'r') content=f.read() f.close() reg=re.compile(r"^id:(\d{1}):initdefault:\D",re.MULTILINE) for initlevel in reg.findall(content): return initlevel - else: return 3 + except: + return 3 def kernelVersion(self): return commands.getoutput("/bin/uname -r").strip("\n") @@ -117,26 +118,30 @@ class SosPolicy: name = "-".join(fields[:-3]) return (name, version, release, arch) - def packageResults(self): + def preWork(self): + # this method will be called before the gathering begins + localname = commands.getoutput("/bin/uname -n").split(".")[0] try: - name = raw_input("Please enter your first initial and last name [%s]: " % localname) - name = re.sub(r"[^a-zA-Z.0-9]", "", name) - if len(name) == 0: name = localname + self.reportName = raw_input("Please enter your first initial and last name [%s]: " % localname) + self.reportName = re.sub(r"[^a-zA-Z.0-9]", "", self.reportName) + if len(self.reportName) == 0: + self.reportName = localname - ticketNumber = raw_input("Please enter the case number that you are generating this report for: ") - ticketNumber = re.sub(r"[^0-9]", "", ticketNumber) + self.ticketNumber = raw_input("Please enter the case number that you are generating this report for: ") + self.ticketNumber = re.sub(r"[^0-9]", "", self.ticketNumber) + print except KeyboardInterrupt: - print _("<interrupted>") - print _("Temporary files have been stored in %s") % self.cInfo['dstroot'] print - sys.exit(1) + sys.exit(0) - if len(ticketNumber): - namestr = name + "." + ticketNumber + def packageResults(self): + + if len(self.ticketNumber): + namestr = self.reportName + "." + self.ticketNumber else: - namestr = name + namestr = self.reportName ourtempdir = gettempdir() tarballName = os.path.join(ourtempdir, "sosreport-" + namestr + ".tar.bz2") @@ -148,7 +153,7 @@ class SosPolicy: tarcmd = "/bin/tar -jcf %s %s" % (tarballName, namestr) print - print "Creating compressed tar archive..." + print "Creating compressed archive..." if not os.access(string.split(tarcmd)[0], os.X_OK): print "Unable to create tarball" return @@ -166,17 +171,16 @@ class SosPolicy: os.system("/bin/mv %s %s" % (aliasdir, self.cInfo['dstroot'])) # add last 6 chars from md5sum to file name - status, md5out = commands.getstatusoutput('''/usr/bin/md5sum "%s"''' % tarballName) - if not status and len(md5out): - oldtarballName = tarballName - try: - md5out = md5out.strip().split()[0] - tarballName = os.path.join(ourtempdir, "sosreport-%s-%s.tar.bz2" % (namestr, md5out[-6:]) ) - os.system("/bin/mv %s %s" % (oldtarballName, tarballName) ) - except: - md5out = False - else: - md5out = False + fp = open(tarballName, "r") + md5out = md5.new(fp.read()).hexdigest() + fp.close() + oldtarballName = tarballName + tarballName = os.path.join(ourtempdir, "sosreport-%s-%s.tar.bz2" % (namestr, md5out[-6:]) ) + os.system("/bin/mv %s %s" % (oldtarballName, tarballName) ) + # store md5 to a file + fp = open(tarballName + ".md5", "w") + fp.write(md5out + "\n") + fp.close() sys.stdout.write("\n") print "Your sosreport has been generated and saved in:\n %s" % tarballName |