From d55a25ad770dadff04e05149d1efa7e1163c1c21 Mon Sep 17 00:00:00 2001 From: Aleksander Kiryk Date: Tue, 22 Feb 2022 10:02:16 +0100 Subject: [PATCH] Group all g calls in the bottom of the script --- graph.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/graph.py b/graph.py index 430b0ab..4c069eb 100755 --- a/graph.py +++ b/graph.py @@ -135,6 +135,18 @@ except: gnuplot = run_process("gnuplot", stdin=subprocess.PIPE, stdout=subprocess.PIPE) +sdt = datetime.datetime.strptime(START_DATE, '%Y-%m-%d-%H:%M:%S') +edt = datetime.datetime.strptime(END_DATE, '%Y-%m-%d-%H:%M:%S') + +seconds_between = (edt - sdt).total_seconds() +if seconds_between < 100: + seconds_between = 100 + +nsdt = sdt - datetime.timedelta(seconds = (seconds_between * 0.01)) +nedt = edt + datetime.timedelta(seconds = (seconds_between * 0.01)) + +host = socket.gethostname() + g("set ylabel 'cpu % load (user)'") g("set ylabel tc rgb 'white' font 'Courier-New,8'") @@ -159,26 +171,13 @@ g("set rmargin 6") g(f"set terminal {OUTPUT_TYPE} size 1200,800 background '#222222' font 'Courier-New,8'") - g(f"set output 'plot.{OUTPUT_EXT}'") g("set multiplot layout 3,1 title \"\\n\\n\\n\"") -sdt = datetime.datetime.strptime(START_DATE, '%Y-%m-%d-%H:%M:%S') -edt = datetime.datetime.strptime(END_DATE, '%Y-%m-%d-%H:%M:%S') - g(f"set title 'cpu load (average = {AVERAGE_LOAD:.2f} %%)'") g("set title tc rgb 'white' font 'Courier-New,8'") -seconds_between = (edt - sdt).total_seconds() -if seconds_between < 100: - seconds_between = 100 - -nsdt = sdt - datetime.timedelta(seconds = (seconds_between * 0.01)) -nedt = edt + datetime.timedelta(seconds = (seconds_between * 0.01)) - -host = socket.gethostname() - g(f"set xrange ['{nsdt.strftime('%Y-%m-%d-%H:%M:%S')}':'{nedt.strftime('%Y-%m-%d-%H:%M:%S')}']"); g("set label 101 at screen 0.02, screen 0.95 'Running on {/:Bold %s} \@ {/:Bold %s}, {/:Bold %d} threads x {/:Bold %s}, total ram: {/:Bold %.2f GB}, total disk space: {/:Bold %.2f GB}' tc rgb 'white'" % (host, uname, cpus, cpu_name, TOTAL_RAM, TOTAL_FS))