Option --ovs is added for ovs-bugtool command to collect
only OpenvSwitch relevant information. To perform
filtering in plugins, a new xml attribute filters="ovs" (optional)
would be required in element 'command','files','directory' in
openvswitch.xml. Value of 'filters' attribute will be compared
with filtering option in load_plugins to get all relevant operation
to collect information. If no "--ovs" option is passed then it will
behave as earlier.
Fixed an issue which occurs in scenario where option '--yestoall'
is not passed and user keeps entering "y" or "n" on prompt.
Plus, trailing whitespaces are fixed. White space before '=' and
after in function def and call is also fixed.
Signed-off-by: Arun Sharma <arun.sharma@calsoftinc.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
post-v1.8.0
------------------------
post-v1.8.0
------------------------
+ - ovs-bugtool: New --ovs option to report only OVS related information.
- New %t and %T log escapes to identify the subprogram within a
cooperating group of processes or threads that emitted a log message.
The default log patterns now include this information.
- New %t and %T log escapes to identify the subprogram within a
cooperating group of processes or threads that emitted a log message.
The default log patterns now include this information.
.IP "\fB\-\-all\fR"
Use all available capabilities.
.
.IP "\fB\-\-all\fR"
Use all available capabilities.
.
+.IP "\fB\-\-ovs\fR"
+Use only Open vSwitch relevant capabilities.
+.
.IP "\fB\-\-capabilities\fR"
List \fBovs\-bugtool\fR capabilities.
.
.IP "\fB\-\-capabilities\fR"
List \fBovs\-bugtool\fR capabilities.
.
def output_ts(x):
output("[%s] %s" % (time.strftime("%x %X %Z"), x))
def output_ts(x):
output("[%s] %s" % (time.strftime("%x %X %Z"), x))
-def cmd_output(cap, args, label = None, filter = None):
+def cmd_output(cap, args, label=None, filter=None):
if cap in entries:
if not label:
if isinstance(args, list):
if cap in entries:
if not label:
if isinstance(args, list):
run_procs(process_lists.values())
run_procs(process_lists.values())
global ANSWER_YES_TO_ALL, SILENT_MODE
global entries, data, dbg, unlimited_data
global ANSWER_YES_TO_ALL, SILENT_MODE
global entries, data, dbg, unlimited_data
+ # Filter flags
+ only_ovs_info = False
+ collect_all_info = True
+
# we need access to privileged files, exit if we are not running as root
if os.getuid() != 0:
print >>sys.stderr, "Error: ovs-bugtool must be run as root"
# we need access to privileged files, exit if we are not running as root
if os.getuid() != 0:
print >>sys.stderr, "Error: ovs-bugtool must be run as root"
(options, params) = getopt.gnu_getopt(
argv, 'sy', ['capabilities', 'silent', 'yestoall', 'entries=',
'output=', 'outfd=', 'outfile=', 'all', 'unlimited',
(options, params) = getopt.gnu_getopt(
argv, 'sy', ['capabilities', 'silent', 'yestoall', 'entries=',
'output=', 'outfd=', 'outfile=', 'all', 'unlimited',
except getopt.GetoptError, opterr:
print >>sys.stderr, opterr
return 2
except getopt.GetoptError, opterr:
print >>sys.stderr, opterr
return 2
dbg = True
ProcOutput.debug = True
dbg = True
ProcOutput.debug = True
+ if k == '--ovs':
+ only_ovs_info = True
+ collect_all_info = False
+
if len(params) != 1:
print >>sys.stderr, "Invalid additional arguments", str(params)
return 2
if len(params) != 1:
print >>sys.stderr, "Invalid additional arguments", str(params)
return 2
for d in disk_list():
cmd_output(CAP_HDPARM_T, [HDPARM, '-tT', '/dev/%s' % d])
for d in disk_list():
cmd_output(CAP_HDPARM_T, [HDPARM, '-tT', '/dev/%s' % d])
- file_output(CAP_KERNEL_INFO, [PROC_VERSION, PROC_MODULES, PROC_DEVICES,
+ file_output(CAP_KERNEL_INFO, [PROC_VERSION, PROC_MODULES, PROC_DEVICES,
PROC_FILESYSTEMS, PROC_CMDLINE])
cmd_output(CAP_KERNEL_INFO, [ZCAT, PROC_CONFIG], label='config')
cmd_output(CAP_KERNEL_INFO, [SYSCTL, '-A'])
PROC_FILESYSTEMS, PROC_CMDLINE])
cmd_output(CAP_KERNEL_INFO, [ZCAT, PROC_CONFIG], label='config')
cmd_output(CAP_KERNEL_INFO, [SYSCTL, '-A'])
cmd_output(CAP_MULTIPATH, [DMSETUP, 'table'])
func_output(CAP_MULTIPATH, 'multipathd_topology', multipathd_topology)
cmd_output(CAP_MULTIPATH, [MPPUTIL, '-a'])
cmd_output(CAP_MULTIPATH, [DMSETUP, 'table'])
func_output(CAP_MULTIPATH, 'multipathd_topology', multipathd_topology)
cmd_output(CAP_MULTIPATH, [MPPUTIL, '-a'])
- if CAP_MULTIPATH in entries:
+ if CAP_MULTIPATH in entries and collect_all_info:
dump_rdac_groups(CAP_MULTIPATH)
tree_output(CAP_NETWORK_CONFIG, SYSCONFIG_NETWORK_SCRIPTS, IFCFG_RE)
dump_rdac_groups(CAP_MULTIPATH)
tree_output(CAP_NETWORK_CONFIG, SYSCONFIG_NETWORK_SCRIPTS, IFCFG_RE)
tree_output(CAP_YUM, APT_SOURCES_LIST_D)
cmd_output(CAP_YUM, [DPKG_QUERY, '-W', '-f=${Package} ${Version} ${Status}\n'], 'dpkg-packages')
tree_output(CAP_YUM, APT_SOURCES_LIST_D)
cmd_output(CAP_YUM, [DPKG_QUERY, '-W', '-f=${Package} ${Version} ${Status}\n'], 'dpkg-packages')
+ # Filter out ovs relevant information if --ovs option passed
+ # else collect all information
+ filters = set()
+ if only_ovs_info:
+ filters.add('ovs')
+ ovs_info_caps = [CAP_NETWORK_STATUS, CAP_SYSTEM_LOGS,
+ CAP_NETWORK_CONFIG]
+ ovs_info_list = ['process-tree']
+ # We cannot use iteritems, since we modify 'data' as we pass through
+ for (k, v) in data.items():
+ cap = v['cap']
+ if 'filename' in v:
+ info = k[0]
+ else:
+ info = k
+ if info not in ovs_info_list and cap not in ovs_info_caps:
+ del data[k]
+
+ if filters:
+ filter = ",".join(filters)
+ else:
+ filter = None
+
+ load_plugins(filter=filter)
# permit the user to filter out data
# permit the user to filter out data
- for k in sorted(data.keys()):
- if not ANSWER_YES_TO_ALL and not yes("Include '%s'? [Y/n]: " % k):
- del data[k]
+ # We cannot use iteritems, since we modify 'data' as we pass through
+ for (k, v) in sorted(data.items()):
+ cap = v['cap']
+ if 'filename' in v:
+ key = k[0]
+ else:
+ key = k
+ if not ANSWER_YES_TO_ALL and not yes("Include '%s'? [Y/n]: " % key):
+ del data[k]
# collect selected data now
output_ts('Running commands to collect data')
# collect selected data now
output_ts('Running commands to collect data')
def multipathd_topology(cap):
def multipathd_topology(cap):
- pipe = Popen([MULTIPATHD, '-k'], bufsize=1, stdin=PIPE,
+ pipe = Popen([MULTIPATHD, '-k'], bufsize=1, stdin=PIPE,
stdout=PIPE, stderr=dev_null)
stdout, stderr = pipe.communicate('show topology')
stdout=PIPE, stderr=dev_null)
stdout, stderr = pipe.communicate('show topology')
group, _ = line.split(None, 1)
cmd_output(cap, [MPPUTIL, '-g', group])
group, _ = line.split(None, 1)
cmd_output(cap, [MPPUTIL, '-g', group])
-def load_plugins(just_capabilities = False):
+def load_plugins(just_capabilities=False, filter=None):
def getText(nodelist):
rc = ""
for node in nodelist:
def getText(nodelist):
rc = ""
for node in nodelist:
rc += node.data
return rc.encode()
rc += node.data
return rc.encode()
- def getBoolAttr(el, attr, default = False):
+ def getBoolAttr(el, attr, default=False):
ret = default
val = el.getAttribute(attr).lower()
if val in ['true', 'false', 'yes', 'no']:
ret = val in ['true', 'yes']
return ret
ret = default
val = el.getAttribute(attr).lower()
if val in ['true', 'false', 'yes', 'no']:
ret = val in ['true', 'yes']
return ret
for dir in [d for d in os.listdir(PLUGIN_DIR) if os.path.isdir(os.path.join(PLUGIN_DIR, d))]:
if not caps.has_key(dir):
if not os.path.exists("%s/%s.xml" % (PLUGIN_DIR, dir)):
for dir in [d for d in os.listdir(PLUGIN_DIR) if os.path.isdir(os.path.join(PLUGIN_DIR, d))]:
if not caps.has_key(dir):
if not os.path.exists("%s/%s.xml" % (PLUGIN_DIR, dir)):
if just_capabilities:
continue
if just_capabilities:
continue
plugdir = os.path.join(PLUGIN_DIR, dir)
for file in [f for f in os.listdir(plugdir) if f.endswith('.xml')]:
xmldoc = parse(os.path.join(plugdir, file))
assert xmldoc.documentElement.tagName == "collect"
for el in xmldoc.documentElement.getElementsByTagName("*"):
plugdir = os.path.join(PLUGIN_DIR, dir)
for file in [f for f in os.listdir(plugdir) if f.endswith('.xml')]:
xmldoc = parse(os.path.join(plugdir, file))
assert xmldoc.documentElement.tagName == "collect"
for el in xmldoc.documentElement.getElementsByTagName("*"):
+ filters_tmp = el.getAttribute("filters")
+ if filters_tmp == '':
+ filters = []
+ else:
+ filters = filters_tmp.split(',')
+ if not(filter is None or filter in filters):
+ continue
if el.tagName == "files":
newest_first = getBoolAttr(el, 'newest_first')
file_output(dir, getText(el.childNodes).split(),
if el.tagName == "files":
newest_first = getBoolAttr(el, 'newest_first')
file_output(dir, getText(el.childNodes).split(),
if pattern == '': pattern = None
negate = getBoolAttr(el, 'negate')
newest_first = getBoolAttr(el, 'newest_first')
if pattern == '': pattern = None
negate = getBoolAttr(el, 'negate')
newest_first = getBoolAttr(el, 'newest_first')
- tree_output(dir, getText(el.childNodes), pattern and re.compile(pattern) or None,
+ tree_output(dir, getText(el.childNodes),
+ pattern and re.compile(pattern) or None,
negate=negate, newest_first=newest_first)
elif el.tagName == "command":
label = el.getAttribute("label")
negate=negate, newest_first=newest_first)
elif el.tagName == "command":
label = el.getAttribute("label")
output ('Writing archive %s successful.' % filename)
if SILENT_MODE:
print filename
output ('Writing archive %s successful.' % filename)
if SILENT_MODE:
print filename
-def size_of_dir(d, pattern = None, negate = False):
+def size_of_dir(d, pattern=None, negate=False):
if os.path.isdir(d):
return size_of_all([os.path.join(d, fn) for fn in os.listdir(d)],
pattern, negate)
if os.path.isdir(d):
return size_of_all([os.path.join(d, fn) for fn in os.listdir(d)],
pattern, negate)
-def size_of_all(files, pattern = None, negate = False):
+def size_of_all(files, pattern=None, negate=False):
return sum([size_of(f, pattern, negate) for f in files])
return sum([size_of(f, pattern, negate) for f in files])
class StringIOmtime(StringIO.StringIO):
class StringIOmtime(StringIO.StringIO):
- def __init__(self, buf = ''):
+ def __init__(self, buf=''):
StringIO.StringIO.__init__(self, buf)
self.mtime = time.time()
StringIO.StringIO.__init__(self, buf)
self.mtime = time.time()
- <command label="tc-class-show">/usr/share/openvswitch/scripts/ovs-bugtool-tc-class-show</command>
- <command label="ovs-vsctl-show">/usr/share/openvswitch/scripts/ovs-bugtool-vsctl-show</command>
- <command label="dump-ovsdb">/usr/share/openvswitch/scripts/ovs-bugtool-ovsdb-dump</command>
- <command label="ovs-appctl-lacp-show">/usr/share/openvswitch/scripts/ovs-bugtool-lacp-show</command>
- <command label="ovs-appctl-cfm-show">/usr/share/openvswitch/scripts/ovs-bugtool-cfm-show</command>
- <command label="ovs-appctl-coverage-show">/usr/share/openvswitch/scripts/ovs-bugtool-coverage-show</command>
- <command label="ovs-appctl-bond-show">/usr/share/openvswitch/scripts/ovs-bugtool-bond-show</command>
- <command label="ovs-appctl-memory-show">/usr/share/openvswitch/scripts/ovs-bugtool-memory-show</command>
+ <command label="tc-class-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-tc-class-show</command>
+ <command label="ovs-vsctl-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-vsctl-show</command>
+ <command label="dump-ovsdb" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-ovsdb-dump</command>
+ <command label="ovs-appctl-lacp-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-lacp-show</command>
+ <command label="ovs-appctl-cfm-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-cfm-show</command>
+ <command label="ovs-appctl-coverage-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-coverage-show</command>
+ <command label="ovs-appctl-bond-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-bond-show</command>
+ <command label="ovs-appctl-memory-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-memory-show</command>
<collect>
<command label="timezone">date --rfc-3339=seconds</command>
<collect>
<command label="timezone">date --rfc-3339=seconds</command>
- <command label="ovs-daemons-ver">/usr/share/openvswitch/scripts/ovs-bugtool-daemons-ver</command>
+ <command label="ovs-daemons-ver" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-daemons-ver</command>
- <directory label="ovsdb-backups" pattern=".*/conf.db.backup[0-9][^/]*$">/etc/openvswitch</directory>
+ <directory label="ovsdb-backups" filters="ovs" pattern=".*/conf.db.backup[0-9][^/]*$">/etc/openvswitch</directory>