From 82e5d550f1f1da442f4844986477c4a7c0bafa55 Mon Sep 17 00:00:00 2001 From: Philip Knirsch Date: Thu, 26 Feb 2009 18:38:39 +0100 Subject: - Added config file option to enable/disable plugins - Switched from ConfigParser to RawConfigParser - Renamed doc/README.txt to doc/DESIGN.txt - Added tuned.conf man page - Updated tuned man page - Updated package descriptions (#487312) - Added documentation for utils scripts (#487312) --- Makefile | 6 ++- README | 56 ++++++++++++++----- doc/DESIGN.txt | 143 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/README.txt | 143 ------------------------------------------------- doc/README.utils | 94 ++++++++++++++++++++++++++++++++ doc/tuned.8 | 21 ++++++-- doc/tuned.conf.5 | 37 +++++++++++++ monitorplugins/disk.py | 5 ++ monitorplugins/net.py | 5 ++ tuned.conf | 14 ++++- tuned.py | 2 +- tuned.spec | 26 +++++++-- tuningplugins/disk.py | 8 ++- tuningplugins/net.py | 9 +++- 14 files changed, 400 insertions(+), 169 deletions(-) create mode 100644 doc/DESIGN.txt delete mode 100644 doc/README.txt create mode 100644 doc/README.utils create mode 100644 doc/tuned.conf.5 diff --git a/Makefile b/Makefile index 8788a76..c26a8d6 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ GITTAG = v$(VERSION) DIRS = doc contrib tuningplugins monitorplugins FILES = tuned tuned.spec Makefile tuned.py tuned.initscript tuned.conf -FILES_doc = doc/README.txt doc/TIPS.txt doc/tuned.8 +FILES_doc = doc/DESIGN.txt doc/README.utils doc/TIPS.txt doc/tuned.8 doc/tuned.conf.5 FILES_contrib = contrib/diskdevstat contrib/netdevstat FILES_tuningplugins = tuningplugins/disk.py tuningplugins/net.py tuningplugins/__init__.py FILES_monitorplugins = monitorplugins/disk.py monitorplugins/net.py monitorplugins/__init__.py @@ -78,9 +78,11 @@ install: mkdir -p $(DESTDIR)/etc/rc.d/init.d install -m 0755 tuned.initscript $(DESTDIR)/etc/rc.d/init.d/tuned - # Install manpage + # Install manpages mkdir -p $(DESTDIR)/usr/share/man/man8 install -m 0644 doc/tuned.8 $(DESTDIR)/usr/share/man/man8 + mkdir -p $(DESTDIR)/usr/share/man/man5 + install -m 0644 doc/tuned.conf.5 $(DESTDIR)/usr/share/man/man5 changelog: git-log > ChangeLog diff --git a/README b/README index 954d73c..1e3cb81 100644 --- a/README +++ b/README @@ -19,21 +19,51 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -SYNOPSIS - tuned [options] +How to use +---------- -DESCRIPTION - tuned is a dynamic adaptive system tuning daemon that tunes system settings dynamically depending on usage. +After installing the package you simply need to start the tuned +service either with system-config-services or from the +commandline in a rootshell via: -OPTIONS - -d, --daemon - This options starts tuned as a daemon as opposed to in the foreground without forking at startup. + service tuned start - -c, --conffile="conffile" - Specify the name and path of the configuration file, default is /etc/tuned.conf. +You can also automatically start it during system startup by +switching it on via chkconfig: -BUGS - There are no known bugs. To file bug reports, see AUTHORS below. + chkconfig tuned on -AUTHOR - Written by Phil Knirsch . +After that the daemon will run automatically and monitor the +usage of various system components. Based on that information +components will then be put into lower or higher power saving +modes to adapt to the current usage. Currently only ethernet +network and and ATA harddisk devices are implemented. + +The config file /etc/tuned.conf contains several sections in +INI style. There is always a "main" section which controls +overall options of the daemon. Currently only 1 option +is available: + +interval: Interval for monitoring and tuning in seconds. + Default is 10. + +Each monitoring and tuning plugin has an own section then. +Currently only 1 option for plugins is available: + +enabled: Enabled or disable the plugin. Default is True. + Any other value disables it. + +WARNING: At the moment there is a small incompatibility with +tuned and NetworkManager which will results in connectivity +loss if you are using tuned and your network devices are +controlled by NetworkManager. This will be fixed in a future +version of tuned and NetworkManager. At the moment there +are two workarounds: + +1) Don't use NetworkManager for your Ethernet devices but +configure them with system-config-network and enable the +network service. +2) Disabled the network tuning in tuned by editing +/etc/tuned.conf and uncomment the +# enabled=False +line in the NetTuning section. diff --git a/doc/DESIGN.txt b/doc/DESIGN.txt new file mode 100644 index 0000000..40a1d9f --- /dev/null +++ b/doc/DESIGN.txt @@ -0,0 +1,143 @@ +Automatic system tuning daemon: tuned +===================================== + +Concept: +-------- + +- Monitoring plugins for different sources (cpu, disk, network, sound, memory) +- Each monitoring plugin has a getLoad() method that returns a value between 0 - 100 +- Tuning plugins for different targets (cpu, disk, network, sound, + memory etc) and modes (power or performance) +- Each plugin can set various weights for any monitoring source (0 - 100) +- Each tuning plugin has a setTuning(load) method +- Tuning will be based on accumulated load*weight for each target + + + +Diagram: +-------- + + [Mon-P] [Mon-P] [Mon-P] + \ | / + \ | / + \ | / + \ | / + \ | / + [tuned] + / | \ + / | \ + / | \ + / | \ + / | \ + [Tune-P] [Tune-P] [Tune-P] + + + +tuned: +------- + +- Is the main interface and aggregator +- Acts as a "middleware" +- Only general functionality. Specific hw/mon functionality only in plugins +- Has a list of all mon and pm plugins +- Monitoring interval is configurable (1 wakeup per interval to reduce # of + wakeups) +- Weights for each Mon can be set for each Tune plugin +- Default weight is 0 +- Aggreated load: mon-p.getLoad() * tune-p.weights[mon-p] / 100. If all weights + together are 100 then this will be a balanced and normalized load +- Accumulated weights per tune plugin can be > 100 or < 100. Need to decide + whether to automatically normalize it or not +/* - Tuning aggressivness can be specified from 0 to 100. 0 == no PM, 100 means + always fully tune even under full load. Configurable globally for all tuning + plugins and/or individually */ +- Tuning modes should follow the system/user settings for power management of + the currently running GUI (e.g. presentation mode etc) +- all fooLoad() methods always return a hash like this: {cat -> {devname -> {subcat = load}}} + to support multiple devices per monitor (e.g. disks, network cards) +- Optional parameters for fooLoad() calls: category, subcategory and devname +- Each plugin can be completely disabled. +- External interfaces to allow requests for monitoring applications + + +Monitor plugins: +---------------- + +- Monitor plugins can be based on any source. E.g. collectd or stap scripts +- Each plugins needs to register to tuned via registerMonitorPlugin() +- Each plugins has it's own configuration. Only external interface to tuned + is getLoad() (which returns a list of tuples, see tuned) +- Each plugin needs to be in a specific category +- Examples of categories that can be monitored: + o CPU + o Disk IO + o Network IO + o Memory IO + o USB + o Graphics + o External input (keyboard/mouse) +- Subcategories possible: + o Input + o Output + o Blocksize +- Should avoid disk/network io to prevent unecessary wakeups + + +Tuning plugins: +--------------- + +- Tuning plugins will be HW specific +- Each plugins needs to register to tuned via registerTuningPlugin() +- Blacklists for know problems with HW +- There are 2 types of tuning plugins: + o Power + o Performance +- Each plugin has to define it's own policy for handling the different + levels of aggregated load +- Each plugin has an interface called setTuning(load) where load is the aggreated + load for that tuning plugin modified by the specific or overall level of + tuning aggressiveness +- Several levels of aggressiveness: none, low, medium, high, max +- Parts that can be tuned: + o CPU + o Disk IO + o Network IO + o Memory IO + o USB + o Graphics + o External input (keyboard/mouse) + + +Example: +-------- + +monitoring plugin for disk io: Montiors either via /proc or other means the IO +for all disks in the system. + +getLoad() returns something like: {"DISK" : {"sda" : {"READ" : 0.24, "WRITE" : +0.01, "SIZE" : 0.31}}} + +This means that sda would be at 24% of it's known peak load in regard to +reads, at 1% in regard to writes and at 31% in regard to blocksizes. + +Based on that information a tuning plugin for disk io could now decide to do +the following: + +load = tuned.getLoad("DISK") +for devnames in load["DISK"].keys(): + devnode = load["DISK"][devname] + # Spin down after 30s and max powersave if device isn't in use + if (devnode["WRITE"] == 0.0 and devnode["READ"] == 0.0) { + hdparm -S5 /dev/devname + hdparm -B1 /dev/devname + # If no write and little reads: Allow drive to spin down after 5m + # and max powersave. + } elseif (devnode["WRITE"] == 0.0 and devnode["READ"] <= 0.05) { + hdparm -S60 /dev/devname + hdparm -B1 /dev/devname + # If write are done or more reads don't allow disk to spindown + # and raise powersave mode to medium range + } else { + hdparm -S0 /dev/devname + hdparm -B128 /dev/devname + } diff --git a/doc/README.txt b/doc/README.txt deleted file mode 100644 index 40a1d9f..0000000 --- a/doc/README.txt +++ /dev/null @@ -1,143 +0,0 @@ -Automatic system tuning daemon: tuned -===================================== - -Concept: --------- - -- Monitoring plugins for different sources (cpu, disk, network, sound, memory) -- Each monitoring plugin has a getLoad() method that returns a value between 0 - 100 -- Tuning plugins for different targets (cpu, disk, network, sound, - memory etc) and modes (power or performance) -- Each plugin can set various weights for any monitoring source (0 - 100) -- Each tuning plugin has a setTuning(load) method -- Tuning will be based on accumulated load*weight for each target - - - -Diagram: --------- - - [Mon-P] [Mon-P] [Mon-P] - \ | / - \ | / - \ | / - \ | / - \ | / - [tuned] - / | \ - / | \ - / | \ - / | \ - / | \ - [Tune-P] [Tune-P] [Tune-P] - - - -tuned: -------- - -- Is the main interface and aggregator -- Acts as a "middleware" -- Only general functionality. Specific hw/mon functionality only in plugins -- Has a list of all mon and pm plugins -- Monitoring interval is configurable (1 wakeup per interval to reduce # of - wakeups) -- Weights for each Mon can be set for each Tune plugin -- Default weight is 0 -- Aggreated load: mon-p.getLoad() * tune-p.weights[mon-p] / 100. If all weights - together are 100 then this will be a balanced and normalized load -- Accumulated weights per tune plugin can be > 100 or < 100. Need to decide - whether to automatically normalize it or not -/* - Tuning aggressivness can be specified from 0 to 100. 0 == no PM, 100 means - always fully tune even under full load. Configurable globally for all tuning - plugins and/or individually */ -- Tuning modes should follow the system/user settings for power management of - the currently running GUI (e.g. presentation mode etc) -- all fooLoad() methods always return a hash like this: {cat -> {devname -> {subcat = load}}} - to support multiple devices per monitor (e.g. disks, network cards) -- Optional parameters for fooLoad() calls: category, subcategory and devname -- Each plugin can be completely disabled. -- External interfaces to allow requests for monitoring applications - - -Monitor plugins: ----------------- - -- Monitor plugins can be based on any source. E.g. collectd or stap scripts -- Each plugins needs to register to tuned via registerMonitorPlugin() -- Each plugins has it's own configuration. Only external interface to tuned - is getLoad() (which returns a list of tuples, see tuned) -- Each plugin needs to be in a specific category -- Examples of categories that can be monitored: - o CPU - o Disk IO - o Network IO - o Memory IO - o USB - o Graphics - o External input (keyboard/mouse) -- Subcategories possible: - o Input - o Output - o Blocksize -- Should avoid disk/network io to prevent unecessary wakeups - - -Tuning plugins: ---------------- - -- Tuning plugins will be HW specific -- Each plugins needs to register to tuned via registerTuningPlugin() -- Blacklists for know problems with HW -- There are 2 types of tuning plugins: - o Power - o Performance -- Each plugin has to define it's own policy for handling the different - levels of aggregated load -- Each plugin has an interface called setTuning(load) where load is the aggreated - load for that tuning plugin modified by the specific or overall level of - tuning aggressiveness -- Several levels of aggressiveness: none, low, medium, high, max -- Parts that can be tuned: - o CPU - o Disk IO - o Network IO - o Memory IO - o USB - o Graphics - o External input (keyboard/mouse) - - -Example: --------- - -monitoring plugin for disk io: Montiors either via /proc or other means the IO -for all disks in the system. - -getLoad() returns something like: {"DISK" : {"sda" : {"READ" : 0.24, "WRITE" : -0.01, "SIZE" : 0.31}}} - -This means that sda would be at 24% of it's known peak load in regard to -reads, at 1% in regard to writes and at 31% in regard to blocksizes. - -Based on that information a tuning plugin for disk io could now decide to do -the following: - -load = tuned.getLoad("DISK") -for devnames in load["DISK"].keys(): - devnode = load["DISK"][devname] - # Spin down after 30s and max powersave if device isn't in use - if (devnode["WRITE"] == 0.0 and devnode["READ"] == 0.0) { - hdparm -S5 /dev/devname - hdparm -B1 /dev/devname - # If no write and little reads: Allow drive to spin down after 5m - # and max powersave. - } elseif (devnode["WRITE"] == 0.0 and devnode["READ"] <= 0.05) { - hdparm -S60 /dev/devname - hdparm -B1 /dev/devname - # If write are done or more reads don't allow disk to spindown - # and raise powersave mode to medium range - } else { - hdparm -S0 /dev/devname - hdparm -B128 /dev/devname - } diff --git a/doc/README.utils b/doc/README.utils new file mode 100644 index 0000000..66f9937 --- /dev/null +++ b/doc/README.utils @@ -0,0 +1,94 @@ +Systemtap disk and network statistic monitoring tools +===================================================== + +The netdevstat and diskdevstat are 2 systemtap tools that allow the user to +collect detailed information about network and disk aktivity of all +applications running on a system. These 2 tools were insipred by powertop, +which shows the wakeups of applications per second. + +The basic idea is to collect statistic about the running applications in a +form that allows a user to identify applications that behave power +inefficient, meaning instead of doing fewer and bigger IO operations they +do more and smaller ones. Current monitoring tools typically only show +the transfer speeds which isn't very meaningful in that context. + +To run them you need to have systemtap and kernel-debuginfo installed. +If both are installed a simple + + netdevstat + +or + + diskdevstat + +will start the scripts. There are no parameters or options for them. The +output will look similar to top and/or powertop. Here a sample output of +a longer diskdevstat run on a Fedora 10 system running KDE 4.2: + + + PID UID DEV WRITE_CNT WRITE_MIN WRITE_MAX WRITE_AVG READ_CNT READ_MIN READ_MAX READ_AVG COMMAND + 2789 2903 sda1 854 0.000 120.000 39.836 0 0.000 0.000 0.000 plasma +15494 0 sda1 0 0.000 0.000 0.000 758 0.000 0.012 0.000 0logwatch +15520 0 sda1 0 0.000 0.000 0.000 140 0.000 0.009 0.000 perl +15549 0 sda1 0 0.000 0.000 0.000 140 0.000 0.009 0.000 perl +15585 0 sda1 0 0.000 0.000 0.000 108 0.001 0.002 0.000 perl + 2573 0 sda1 63 0.033 3600.015 515.226 0 0.000 0.000 0.000 auditd +15429 0 sda1 0 0.000 0.000 0.000 62 0.009 0.009 0.000 crond +15379 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond +15473 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond +15415 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond +15433 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond +15425 0 sda1 0 0.000 0.000 0.000 62 0.007 0.007 0.000 crond +15375 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond +15477 0 sda1 0 0.000 0.000 0.000 62 0.007 0.007 0.000 crond +15469 0 sda1 0 0.000 0.000 0.000 62 0.007 0.007 0.000 crond +15419 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond +15481 0 sda1 0 0.000 0.000 0.000 61 0.000 0.001 0.000 crond +15355 0 sda1 0 0.000 0.000 0.000 37 0.000 0.014 0.001 laptop_mode + 2153 0 sda1 26 0.003 3600.029 1290.730 0 0.000 0.000 0.000 rsyslogd +15575 0 sda1 0 0.000 0.000 0.000 16 0.000 0.000 0.000 cat +15581 0 sda1 0 0.000 0.000 0.000 12 0.001 0.002 0.000 perl +15582 0 sda1 0 0.000 0.000 0.000 12 0.001 0.002 0.000 perl +15579 0 sda1 0 0.000 0.000 0.000 12 0.000 0.001 0.000 perl +15580 0 sda1 0 0.000 0.000 0.000 12 0.001 0.001 0.000 perl +15354 0 sda1 0 0.000 0.000 0.000 12 0.000 0.170 0.014 sh +15584 0 sda1 0 0.000 0.000 0.000 12 0.001 0.002 0.000 perl +15548 0 sda1 0 0.000 0.000 0.000 12 0.001 0.014 0.001 perl +15577 0 sda1 0 0.000 0.000 0.000 12 0.001 0.003 0.000 perl +15519 0 sda1 0 0.000 0.000 0.000 12 0.001 0.005 0.000 perl +15578 0 sda1 0 0.000 0.000 0.000 12 0.001 0.001 0.000 perl +15583 0 sda1 0 0.000 0.000 0.000 12 0.001 0.001 0.000 perl +15547 0 sda1 0 0.000 0.000 0.000 11 0.000 0.002 0.000 perl +15576 0 sda1 0 0.000 0.000 0.000 11 0.001 0.001 0.000 perl +15518 0 sda1 0 0.000 0.000 0.000 11 0.000 0.001 0.000 perl +15354 0 sda1 0 0.000 0.000 0.000 10 0.053 0.053 0.005 lm_lid.sh + + +Here a quick explanation of each column: + +PID: Process ID of the application +UID: User ID under which the applications is running +DEV: Device on which the IO took place +WRITE_CNT: Total number of write operations +WRITE_MIN: Lowest time in seconds for 2 consecutive writes +WRITE_MAX: Largest time in seconds for 2 consecutive writes +WRITE_AVG: Average time in seconds for 2 consecutive writes +READ_CNT: Total number of read operations +READ_MIN: Lowest time in seconds for 2 consecutive reads +READ_MAX: Largest time in seconds for 2 consecutive reads +READ_AVG: Average time in seconds for 2 consecutive reads +COMMAND: Name of the process + +In this example 3 very obvious applications stand out: + + PID UID DEV WRITE_CNT WRITE_MIN WRITE_MAX WRITE_AVG READ_CNT READ_MIN READ_MAX READ_AVG COMMAND + 2789 2903 sda1 854 0.000 120.000 39.836 0 0.000 0.000 0.000 plasma + 2573 0 sda1 63 0.033 3600.015 515.226 0 0.000 0.000 0.000 auditd + 2153 0 sda1 26 0.003 3600.029 1290.730 0 0.000 0.000 0.000 rsyslogd + +Those are the 3 applications that have a WRITE_CNT > 0, meaning they performed +some form of write during the measurement. Of those, plasma was the worst +offender by a large amount. For one in total number of writes and of course +the average time between writes was also the lowest. This would be the best +candidate to investigate if you're concerned about power inefficient +applications. diff --git a/doc/tuned.8 b/doc/tuned.8 index 85b1209..abd1f6c 100644 --- a/doc/tuned.8 +++ b/doc/tuned.8 @@ -1,4 +1,4 @@ -.TH tuned 8 "25 Feb 2009" +.TH "tuned" "8" "25 Feb 2009" "Phil Knirsch" "adaptive system tuning daemon" .SH NAME tuned \- dynamic adaptive system tuning daemon .SH SYNOPSIS @@ -6,7 +6,10 @@ tuned \- dynamic adaptive system tuning daemon .SH DESCRIPTION \fBtuned\fR is a dynamic adaptive system tuning daemon that tunes system settings dynamically depending on -usage. +usage. It does so by monitoring the usage of several system components +periodically. Based on that information components will then be put into +lower or higher power saving modes to adapt to the current usage. Currently +only ethernet network and ATA harddisk devices are implemented. .SH OPTIONS .TP 12 .BI \-d "\fR, \fP" \--daemon @@ -16,7 +19,19 @@ in the foreground without forking at startup. .BI \-c "\fR, \fP" \--conffile=" conffile" Specify the name and path of the configuration file, default is \fB/etc/tuned.conf\fR. .SH BUGS -There are no known bugs. To file bug reports, see \fBAUTHORS\fP below. +If you are using tuned together with NetworkManager at the moment NetworkManager +will completely stop and start a managed device when tuned switches power +saving levels. This happens because the network device will loose it's physical +link for a very short time when it performs a power saving switch and +NetworkManager can not distinguish this from a connectivity loss. This will be +resolved in future versions of tuned and NM where NM will gain the mechanism to +switch speeds for network devices. +.SH "FILES" +.nf +/etc/tuned.conf +.SH "SEE ALSO" +.LP +tuned.conf(5) .SH AUTHOR Written by Phil Knirsch . .SH REPORTING BUGS diff --git a/doc/tuned.conf.5 b/doc/tuned.conf.5 new file mode 100644 index 0000000..fea5655 --- /dev/null +++ b/doc/tuned.conf.5 @@ -0,0 +1,37 @@ +.TH "tuned.conf" "5" "26 Feb 2009" "Phil Knirsch" "tuned configuration file" +.SH "NAME" +.LP +\fBtuned.conf\fR \- Configuration file for \fBtuned(8)\fR. +.SH "DESCRIPTION" +.LP +The tuned configuration file is by default found at \fB/etc/tuned.conf\fR. +.SH "PARAMETERS" +.LP +The tuned.conf file must always contain a [main] section. The main section +defines general parameters for the daemon. Each plugin may have a +section with plugin specific parameters. +.SH "[main] OPTIONS" +.LP +The [main] section must exist for tuned. It contains the following +options: + +.IP \fBinterval\fR +Interval for monitoring and tuning in seconds. The default is 10. + +.SH "[plugin] OPTIONS" +.LP +Each plugin can have an individual section with the name of the plugin as +the section name. All plugins support at least the following options: + +.IP \fBenabled\fR +Enabled or disable the plugin. Default is True. Any other value disables it. +.SH "FILES" +.nf +/etc/tuned.conf +.SH "SEE ALSO" +.LP +tuned(8) +.SH AUTHOR +Written by Phil Knirsch . +.SH REPORTING BUGS +Report bugs to . diff --git a/monitorplugins/disk.py b/monitorplugins/disk.py index 6167c84..2b58220 100644 --- a/monitorplugins/disk.py +++ b/monitorplugins/disk.py @@ -21,6 +21,7 @@ import os class DiskMonitor: def __init__(self): self.devices = {} + self.enabled = True dnames = os.listdir("/sys/block/") for d in dnames: try: @@ -58,11 +59,15 @@ class DiskMonitor: def init(self, config): self.config = config + if self.config.has_option("DiskMonitor", "enabled"): + self.enabled = (self.config.get("DiskMonitor", "enabled") == "True") def cleanup(self): pass def getLoad(self): + if not self.enabled: + return self.__update__() ret = {} ret["DISK"] = {} diff --git a/monitorplugins/net.py b/monitorplugins/net.py index bf806f7..6051b5c 100644 --- a/monitorplugins/net.py +++ b/monitorplugins/net.py @@ -21,6 +21,7 @@ import os class NetMonitor: def __init__(self): self.devices = {} + self.enabled = True devs = open("/proc/net/dev").readlines() for l in devs: l = l.replace(":", " ") @@ -64,6 +65,8 @@ class NetMonitor: def init(self, config): self.config = config + if self.config.has_option("NetMonitor", "enabled"): + self.enabled = (self.config.get("NetMonitor", "enabled") == "True") interval = self.config.getint("main", "interval") # Assume 1gbit interfaces for now. FIXME: Need clean way to figure out max interface speed for d in self.devices.keys(): @@ -73,6 +76,8 @@ class NetMonitor: pass def getLoad(self): + if not self.enabled: + return self.__update__() ret = {} ret["NET"] = {} diff --git a/tuned.conf b/tuned.conf index 793d81e..96f8b89 100644 --- a/tuned.conf +++ b/tuned.conf @@ -4,24 +4,36 @@ [main] # Interval for monitoring and tuning. Default is 10s. -interval=10 +# interval=10 # # Disk monitoring section # [DiskMonitor] +# Enabled or disable the plugin. Default is True. Any other value +# disables it. +# enabled=False # # Disk tuning section # [DiskTuning] +# Enabled or disable the plugin. Default is True. Any other value +# disables it. +# enabled=False # # Net monitoring section # [NetMonitor] +# Enabled or disable the plugin. Default is True. Any other value +# disables it. +# enabled=False # # Net tuning section # [NetTuning] +# Enabled or disable the plugin. Default is True. Any other value +# disables it. +# enabled=False diff --git a/tuned.py b/tuned.py index 773359a..cf12152 100644 --- a/tuned.py +++ b/tuned.py @@ -38,7 +38,7 @@ class Tuned: store.append(_plugin) def init(self, path, cfgfile): - self.config = ConfigParser.ConfigParser() + self.config = ConfigParser.RawConfigParser() self.config.read(cfgfile) if self.config.has_option("main", "interval"): self.interval = self.config.getint("main", "interval") diff --git a/tuned.spec b/tuned.spec index d8b8728..72cda35 100644 --- a/tuned.spec +++ b/tuned.spec @@ -1,6 +1,6 @@ Summary: A dynamic adaptive system tuning daemon Name: tuned -Version: 0.1.1 +Version: 0.1.2 Release: 1%{?dist} License: GPLv2+ Group: System Environment/Daemons @@ -21,15 +21,22 @@ BuildArch: noarch %description The tuned package contains a daemon that tunes system settings dynamically. +It does so by monitoring the usage of several system components periodically. +Based on that information components will then be put into lower or higher +power saving modes to adapt to the current usage. Currently only ethernet +network and ATA harddisk devices are implemented. %package utils -Summary: Disk and net monitoring systemtap scripts +Summary: Disk and net statistic monitoring systemtap scripts Requires: systemtap kernel-debuginfo Group: Applications/System %description utils The tuned-utils package contains several systemtap scripts to allow detailed -manual monitoring of the system. +manual monitoring of the system. Instead of the typical IO/sec it collects +minimal, maximal and average time between operations to be able to +identify applications that behave power inefficient (many small operations +instead of fewer large ones). %prep %setup -q @@ -59,20 +66,31 @@ fi %files %defattr(-,root,root,-) -%doc AUTHORS ChangeLog COPYING INSTALL NEWS README doc/README.txt doc/TIPS.txt +%doc AUTHORS ChangeLog COPYING INSTALL NEWS README doc/DESIGN.txt doc/TIPS.txt %{_initddir}/tuned %config(noreplace) %{_sysconfdir}/tuned.conf %{_sbindir}/tuned %{_datadir}/tuned +%{_mandir}/man5/* %{_mandir}/man8/* %files utils +%doc doc/README.utils %defattr(-,root,root,-) %{_sbindir}/netdevstat %{_sbindir}/diskdevstat %changelog +* Thu Feb 26 2009 Phil Knirsch - 0.1.2-1 +- Added config file option to enable/disable plugins +- Switched from ConfigParser to RawConfigParser +- Renamed doc/README.txt to doc/DESIGN.txt +- Added tuned.conf man page +- Updated tuned man page +- Updated package descriptions (#487312) +- Added documentation for utils scripts (#487312) + * Wed Feb 25 2009 Phil Knirsch - 0.1.1-1 - Bump version - Added comment in empty __init__.py files diff --git a/tuningplugins/disk.py b/tuningplugins/disk.py index d255252..a97433a 100644 --- a/tuningplugins/disk.py +++ b/tuningplugins/disk.py @@ -21,6 +21,7 @@ import os, copy class DiskTuning: def __init__(self): self.devidle = {} + self.enabled = True def __updateIdle__(self, dev, devload): idle = self.devidle.setdefault(dev, {}) @@ -35,12 +36,17 @@ class DiskTuning: def init(self, config): self.config = config + if self.config.has_option("DiskTuning", "enabled"): + self.enabled = (self.config.get("DiskTuning", "enabled") == "True") def cleanup(self): for dev in self.devidle.keys(): - os.system("hdparm -S0 -B255 /dev/"+dev+" > /dev/null 2>&1") + if self.enabled and self.devidle[dev]["LEVEL"] > 0: + os.system("hdparm -S0 -B255 /dev/"+dev+" > /dev/null 2>&1") def setTuning(self, load): + if not self.enabled: + return disks = load.setdefault("DISK", {}) for dev in disks.keys(): devload = disks[dev] diff --git a/tuningplugins/net.py b/tuningplugins/net.py index 1ef11c6..ecb4c20 100644 --- a/tuningplugins/net.py +++ b/tuningplugins/net.py @@ -21,6 +21,7 @@ import os, copy class NetTuning: def __init__(self): self.devidle = {} + self.enabled = True def __updateIdle__(self, dev, devload): idle = self.devidle.setdefault(dev, {}) @@ -35,12 +36,18 @@ class NetTuning: def init(self, config): self.config = config + if self.config.has_option("NetTuning", "enabled"): + self.enabled = (self.config.get("NetTuning", "enabled") == "True") + def cleanup(self): for dev in self.devidle.keys(): - os.system("ethtool -s "+dev+" advertise 0x03F") + if self.enabled and self.devidle[dev]["LEVEL"] > 0: + os.system("ethtool -s "+dev+" advertise 0x03F") def setTuning(self, load): + if not self.enabled: + return disks = load.setdefault("NET", {}) for dev in disks.keys(): devload = disks[dev] -- cgit