• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2Runs vmstat X where X is the interval in seconds
3
4Defaults options:
5job.profilers.add('vmstat', interval=1)
6"""
7import time, os, subprocess
8from autotest_lib.client.bin import profiler
9
10
11class vmstat(profiler.profiler):
12    version = 1
13
14    def initialize(self, interval = 1):
15        self.interval = interval
16
17
18    def start(self, test):
19        cmd = "/usr/bin/vmstat %d" % self.interval
20        logfile = open(os.path.join(test.profdir, "vmstat"), 'w')
21        p = subprocess.Popen(cmd, shell=True, stdout=logfile, \
22                                        stderr=subprocess.STDOUT)
23        self.pid = p.pid
24
25
26    def stop(self, test):
27        os.kill(self.pid, 15)
28
29
30    def report(self, test):
31        return None
32