diff options
author | Tomás Touceda <chiiph@leap.se> | 2014-05-16 15:47:24 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2014-05-16 15:47:24 -0300 |
commit | 5cb40a959af827e4eadde1c047664c4f4c0ae01d (patch) | |
tree | b11f91ee018a23e0afd7be8c1bc74e0c34a1e64b /scripts/backends_cpu_usage/log_cpu_usage.py | |
parent | ce22976cc0e203e53799e771aa5e3717d498cc5c (diff) | |
parent | 4375c180b3de4eb84603bf15755ae1f7635804fe (diff) |
Merge branch 'release-0.5.1'0.5.1
Diffstat (limited to 'scripts/backends_cpu_usage/log_cpu_usage.py')
-rwxr-xr-x | scripts/backends_cpu_usage/log_cpu_usage.py | 46 |
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() |