Merge branch 'command'
Conflicts: Makefile tuned.spec
This commit is contained in:
commit
733402af8b
11 changed files with 253 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
*.pyc
|
||||
latest-archive
|
||||
*tar.bz2
|
||||
10
Makefile
10
Makefile
|
|
@ -14,6 +14,8 @@ FILES_contrib = contrib/diskdevstat contrib/netdevstat contrib/scomes contrib/va
|
|||
FILES_tuningplugins = tuningplugins/cpu.py tuningplugins/disk.py tuningplugins/net.py tuningplugins/__init__.py
|
||||
FILES_monitorplugins = monitorplugins/cpu.py monitorplugins/disk.py monitorplugins/net.py monitorplugins/__init__.py
|
||||
FILES_ktune = ktune/ktune.init ktune/ktune.sysconfig ktune/sysctl.ktune ktune/README.ktune
|
||||
FILES_commands = commands/cmd_default_mode.py commands/cmd_off_mode.py commands/cmd_list.py \
|
||||
commands/cmd_modes.py commands/__init__.py
|
||||
DOCS = AUTHORS ChangeLog COPYING INSTALL NEWS README
|
||||
|
||||
distarchive: tag archive
|
||||
|
|
@ -31,6 +33,7 @@ archive:
|
|||
cp $(FILES_tuningplugins) $(VERSIONED_NAME)/tuningplugins
|
||||
cp $(FILES_monitorplugins) $(VERSIONED_NAME)/monitorplugins
|
||||
cp $(FILES_ktune) $(VERSIONED_NAME)/ktune
|
||||
cp $(FILES_commands) $(VERSIONED_NAME)/commands
|
||||
|
||||
tar cjf $(VERSIONED_NAME).tar.bz2 $(VERSIONED_NAME)
|
||||
ln -fs $(VERSIONED_NAME).tar.bz2 latest-archive
|
||||
|
|
@ -54,11 +57,13 @@ install:
|
|||
# Install the binaries
|
||||
mkdir -p $(DESTDIR)/usr/sbin/
|
||||
install -m 0755 tuned $(DESTDIR)/usr/sbin/
|
||||
install -m 0755 tuned-adm $(DESTDIR)/usr/sbin/
|
||||
|
||||
# Install the plugins and classes
|
||||
mkdir -p $(DESTDIR)/usr/share/$(NAME)/
|
||||
mkdir -p $(DESTDIR)/usr/share/$(NAME)/tuningplugins
|
||||
mkdir -p $(DESTDIR)/usr/share/$(NAME)/monitorplugins
|
||||
mkdir -p $(DESTDIR)/usr/share/$(NAME)/commands
|
||||
install -m 0644 tuned.py $(DESTDIR)/usr/share/$(NAME)/
|
||||
for file in $(FILES_tuningplugins); do \
|
||||
install -m 0644 $$file $(DESTDIR)/usr/share/$(NAME)/tuningplugins; \
|
||||
|
|
@ -66,6 +71,9 @@ install:
|
|||
for file in $(FILES_monitorplugins); do \
|
||||
install -m 0644 $$file $(DESTDIR)/usr/share/$(NAME)/monitorplugins; \
|
||||
done
|
||||
for file in $(FILES_commands); do \
|
||||
install -m 0644 $$file $(DESTDIR)/usr/share/$(NAME)/commands; \
|
||||
done
|
||||
|
||||
# Install contrib systemtap scripts
|
||||
for file in $(FILES_contrib); do \
|
||||
|
|
@ -76,6 +84,8 @@ install:
|
|||
mkdir -p $(DESTDIR)/etc
|
||||
install -m 0644 tuned.conf $(DESTDIR)/etc
|
||||
|
||||
mkdir -p $(DESTDIR)/etc/tune-profiles/
|
||||
|
||||
# Install initscript
|
||||
mkdir -p $(DESTDIR)/etc/rc.d/init.d
|
||||
install -m 0755 tuned.initscript $(DESTDIR)/etc/rc.d/init.d/tuned
|
||||
|
|
|
|||
8
README.command
Normal file
8
README.command
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
tuned_adm.py
|
||||
------------
|
||||
tuned_adm.py is commandline tool for setting modes
|
||||
which needs ktune and kobo packages. kobo is in repo,
|
||||
ktune must be rebuilt from srpm.
|
||||
|
||||
Commandline is calling ktune with 'tuned-adm default'
|
||||
and setting it back by call 'tuned-adm off'.
|
||||
0
commands/__init__.py
Normal file
0
commands/__init__.py
Normal file
32
commands/cmd_default_mode.py
Normal file
32
commands/cmd_default_mode.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import glob
|
||||
import kobo.shortcuts
|
||||
from kobo.cli import Command
|
||||
|
||||
class Default(Command):
|
||||
"""star ktune and tuned with default settings"""
|
||||
enabled = True
|
||||
|
||||
def options(self):
|
||||
self.parser.usage = "%%prog %s" % self.normalized_name
|
||||
|
||||
self.parser.add_option(
|
||||
"--show-disabled",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="show disabled workers"
|
||||
)
|
||||
|
||||
|
||||
def run(self, *args, **kwargs):
|
||||
os.system('service ktune start')
|
||||
os.system('chkconfig --add ktune && chkconfig --level 345 ktune on')
|
||||
os.system('service tuned start')
|
||||
os.system('chkconfig --add tuned && chkconfig --level 345 tuned on')
|
||||
|
||||
# usb_devices = glob.glob('/sys/bus/usb/devices/?-?/')
|
||||
# for i in usb_devices:
|
||||
# retcode, output = kobo.shortcuts.run('echo 2 > %spower/autosuspend' % i)
|
||||
# retcode, output = kobo.shortcuts.run('echo auto > %spower/level' % i)
|
||||
33
commands/cmd_list.py
Normal file
33
commands/cmd_list.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import glob
|
||||
import kobo.shortcuts
|
||||
from kobo.cli import Command
|
||||
|
||||
class List(Command):
|
||||
"""list of modes"""
|
||||
enabled = True
|
||||
|
||||
def options(self):
|
||||
self.parser.usage = "%%prog %s" % self.normalized_name
|
||||
|
||||
self.parser.add_option(
|
||||
"--show-disabled",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="show disabled workers"
|
||||
)
|
||||
|
||||
|
||||
def run(self, *args, **kwargs):
|
||||
# link config files into directory which is exectued by ktune
|
||||
if os.path.exists("/etc/tune-profiles/"):
|
||||
modes = os.listdir("/etc/tune-profiles")
|
||||
if len(modes) > 0:
|
||||
print "Modes: "
|
||||
for i in range(len(modes)):
|
||||
print modes[i]
|
||||
else:
|
||||
print "No other profiles than default defined."
|
||||
46
commands/cmd_modes.py
Normal file
46
commands/cmd_modes.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import glob
|
||||
import kobo.shortcuts
|
||||
from kobo.cli import Command
|
||||
|
||||
class Modes(Command):
|
||||
"""set mode"""
|
||||
enabled = True
|
||||
|
||||
def options(self):
|
||||
self.parser.usage = "%%prog %s" % self.normalized_name
|
||||
|
||||
self.parser.add_option(
|
||||
"--show-disabled",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="show disabled workers"
|
||||
)
|
||||
|
||||
|
||||
def run(self, *args, **kwargs):
|
||||
# link config files into directory which is exectued by ktune
|
||||
if os.path.exists("/etc/tune-profiles/"):
|
||||
modes = os.listdir("/etc/tune-profiles")
|
||||
if modes > 0:
|
||||
print 'Mode %s' % args[0]
|
||||
file1 = ('/etc/tune-profiles/%s/ktune.conf' % args[0])
|
||||
os.symlink(file1, '/etc/ktune.d/ktune.conf')
|
||||
file2 = ('/etc/tune-profiles/%s/ktune.sh' % args[0])
|
||||
os.symlink(file2, '/etc/ktune.d/ktune.sh')
|
||||
os.rename('/etc/tuned.conf', '/etc/tuned.conf.bckp')
|
||||
file3 = ('/etc/tune-profiles/%s/tuned.conf' % args[0])
|
||||
os.symlink(file3, '/etc/tuned.conf')
|
||||
#if os.path.exists("/etc/tune-profiles/server/ktune"):
|
||||
os.rename('/etc/sysconfig/ktune', '/etc/sysconfig/ktune.bckp')
|
||||
file4 = ('/etc/tune-profiles/%s/ktune' % args[0])
|
||||
os.symlink(file4, '/etc/sysconfig/ktune')
|
||||
|
||||
os.system('service ktune start')
|
||||
os.system('chkconfig --add ktune && chkconfig --level 345 ktune on')
|
||||
|
||||
os.system('service tuned start --config=/etc/tune-profiles/server/tuned.conf')
|
||||
os.system('chkconfig --add tuned && chkconfig --level 345 tuned on')
|
||||
37
commands/cmd_off_mode.py
Normal file
37
commands/cmd_off_mode.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import glob
|
||||
import kobo.shortcuts
|
||||
from kobo.cli import Command
|
||||
|
||||
class Off(Command):
|
||||
"""switch off all tunning"""
|
||||
enabled = True
|
||||
|
||||
def options(self):
|
||||
self.parser.usage = "%%prog %s" % self.normalized_name
|
||||
|
||||
self.parser.add_option(
|
||||
"--show-disabled",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="show disabled workers"
|
||||
)
|
||||
|
||||
|
||||
def run(self, *args, **kwargs):
|
||||
os.system("rm -rf /etc/ktune.d/*.conf")
|
||||
os.system("rm -rf /etc/ktune.d/*.sh")
|
||||
if os.path.exists("/etc/sysconfig/ktune.bckp"):
|
||||
os.rename("/etc/sysconfig/ktune.bckp", "/etc/sysconfig/ktune")
|
||||
if os.path.exists("/etc/tuned.conf.bckp") and os.path.exists("/etc/tuned.conf"):
|
||||
os.rename("/etc/tuned.conf.bckp", "/etc/tuned.conf")
|
||||
os.system('service ktune stop')
|
||||
os.system('service tuned stop')
|
||||
os.system('chkconfig --del ktune')
|
||||
os.system('chkconfig --del tuned')
|
||||
usb_devices = glob.glob('/sys/bus/usb/devices/?-?/')
|
||||
# test whether usb suspend is on
|
||||
for i in usb_devices:
|
||||
retcode, output = kobo.shortcuts.run('echo on > %spower/level' % i)
|
||||
55
man/tuned-adm.1
Normal file
55
man/tuned-adm.1
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
.\"/*
|
||||
.\" * All rights reserved
|
||||
.\" * Copyright (C) 2009 Red Hat, Inc.
|
||||
.\" * Authors: Marcela Mašláňová
|
||||
.\" *
|
||||
.\" * This program is free software; you can redistribute it and/or
|
||||
.\" * modify it under the terms of the GNU General Public License
|
||||
.\" * as published by the Free Software Foundation; either version 2
|
||||
.\" * of the License, or (at your option) any later version.
|
||||
.\" *
|
||||
.\" * This program is distributed in the hope that it will be useful,
|
||||
.\" * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
.\" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
.\" * GNU General Public License for more details.
|
||||
.\" *
|
||||
.\" * You should have received a copy of the GNU General Public License
|
||||
.\" * along with this program; if not, write to the Free Software
|
||||
.\" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
.\" */
|
||||
.\"
|
||||
.TH TUNED_ADM "1" "9 Jul 2009" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
tuned-adm \- commandline tool for setting the power-save options
|
||||
.SH SYNOPSIS
|
||||
.B tuned-adm
|
||||
.B
|
||||
.BR help ", " laptop ", " server ", " default ", " off "
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
This command line utility allows user to set profile for server or laptop.
|
||||
.SH "OPTIONS"
|
||||
|
||||
.SS
|
||||
.TP
|
||||
.B help
|
||||
Print out the list of commands.
|
||||
|
||||
.TP
|
||||
.B laptop
|
||||
|
||||
.TP
|
||||
.B server
|
||||
These settings are calling ktune which set up different values for better resource consumption.
|
||||
It also switch on tuned daemon and add ktune and tuned into chkconfig. Usbsuspend is set.
|
||||
|
||||
.TP
|
||||
.B off
|
||||
Switch off all ktune and tuned settings and remove them from services. The configuration file are
|
||||
set to previous settings.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR tuned (8)
|
||||
.SH AUTHOR
|
||||
.nf
|
||||
Marcela Mašláňová <mmaslano@redhat.com>
|
||||
26
tuned-adm
Executable file
26
tuned-adm
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import locale
|
||||
from kobo.cli import *
|
||||
|
||||
|
||||
from kobo.tback import *
|
||||
set_except_hook()
|
||||
|
||||
|
||||
TUNEDDIR="/usr/share/tuned"
|
||||
if TUNEDDIR not in sys.path:
|
||||
sys.path.insert(0, TUNEDDIR)
|
||||
|
||||
import commands
|
||||
CommandContainer.register_module(commands)
|
||||
|
||||
|
||||
def main(argv):
|
||||
parser = CommandOptionParser(command_container=CommandContainer(), default_command="help")
|
||||
parser.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
|
|
@ -18,6 +18,7 @@ Requires(preun): chkconfig
|
|||
Requires(preun): initscripts
|
||||
Requires(postun): initscripts
|
||||
BuildArch: noarch
|
||||
Requires: kobo
|
||||
|
||||
%description
|
||||
The tuned package contains a daemon that tunes system settings dynamically.
|
||||
|
|
@ -74,6 +75,8 @@ fi
|
|||
%{_initddir}/tuned
|
||||
%config(noreplace) %{_sysconfdir}/tuned.conf
|
||||
%{_sbindir}/tuned
|
||||
%{_sbindir}/tuned-adm
|
||||
%{_sysconfdir}/tune-profiles
|
||||
%{_datadir}/tuned
|
||||
%{_mandir}/man5/*
|
||||
%{_mandir}/man8/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue