add missing standalone profiler file
Signed-off-by: Martin J. Bligh <mbligh@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1172 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/standalone_profiler.py b/server/standalone_profiler.py
new file mode 100644
index 0000000..53c2dcf
--- /dev/null
+++ b/server/standalone_profiler.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python2.4
+#
+# Copyright 2007 Google Inc. All Rights Reserved.
+
+"""Runs profilers on a machine when no autotest job is running.
+
+This is used to profile a task when the task is running on a machine that is not
+running through autotest.
+"""
+
+__author__ = 'cranger@google.com (Colby Ranger)'
+
+from common import barrier
+
+
+def generate_test(machines, hostname, profilers, timeout_start, timeout_stop,
+ timeout_sync=180):
+ control_file = []
+ for profiler in profilers:
+ control_file.append("job.profilers.add(%s)"
+ % str(profiler)[1:-1]) # Remove parens
+
+ control_file.append("job.run_test('barriertest',%d,%d,%d,'%s','%s',%s)"
+ % (timeout_sync, timeout_start, timeout_stop,
+ hostname, "PROF_MASTER", str(machines)))
+
+ for profiler in profilers:
+ control_file.append("job.profilers.delete('%s')" % profiler[0])
+
+ return "\n".join(control_file)
+
+
+def wait_for_profilers(machines, timeout = 300):
+ sb = barrier.barrier("PROF_MASTER", "sync_profilers",
+ timeout, port=63100)
+ sb.rendevous_servers("PROF_MASTER", *machines)
+
+
+def start_profilers(machines, timeout = 120):
+ sb = barrier.barrier("PROF_MASTER", "start_profilers",
+ timeout, port=63100)
+ sb.rendevous_servers("PROF_MASTER", *machines)
+
+
+def stop_profilers(machines, timeout = 120):
+ sb = barrier.barrier("PROF_MASTER", "stop_profilers",
+ timeout, port=63100)
+ sb.rendevous_servers("PROF_MASTER", *machines)