diff options
author | Philip Knirsch <pknirsch@hamburg.stuttgart.redhat.com> | 2009-02-25 11:28:06 +0100 |
---|---|---|
committer | Philip Knirsch <pknirsch@hamburg.stuttgart.redhat.com> | 2009-02-25 11:28:06 +0100 |
commit | 1fa57228447abc46d58bcc377ab373c026ccd008 (patch) | |
tree | 634135e6c1c62729feb2893a38d7b2da0d89784e /tuned.py | |
parent | e393e728bcffd730401780a8fb3d077d952fed78 (diff) | |
download | tuned-1fa57228447abc46d58bcc377ab373c026ccd008.tar.gz tuned-1fa57228447abc46d58bcc377ab373c026ccd008.tar.xz tuned-1fa57228447abc46d58bcc377ab373c026ccd008.zip |
- Add init() methods to each plugin
- Call plugin init() methods during tuned's init()
- Add support for command line parameters
o -c conffile|--config==conffile to specify the location of the config file
o -d to start tuned as a daemon (instead of as normal app)
- Readded the debug output in case tuned isn't started as as daemon
- Fixed initialization of max transfer values for net tuning plugin
Diffstat (limited to 'tuned.py')
-rw-r--r-- | tuned.py | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -2,10 +2,9 @@ import time,os,locale,ConfigParser class Tuned: def __init__(self): + self.interval = 10 self.mp = [] self.tp = [] - self.config = ConfigParser.ConfigParser() - self.config.read('/etc/tuned.conf') def __initplugins__(self, path, module, store): _files = map(lambda v: v[:-3], filter(lambda v: v[-3:] == ".py" and \ @@ -20,26 +19,31 @@ class Tuned: exec _cmd store.append(_plugin) - def init(self, path): + def init(self, path, cfgfile): + self.config = ConfigParser.ConfigParser() + self.config.read(cfgfile) + if config.has_option("main", "interval"): + self.interval = config.getint("main", "interval") + else: + config.set("main", "interval", self.interval) self.__initplugins__(path, "monitorplugins", self.mp) self.__initplugins__(path, "tuningplugins", self.tp) for p in self.mp: - p.config = self.config + p.init(self.config) for p in self.tp: - p.config = self.config + p.init(self.config) def run(self): - #print("Running...") + print("Running...") while True: lh = {} for p in self.mp: lh.update(p.getLoad()) for p in self.tp: p.setTuning(lh) - time.sleep(10) + time.sleep(self.interval) def cleanup(self): - pass - #print("Cleanup...") + print("Cleanup...") tuned = Tuned() |