diff options
author | Ilias Apalodimas <ilias.apalodimas@linaro.org> | 2017-08-29 09:32:36 +0300 |
---|---|---|
committer | Ilias Apalodimas <ilias.apalodimas@linaro.org> | 2017-08-29 09:32:36 +0300 |
commit | 89374defcf95900902340640dd4a83cbe891b81e (patch) | |
tree | 69a792bf6fb8dbb03542ccc532b5172c21abc2fe | |
parent | 55726124c6a78bf882cccbd1c2b5cf2c48917d75 (diff) |
File to process is now passed as the first argument
-rwxr-xr-x | tools/rrd_graphs/rrd-plot.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/rrd_graphs/rrd-plot.py b/tools/rrd_graphs/rrd-plot.py index 0a1d719..9d3c574 100755 --- a/tools/rrd_graphs/rrd-plot.py +++ b/tools/rrd_graphs/rrd-plot.py @@ -1,6 +1,7 @@ #!/usr/bin/python import rrdtool +import sys # create RRD database def create_db(start, end, rrd_db='ts.rrd'): @@ -31,7 +32,7 @@ def create_db(start, end, rrd_db='ts.rrd'): # Update rrd databses with logged data. # data format epoch:avg time between samples:value -def update_db(pkg_log='pkg-gen-stats', rrd_db='ts.rrd'): +def update_db(pkg_log, rrd_db='ts.rrd'): ret = 0 try: with open(pkg_log, 'r') as f: @@ -63,7 +64,7 @@ def plot_db(start, end, output, rrd_db='ts.rrd'): "--vertical-label=PPS", '-w' '1024', '-h', '384', '--lower-limit', '0', - '--x-grid', 'SECOND:15:MINUTE:1:SECOND:10:0:%T', + '--x-grid', 'SECOND:15:MINUTE:1:SECOND:30:0:%T', #GTM:GST:MTM:MST:LTM:LST:LPR:LFM plot_sources) @@ -72,7 +73,7 @@ def plot_db(start, end, output, rrd_db='ts.rrd'): # Open file and get first-last time from epoch # @start: first entry # @end: last entry -def get_tstamps(pkg_log='pkg-gen-stats'): +def get_tstamps(pkg_log): ret = (-1, -1) # FIXME add checks for failures @@ -90,10 +91,15 @@ def get_tstamps(pkg_log='pkg-gen-stats'): return (start, end) def main(): + try: + plot_file = sys.argv[1] + except IndexError: + plot_file = 'pkg-gen-stats' + print("Plot {} data") . format(plot_file) output = 'graph.png' - start, end = get_tstamps() + start, end = get_tstamps(plot_file) create_db(start, end) - update_db() + update_db(plot_file) plot_db(start,end, output) print("Saved {}") . format(output) |