summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorThomas Rueckstiess <thomas@rueckstiess.net>2015-01-06 12:13:40 +1100
committerThomas Rueckstiess <thomas@rueckstiess.net>2015-01-06 16:01:47 +1100
commitfb1b6e58d10a9a5368c1f36f196304177a2de651 (patch)
treef9a1b71fdf6f70ac753b4096ead5d6892434f1ad /tools
parent813d4b82c21ecbc09a49ddc2383386f653bbfacf (diff)
downloadmongo-fb1b6e58d10a9a5368c1f36f196304177a2de651.tar.gz
error msg if template missing. break lines at 80 chars. better help texts.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/wtstats.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/tools/wtstats.py b/tools/wtstats.py
index 4bacc638587..86585547dde 100755
--- a/tools/wtstats.py
+++ b/tools/wtstats.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
#
-# Public Domain 2014-2015 MongoDB, Inc.
-# Public Domain 2008-2014 WiredTiger, Inc.
+# Public Domain 2008-2015 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
@@ -89,22 +88,24 @@ def munge(args, title, values):
import argparse
def main():
- parser = argparse.ArgumentParser(description='Create graphs from WiredTiger statistics.')
+ parser = argparse.ArgumentParser(description='Create graphs from \
+ WiredTiger statistics.')
parser.add_argument('--all', '-A', action='store_true',
- help='generate all series as separate HTML output files by category')
+ help='generate separate html files for each stats group')
parser.add_argument('--clear', action='store_true',
help='WiredTiger stats gathered with clear set')
parser.add_argument('--include', '-I', metavar='regexp',
type=re.compile, action='append',
- help='include series with titles matching the specifed regexp')
+ help='only include series with titles matching regexp')
parser.add_argument('--list', action='store_true',
- help='list the series that would be displayed')
+ help='only list the parsed series, does not create html file')
parser.add_argument('--output', '-o', metavar='file', default='wtstats',
help='HTML output file prefix')
parser.add_argument('--json', action='store_true',
- help='output data series as json format')
+ help='additionally output data series in json format')
parser.add_argument('files', metavar='file', nargs='+',
- help='input files or directories generated by WiredTiger statistics logging')
+ help='input files or directories generated by WiredTiger statistics \
+ logging')
args = parser.parse_args()
# Read the input file(s) into a dictionary of lists.
@@ -196,8 +197,14 @@ def main():
# load template
this_path = os.path.dirname(os.path.realpath(__file__))
srcfile = os.path.join(this_path, 'wtstats.html.template')
- srcfile = open(srcfile)
- contents = srcfile.read()
+ try:
+ srcfile = open(srcfile)
+ contents = srcfile.read()
+ except IOError:
+ print >>sys.stderr, "Cannot find template file 'wtstats.html.\
+ template'. See ./template/README.md for more information."
+ sys.exit(-1)
+
srcfile.close()
# if --json write data to <filename>.json
@@ -209,7 +216,8 @@ def main():
# write output file
dstfile = open(outputname, 'wt')
- replaced_contents = contents.replace('"### INSERT DATA HERE ###"', json.dumps(json_output))
+ replaced_contents = contents.replace('"### INSERT DATA HERE ###"',
+ json.dumps(json_output))
dstfile.write(replaced_contents)
dstfile.close()
print "created %s" % dstfile.name