summaryrefslogtreecommitdiff
path: root/scripts/backends_cpu_usage/log_cpu_usage.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2014-04-07 12:40:45 -0300
committerdrebs <drebs@leap.se>2014-04-09 14:44:09 -0300
commit573909b10d77ef3d889d33cfaeb3fdadd0135daf (patch)
tree33c4835a3384be1d9b8b01a6d306168ace536b87 /scripts/backends_cpu_usage/log_cpu_usage.py
parent8b8d9befbe3e60753e73bc7aaf1b8842a1846046 (diff)
Reorganize scripts directory.
Diffstat (limited to 'scripts/backends_cpu_usage/log_cpu_usage.py')
-rwxr-xr-xscripts/backends_cpu_usage/log_cpu_usage.py46
1 files changed, 0 insertions, 46 deletions
diff --git a/scripts/backends_cpu_usage/log_cpu_usage.py b/scripts/backends_cpu_usage/log_cpu_usage.py
deleted file mode 100755
index 2674e1ff..00000000
--- a/scripts/backends_cpu_usage/log_cpu_usage.py
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/python
-
-
-# Get the CPU usage and print to file.
-
-
-import psutil
-import time
-import argparse
-import os
-import threading
-
-
-class LogCpuUsage(threading.Thread):
-
- def __init__(self, fname):
- threading.Thread.__init__(self)
- self._stopped = True
- self._fname = fname
-
- def run(self):
- self._stopped = False
- with open(self._fname, 'w') as f:
- start = time.time()
- while self._stopped is False:
- now = time.time()
- f.write("%f %f\n" % ((now - start), psutil.cpu_percent()))
- time.sleep(0.01)
-
- def stop(self):
- self._stopped = True
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument('file', help='where to save output')
- args = parser.parse_args()
-
- if os.path.isfile(args.file):
- replace = raw_input('File %s exists, replace it (y/N)? ' % args.file)
- if replace.lower() != 'y':
- print 'Bailing out.'
- exit(1)
-
- log_cpu = LogCpuUsage(args.file)
- log_cpu.run()