summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2017-04-13 11:23:01 -0400
committerJonathan Abrahams <jonathan@mongodb.com>2017-04-13 11:23:01 -0400
commit484f61548ce56e1b60c0019470ea46f2f4cfffca (patch)
treeee9b82e14dc5ef277560f091b8eb044105a33b58
parentb5e2615f9cf29942783ed554afeb364052dd83a4 (diff)
downloadmongo-484f61548ce56e1b60c0019470ea46f2f4cfffca.tar.gz
SERVER-28354 Add new option to supply base process name in hang_analyzer
-rwxr-xr-xbuildscripts/hang_analyzer.py71
1 files changed, 45 insertions, 26 deletions
diff --git a/buildscripts/hang_analyzer.py b/buildscripts/hang_analyzer.py
index 816184293d3..04a18f29720 100755
--- a/buildscripts/hang_analyzer.py
+++ b/buildscripts/hang_analyzer.py
@@ -549,6 +549,15 @@ def signal_process(logger, pid, signalnum):
logger.error("Cannot send signal to a process on Windows")
+def pname_match(match_type, pname, interesting_processes):
+ pname = os.path.splitext(pname)[0]
+ for ip in interesting_processes:
+ if (match_type == 'exact' and pname == ip or
+ match_type == 'contains' and ip in pname):
+ return True
+ return False
+
+
# Basic procedure
#
# 1. Get a list of interesting processes
@@ -589,37 +598,46 @@ def main():
process_ids = []
parser = OptionParser(description=__doc__)
+ parser.add_option('-m', '--process-match',
+ dest='process_match',
+ choices=['contains', 'exact'],
+ default='contains',
+ help="Type of match for process names (-p & -g), specify 'contains', or"
+ " 'exact'. Note that the process name match performs the following"
+ " conversions: change all process names to lowecase, strip off the file"
+ " extenstion, like '.exe' on Windows. Default is 'contains'.")
parser.add_option('-p', '--process-names',
- dest='process_names',
- help='Comma separated list of process names to analyze')
+ dest='process_names',
+ help='Comma separated list of process names to analyze')
parser.add_option('-g', '--go-process-names',
- dest='go_process_names',
- help='Comma separated list of go process names to analyze')
+ dest='go_process_names',
+ help='Comma separated list of go process names to analyze')
parser.add_option('-d', '--process-ids',
- dest='process_ids',
- default=None,
- help='Comma separated list of process ids (PID) to analyze, overrides -p & -g')
+ dest='process_ids',
+ default=None,
+ help='Comma separated list of process ids (PID) to analyze, overrides -p &'
+ ' -g')
parser.add_option('-c', '--dump-core',
- dest='dump_core',
- action="store_true",
- default=False,
- help='Dump core file for each analyzed process')
+ dest='dump_core',
+ action="store_true",
+ default=False,
+ help='Dump core file for each analyzed process')
parser.add_option('-s', '--max-core-dumps-size',
- dest='max_core_dumps_size',
- default=10000,
- help='Maximum total size of core dumps to keep in megabytes')
+ dest='max_core_dumps_size',
+ default=10000,
+ help='Maximum total size of core dumps to keep in megabytes')
parser.add_option('-o', '--debugger-output',
- dest='debugger_output',
- action="append",
- choices=['file', 'stdout'],
- default=None,
- help="If 'stdout', then the debugger's output is written to the Python"
- " process's stdout. If 'file', then the debugger's output is written"
- " to a file named debugger_<process>_<pid>.log for each process it"
- " attaches to. This option can be specified multiple times on the"
- " command line to have the debugger's output written to multiple"
- " locations. By default, the debugger's output is written only to the"
- " Python process's stdout.")
+ dest='debugger_output',
+ action="append",
+ choices=['file', 'stdout'],
+ default=None,
+ help="If 'stdout', then the debugger's output is written to the Python"
+ " process's stdout. If 'file', then the debugger's output is written"
+ " to a file named debugger_<process>_<pid>.log for each process it"
+ " attaches to. This option can be specified multiple times on the"
+ " command line to have the debugger's output written to multiple"
+ " locations. By default, the debugger's output is written only to the"
+ " Python process's stdout.")
(options, args) = parser.parse_args()
@@ -663,8 +681,9 @@ def main():
list(missing_pids))
else:
processes = [(pid, pname) for (pid, pname) in all_processes
- if any(pname.find(ip) >= 0 for ip in interesting_processes) and
+ if pname_match(options.process_match, pname, interesting_processes) and
pid != os.getpid()]
+
root_logger.info("Found %d interesting processes %s" % (len(processes), processes))
max_dump_size_bytes = int(options.max_core_dumps_size) * 1024 * 1024