diff options
author | navid <navid@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2007-11-22 10:40:27 +0000 |
---|---|---|
committer | navid <navid@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2007-11-22 10:40:27 +0000 |
commit | e2ea89dbbe1b1731ba4eda7fbe40ea315594a1c9 (patch) | |
tree | affd667e6f91c207a1c497ad895f336f0f386f59 /src/lib | |
parent | e60df25b9b22ec1bf78d8d95ca7673d559f13333 (diff) | |
download | sos-e2ea89dbbe1b1731ba4eda7fbe40ea315594a1c9.tar.gz |
merged navid-dev back into trunk, see spec file for details
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@457 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/sos/plugins/cluster.py | 10 | ||||
-rw-r--r-- | src/lib/sos/plugins/general.py | 2 | ||||
-rw-r--r-- | src/lib/sos/plugins/kdump.py | 30 | ||||
-rw-r--r-- | src/lib/sos/plugins/kernel.py | 2 | ||||
-rw-r--r-- | src/lib/sos/plugins/systemtap.py | 9 | ||||
-rw-r--r-- | src/lib/sos/plugintools.py | 14 | ||||
-rwxr-xr-x | src/lib/sos/policyredhat.py | 63 |
7 files changed, 111 insertions, 19 deletions
diff --git a/src/lib/sos/plugins/cluster.py b/src/lib/sos/plugins/cluster.py index 1ef4fe2a..b536512d 100644 --- a/src/lib/sos/plugins/cluster.py +++ b/src/lib/sos/plugins/cluster.py @@ -147,6 +147,16 @@ class cluster(sos.plugintools.PluginBase): xml = libxml2.parseFile("/etc/cluster/cluster.conf") xpathContext = xml.xpathNewContext() + # make sure that the node names are valid according to RFC 2181 + for hostname in xpathContext.xpathEval('/cluster/clusternodes/clusternode/@name'): + if not re.match('^[a-zA-Z]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*$', hostname.content): + self.addDiagnose("node name (%s) contains invalid characters" % hostname.content) + + # do not rely on DNS to resolve node names, must have them in /etc/hosts + for hostname in xpathContext.xpathEval('/cluster/clusternodes/clusternode/@name'): + if len(self.fileGrep(r'^.*\W+%s' % hostname.content , "/etc/hosts")) == 0: + self.addDiagnose("node %s is not defined in /etc/hosts" % hostname.content) + # check fencing (warn on no fencing) if len(xpathContext.xpathEval("/cluster/clusternodes/clusternode[not(fence/method/device)]")): if self.has_gfs(): diff --git a/src/lib/sos/plugins/general.py b/src/lib/sos/plugins/general.py index c124c001..434bfdaa 100644 --- a/src/lib/sos/plugins/general.py +++ b/src/lib/sos/plugins/general.py @@ -26,6 +26,8 @@ class general(sos.plugintools.PluginBase): def setup(self): self.addCopySpec("/etc/redhat-release") self.addCopySpec("/etc/fedora-release") + self.addCopySpec("/etc/inittab") + self.addCopySpec("/etc/sos.conf") self.addCopySpec("/etc/sysconfig") self.addCopySpec("/proc/stat") self.addCopySpec("/var/log/dmesg") diff --git a/src/lib/sos/plugins/kdump.py b/src/lib/sos/plugins/kdump.py new file mode 100644 index 00000000..254f15dd --- /dev/null +++ b/src/lib/sos/plugins/kdump.py @@ -0,0 +1,30 @@ +### 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 sos.plugintools +import os + +class kdump(sos.plugintools.PluginBase): + """Kdump related information + """ + def checkenabled(self): + if len(self.fileGrep(".* crashkernel=", "/proc/cmdline")) > 0: + return True + return False + + def setup(self): + self.addCopySpec("/etc/kdump.conf") + self.addCopySpec("/etc/sysconfig/kdump") + return + diff --git a/src/lib/sos/plugins/kernel.py b/src/lib/sos/plugins/kernel.py index 9a662fe7..d7f3e833 100644 --- a/src/lib/sos/plugins/kernel.py +++ b/src/lib/sos/plugins/kernel.py @@ -18,7 +18,7 @@ import commands, os, re class kernel(sos.plugintools.PluginBase): """kernel related information """ - optionList = [("modinfo", 'gathers module information on all modules', 'fast', True), + optionList = [("modinfo", 'gathers information on all kernel modules', 'fast', True), ('sysrq', 'trigger sysrq+[m,p,t] dumps', 'fast', False)] moduleFile = "" taintList = [ diff --git a/src/lib/sos/plugins/systemtap.py b/src/lib/sos/plugins/systemtap.py index b99ce0cf..beab832c 100644 --- a/src/lib/sos/plugins/systemtap.py +++ b/src/lib/sos/plugins/systemtap.py @@ -17,13 +17,18 @@ import sos.plugintools class systemtap(sos.plugintools.PluginBase): - """SystemTap pre-requisites information + """SystemTap information """ + def checkenabled(self): + self.files = [ "/usr/bin/stap" ] + self.packages = [ "systemtap", "systemtap-runtime" ] + return sos.plugintools.PluginBase.checkenabled(self) + def setup(self): # requires systemtap, systemtap-runtime, kernel-devel, # kernel-debuginfo, kernel-debuginfo-common + # FIXME: do not use rpm -qa self.collectExtOutput("/bin/rpm -qa | /bin/egrep -e kernel.*`uname -r` -e systemtap -e elfutils | sort") self.collectExtOutput("/usr/bin/stap -V 2") - self.collectExtOutput("/bin/uname -r") return diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py index 2501c450..3e195b4d 100644 --- a/src/lib/sos/plugintools.py +++ b/src/lib/sos/plugintools.py @@ -35,17 +35,23 @@ import shutil from stat import * from time import time -# RHEL3 doesn't have a logging module +# RHEL3 doesn't have a logging module, activate work-around try: import logging except ImportError: import sos.rhel3_logging logging = sos.rhel3_logging -# RHEL3 doesn't have format_exc -if sys.version_info[0] <= 2 and sys.version_info[1] <= 2: +# python < 2.4 (RHEL3 and RHEL4) doesn't have format_exc, activate work-around +if sys.version_info[0] <= 2 and sys.version_info[1] < 4: def format_exc(): - return "ciao" + import StringIO + + output = StringIO.StringIO() + traceback.print_exc(file = output) + toret = output.getvalue() + output.close() + return toret traceback.format_exc = format_exc diff --git a/src/lib/sos/policyredhat.py b/src/lib/sos/policyredhat.py index 2f65dd39..c8bec998 100755 --- a/src/lib/sos/policyredhat.py +++ b/src/lib/sos/policyredhat.py @@ -102,14 +102,6 @@ class SosPolicy: pass return None - def pkgDictByName(self, name): - # FIXME: what does this do? - pkgName = self.pkgByName(name) - if pkgName and len(pkgName) > len(name): - return pkgName[len(name)+1:].split("-") - else: - return None - def allPkgs(self, ds = None, value = None): # if possible return the cached values try: return self._cache_rpm[ "%s-%s" % (ds,value) ] @@ -260,7 +252,18 @@ class SosPolicy: print _("Encrypting archive...") gpgname = self.report_file + ".gpg" - status, output = commands.getstatusoutput("/usr/bin/gpg --trust-model always --batch --keyring /usr/share/sos/rhsupport.pub --no-default-keyring --compress-level 0 --encrypt --recipient support@redhat.com --output %s %s" % (gpgname,self.report_file)) + + try: + keyring = self.cInfo['config'].get("general", "gpg_keyring") + except: + keyring = "/usr/share/sos/rhsupport.pub" + + try: + recipient = self.cInfo['config'].get("general", "gpg_recipient") + except: + recipient = "support@redhat.com" + + status, output = commands.getstatusoutput("""/usr/bin/gpg --trust-model always --batch --keyring "%s" --no-default-keyring --compress-level 0 --encrypt --recipient "%s" --output "%s" "%s" """ % (keyring, recipient, gpgname, self.report_file)) if status == 0: os.unlink(self.report_file) self.report_file = gpgname @@ -307,13 +310,49 @@ class SosPolicy: except: return False + # read ftp URL from configuration + try: + upload_url = self.cInfo['config'].get("general", "upload_url") + except: + upload_url = "ftp://dropbox.redhat.com/incoming" + + from urlparse import urlparse + url = urlparse(upload_url) + + if url[0] != "ftp": + print _("Cannot upload to specified URL.") + return + + # extract username and password from URL, if present + if url[1].find("@") > 0: + username, host = url[1].split("@", 1) + if username.find(":") > 0: + username, passwd = username.split(":", 1) + else: + passwd = None + else: + username, passwd, host = None, None, url[1] + + # extract port, if present + if host.find(":") > 0: + host, port = host.split(":", 1) + port = int(port) + else: + port = 21 + + path = url[2] + try: from ftplib import FTP upload_name = os.path.basename(self.report_file) - ftp = FTP('dropbox.redhat.com') - ftp.login() - ftp.cwd("/incoming") + ftp = FTP() + ftp.connect(host, port) + if username and passwd: + ftp.login(username, passwd) + else: + ftp.login() + ftp.cwd(path) ftp.set_pasv(True) ftp.storbinary('STOR %s' % upload_name, fp) ftp.quit() |