Add support for FreeBSD
authorMark Wong <mark@2ndQuadrant.com>
Wed, 31 Jan 2018 22:13:31 +0000 (14:13 -0800)
committerMark Wong <mark@2ndQuadrant.com>
Wed, 31 Jan 2018 22:13:31 +0000 (14:13 -0800)
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
client/utils/misc.py

index b04138dca09755586095513e4a3490233a040c20..90810e65faa44639c046bcebc333c008dc3cdf62 100755 (executable)
@@ -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)
index fa4e54c3b83d3f6cbd51647771c695818a108d82..05a5f8b3d950fcfdac9bb8bc8d0245efeff9ed5b 100644 (file)
@@ -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):