From d4611000dbc8a44ec7b051d6d4dd47d2c37485c3 Mon Sep 17 00:00:00 2001 From: Mark Wong Date: Wed, 31 Jan 2018 14:13:31 -0800 Subject: [PATCH] Add support for FreeBSD The memory calculations for pgbench will need to be platform specific. Also the system data collection may have to be platform specific. Thus far, just added conditions so that things will run on FreeBSD now. --- client/perffarm-client.py | 5 ++++- client/utils/misc.py | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/client/perffarm-client.py b/client/perffarm-client.py index b04138d..90810e6 100755 --- a/client/perffarm-client.py +++ b/client/perffarm-client.py @@ -38,7 +38,10 @@ if __name__ == '__main__': collectors = MultiCollector() - collectors.register('system', LinuxCollector(OUTPUT_DIR)) + system = os.popen("uname").readlines()[0].split()[0] + if system == 'Linux': + collectors.register('system', LinuxCollector(OUTPUT_DIR)) + pg_collector = PostgresCollector(OUTPUT_DIR, dbname=DATABASE_NAME, bin_path=('%s/bin' % (BUILD_PATH))) collectors.register('postgres', pg_collector) diff --git a/client/utils/misc.py b/client/utils/misc.py index fa4e54c..05a5f8b 100644 --- a/client/utils/misc.py +++ b/client/utils/misc.py @@ -10,7 +10,18 @@ from tempfile import TemporaryFile def available_ram(): 'determine amount of RAM in the system (in megabytes)' - return int(os.popen("free -m").readlines()[1].split()[1]) + system = os.popen("uname").readlines()[0].split()[0] + + if system == 'FreeBSD': + mem = int(os.popen("sysctl hw.physmem").readlines()[0].split()[1]) + mem /= 1024 + mem /= 1024 + elif system == 'Linux': + mem = int(os.popen("free -m").readlines()[1].split()[1]) + else: + mem = 0 + + return mem def run_cmd(args, env=None, cwd=None): -- 2.39.5