From 3b6706a13e3281e845c8af671cf48460ad834bdc Mon Sep 17 00:00:00 2001 From: Peter Gielda Date: Thu, 21 Nov 2019 11:38:43 +0100 Subject: [PATCH] Check sar. --- sargraph.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sargraph.py b/sargraph.py index 2552a57..97c912b 100755 --- a/sargraph.py +++ b/sargraph.py @@ -34,19 +34,25 @@ def pid_running(pid): try: p = subprocess.Popen(["gnuplot", "--version"], stdout=subprocess.PIPE) except: - print("Gnuplot not found") + print("Error: Gnuplot not found") sys.exit(1) VERSION_EXPECTED = [5, 2] version = p.stdout.readline().decode().split(" ")[1].split(".") if (int(version[0]) < VERSION_EXPECTED[0]): - print("Gnuplot version too low. Need at least %d.%d found %s.%s" % (VERSION_EXPECTED[0], VERSION_EXPECTED[1], version[0], version[1])) + print("Error: Gnuplot version too low. Need at least %d.%d found %s.%s" % (VERSION_EXPECTED[0], VERSION_EXPECTED[1], version[0], version[1])) sys.exit(1) if (int(version[0]) == VERSION_EXPECTED[0]) and (int(version[1]) < VERSION_EXPECTED[1]): - print("Gnuplot version too low. Need at least %d.%d found %s.%s" % (VERSION_EXPECTED[0], VERSION_EXPECTED[1], version[0], version[1])) + print("Error: Gnuplot version too low. Need at least %d.%d found %s.%s" % (VERSION_EXPECTED[0], VERSION_EXPECTED[1], version[0], version[1])) sys.exit(1) +try: + p = subprocess.Popen(["sar", "-V"], stdout=subprocess.PIPE) +except: + print("Error: sar not found") + sys.exit(1) + if len(sys.argv) > 1: sid = sys.argv[1] cmd = ""