#!/usr/bin/python
# -*- coding: utf-8 -*-

import os, subprocess
import time
import bench

from datetime import datetime

class gethosts:
    def setoutdir(self, outdir):
	self.outdir = outdir
    
    def getinfo(self):
	return (10, True)
    
    def start(self):
	hosts = file('/etc/hosts', 'r');
	out = file(os.path.join(self.outdir, 'hosts'), 'w')
	out.write(hosts.read())
	
    def poll(self):
	pass
	
    def stop(self):
	pass
	    
    def __str__(self):
	return "<%s>" % (self.__class__.__name__)

cmd = "sleep 40"
benchdir = '/var/tmp/mybench-%s/' % datetime.now().strftime('%Y.%m.%d.%H.%M')
print 'Destination is %s' % benchdir

stats = [bench.statcmd('date', [], 5, False),
	 bench.statcmd('vmstat', ['5']),
	 gethosts()]
bench.run_test(cmd, stats, 'sleep', benchdir)

