X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=debian%2Fovs-bugtool;h=65569649a043413e5517503cd74717b04e16fa23;hb=f8cd50a42b8a816204a8955772d4493a0fb12686;hp=11d3acbcb2cc39c187a556cf937b7351b83a889b;hpb=237414f81b9ac64eb812bb9b4e4fe58ef18cffff;p=openvswitch diff --git a/debian/ovs-bugtool b/debian/ovs-bugtool index 11d3acbc..65569649 100755 --- a/debian/ovs-bugtool +++ b/debian/ovs-bugtool @@ -14,7 +14,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Copyright (c) 2005, 2007 XenSource Ltd. -# Copyright (c) 2010, Nicira Networks. +# Copyright (c) 2010, 2011 Nicira Networks. # # To add new entries to the bugtool, you need to: @@ -33,6 +33,9 @@ # or func_output(). # +import warnings +warnings.filterwarnings(action="ignore", category=DeprecationWarning) + import getopt import re import os @@ -64,7 +67,7 @@ OS_RELEASE = platform.release() # Files & directories # -BUG_DIR = "/var/log/openvswitch" +BUG_DIR = "/var/log/ovs-bugtool" PLUGIN_DIR = "/etc/openvswitch/bugtool" GRUB_CONFIG = '/boot/grub/menu.lst' BOOT_KERNEL = '/boot/vmlinuz-' + OS_RELEASE @@ -93,12 +96,14 @@ HOSTS = '/etc/hosts' HOSTS_ALLOW = '/etc/hosts.allow' HOSTS_DENY = '/etc/hosts.deny' DHCP_LEASE_DIR = '/var/lib/dhcp3' -OPENVSWITCH_CORE_DIR = '/var/log/openvswitch/cores' +OPENVSWITCH_LOG_DIR = '/var/log/openvswitch' OPENVSWITCH_DEFAULT_SWITCH = '/etc/default/openvswitch-switch' OPENVSWITCH_DEFAULT_CONTROLLER = '/etc/default/openvswitch-controller' OPENVSWITCH_CONF_DB = '/etc/openvswitch/conf.db' OPENVSWITCH_VSWITCHD_PID = '/var/run/openvswitch/ovs-vswitchd.pid' +COLLECTD_LOGS_DIR = '/var/lib/collectd/rrd' VAR_LOG_DIR = '/var/log/' +VAR_LOG_CORE_DIR = '/var/log/core' X11_LOGS_DIR = VAR_LOG_DIR X11_LOGS_RE = re.compile(r'.*/Xorg\..*$') X11_AUTH_DIR = '/root/' @@ -181,6 +186,7 @@ CAP_XML_ELEMENT = 'capability' CAP_BLOBS = 'blobs' CAP_BOOT_LOADER = 'boot-loader' +CAP_COLLECTD_LOGS = 'collectd-logs' CAP_DISK_INFO = 'disk-info' CAP_FIRSTBOOT = 'firstboot' CAP_HARDWARE_INFO = 'hardware-info' @@ -220,6 +226,8 @@ def cap(key, pii=PII_MAYBE, min_size=-1, max_size=-1, min_time=-1, cap(CAP_BLOBS, PII_NO, max_size=5*MB) cap(CAP_BOOT_LOADER, PII_NO, max_size=3*KB, max_time=5) +cap(CAP_COLLECTD_LOGS, PII_MAYBE, max_size=50*MB, + max_time=5) cap(CAP_DISK_INFO, PII_MAYBE, max_size=25*KB, max_time=20) cap(CAP_FIRSTBOOT, PII_YES, min_size=60*KB, max_size=80*KB) @@ -353,6 +361,7 @@ def main(argv = None): print >>sys.stderr, "Error: ovs-bugtool must be run as root" return 1 + output_file = None output_type = 'tar.bz2' output_fd = -1 @@ -362,7 +371,8 @@ def main(argv = None): try: (options, params) = getopt.gnu_getopt( argv, 'sy', ['capabilities', 'silent', 'yestoall', 'entries=', - 'output=', 'outfd=', 'all', 'unlimited', 'debug']) + 'output=', 'outfd=', 'outfile=', 'all', 'unlimited', + 'debug']) except getopt.GetoptError, opterr: print >>sys.stderr, opterr return 2 @@ -381,7 +391,7 @@ def main(argv = None): return 0 if k == '--output': - if v in ['tar', 'tar.bz2', 'zip']: + if v in ['tar', 'tar.bz2', 'tar.gz', 'zip']: output_type = v else: print >>sys.stderr, "Invalid output format '%s'" % v @@ -409,6 +419,9 @@ def main(argv = None): print >>sys.stderr, "Invalid output file descriptor", output_fd return 2 + if k == '--outfile': + output_file = v + elif k == '--all': entries = caps.keys() elif k == '--unlimited': @@ -425,6 +438,10 @@ def main(argv = None): print >>sys.stderr, "Option '--outfd' only valid with '--output=tar'" return 2 + if output_fd != -1 and output_file is not None: + print >>sys.stderr, "Cannot set both '--outfd' and '--outfile'" + return 2 + if ANSWER_YES_TO_ALL: output("Warning: '--yestoall' argument provided, will not prompt for individual files.") @@ -448,6 +465,7 @@ exclude those logs from the archive. cmd_output(CAP_BOOT_LOADER, [LS, '-lR', '/boot']) cmd_output(CAP_BOOT_LOADER, [MD5SUM, BOOT_KERNEL, BOOT_INITRD], label='vmlinuz-initrd.md5sum') + tree_output(CAP_COLLECTD_LOGS, COLLECTD_LOGS_DIR) cmd_output(CAP_DISK_INFO, [FDISK, '-l']) file_output(CAP_DISK_INFO, [PROC_PARTITIONS, PROC_MOUNTS]) file_output(CAP_DISK_INFO, [FSTAB]) @@ -504,12 +522,11 @@ exclude those logs from the archive. pass cmd_output(CAP_NETWORK_STATUS, [TC, '-s', 'qdisc']) file_output(CAP_NETWORK_STATUS, [PROC_NET_SOFTNET_STAT]) - tree_output(CAP_NETWORK_STATUS, OPENVSWITCH_CORE_DIR) + tree_output(CAP_NETWORK_STATUS, OPENVSWITCH_LOG_DIR) if os.path.exists(OPENVSWITCH_VSWITCHD_PID): cmd_output(CAP_NETWORK_STATUS, [OVS_DPCTL, 'show']) for d in dp_list(): cmd_output(CAP_NETWORK_STATUS, [OVS_OFCTL, 'show', d]) - cmd_output(CAP_NETWORK_STATUS, [OVS_OFCTL, 'status', d]) cmd_output(CAP_NETWORK_STATUS, [OVS_OFCTL, 'dump-flows', d]) cmd_output(CAP_NETWORK_STATUS, [OVS_DPCTL, 'dump-flows', d]) try: @@ -543,6 +560,7 @@ exclude those logs from the archive. tree_output(CAP_X11_LOGS, X11_LOGS_DIR, X11_LOGS_RE) tree_output(CAP_X11_AUTH, X11_AUTH_DIR, X11_AUTH_RE) + tree_output(CAP_SYSTEM_LOGS, VAR_LOG_CORE_DIR) try: @@ -565,19 +583,24 @@ exclude those logs from the archive. data['inventory.xml'] = {'cap': None, 'output': StringIOmtime(make_inventory(data, subdir))} # create archive - if output_fd == -1 and not os.path.exists(BUG_DIR): - try: - os.makedirs(BUG_DIR) - except: - pass + if output_fd == -1: + if output_file is None: + dirname = BUG_DIR + else: + dirname = os.path.dirname(output_file) + if dirname and not os.path.exists(dirname): + try: + os.makedirs(dirname) + except: + pass if output_fd == -1: output_ts('Creating output file') if output_type.startswith('tar'): - make_tar(subdir, output_type, output_fd) + make_tar(subdir, output_type, output_fd, output_file) else: - make_zip(subdir) + make_zip(subdir, output_file) clean_tapdisk_logs() @@ -765,15 +788,20 @@ def load_plugins(just_capabilities = False): if label == '': label = None cmd_output(dir, getText(el.childNodes), label) -def make_tar(subdir, suffix, output_fd): +def make_tar(subdir, suffix, output_fd, output_file): global SILENT_MODE, data mode = 'w' if suffix == 'tar.bz2': mode = 'w:bz2' - filename = "%s/%s.%s" % (BUG_DIR, subdir, suffix) + elif suffix == 'tar.gz': + mode = 'w:gz' if output_fd == -1: + if output_file is None: + filename = "%s/%s.%s" % (BUG_DIR, subdir, suffix) + else: + filename = output_file tf = tarfile.open(filename, mode) else: tf = tarfile.open(None, 'w', os.fdopen(output_fd, 'a')) @@ -808,10 +836,13 @@ def make_tar(subdir, suffix, output_fd): print filename -def make_zip(subdir): +def make_zip(subdir, output_file): global SILENT_MODE, data - filename = "%s/%s.zip" % (BUG_DIR, subdir) + if output_file is None: + filename = "%s/%s.zip" % (BUG_DIR, subdir) + else: + filename = output_file zf = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) try: