Skip to content

Commit

Permalink
Update the stats-to-csv script for broker and loggers
Browse files Browse the repository at this point in the history
Add support for logger nodes so that the script still works when run
on a logger node.

With the switch to broker, there are no longer any "child" entries in
the stats.log, so the script was not writing any data to the files in
the "logs/stats/www/" directory.  For now, keep support for "child" entries
so that the script works for both old and new stats.log files.
  • Loading branch information
Daniel Thayer committed Sep 7, 2018
1 parent 9455886 commit 4461807
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions bin/stats-to-csv
Expand Up @@ -15,6 +15,7 @@ import sys
# Read the meta.dat file, and extract node names from it.
def readNodes(meta):
manager = ""
loggers = set()
proxies = set()
workers = set()

Expand All @@ -35,10 +36,13 @@ def readNodes(meta):
if m[2] == "proxy":
proxies.add(m[1])

if m[2] == "logger":
loggers.add(m[1])

if m[2] == "manager":
manager = m[1]

return (manager, proxies, workers)
return (manager, loggers, proxies, workers)


# Read the stats.log file, and create/append CSV files for one node.
Expand Down Expand Up @@ -69,13 +73,17 @@ def processNode(stats, wwwdir, node, iface):
return

try:
val = int(entry["parent-cpu"]) + int(entry["child-cpu"])
val = int(entry["parent-cpu"])
if "child-cpu" in entry:
val += int(entry["child-cpu"])
cpu.write("%s,%s\n" % (t, val))
except (ValueError, KeyError):
pass

try:
val = int(entry["parent-vsize"]) + int(entry["child-vsize"])
val = int(entry["parent-vsize"])
if "child-vsize" in entry:
val += int(entry["child-vsize"])
mem.write("%s,%s\n" % (t, val))
except (ValueError, KeyError):
pass
Expand Down Expand Up @@ -151,7 +159,7 @@ def main():
sys.exit(1)

try:
manager, proxies, workers = readNodes(meta)
manager, loggers, proxies, workers = readNodes(meta)
except IOError as err:
print("Error: failed to read file: %s" % err)
sys.exit(1)
Expand All @@ -163,6 +171,9 @@ def main():
for p in proxies:
processNode(stats, wwwdir, p, False)

for l in loggers:
processNode(stats, wwwdir, l, False)

if manager:
processNode(stats, wwwdir, manager, False)
except IOError as err:
Expand Down

0 comments on commit 4461807

Please sign in to comment.