tuned.cfg man page + initial tuned-adm
This commit is contained in:
parent
25371679a4
commit
0faaa74df3
2 changed files with 181 additions and 0 deletions
76
man/tuned.cfg.5
Normal file
76
man/tuned.cfg.5
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
.TH "tuned.cfg" "5" "13 Mar 2012" "Jan Kaluza" "tuned.cfg file format description"
|
||||
.SH NAME
|
||||
tuned.cfg \- Tuned profile definition
|
||||
.SH DESCRIPTION
|
||||
This man page documents format of Tuned 2.0 profile definition files. Profile is
|
||||
stored in /etc/tuned/<profile_name>/tuned.cfg or in
|
||||
/usr/lib/tuned/<profile_name>/tuned.cfg file where the /etc/tuned/ directory has
|
||||
higher priority.
|
||||
|
||||
The \fBtuned.cfg\fR configures the profile and it is in ini-file format.
|
||||
|
||||
.SH MAIN SECTION
|
||||
The main section is called "[main]" and can contain following options:
|
||||
|
||||
.TP
|
||||
include=
|
||||
Includes config file defined as value. Config file can be defined as full path
|
||||
or by the profile name to which it belongs.
|
||||
If this parameter is present, the histogram will be shown at the end of the measurement.
|
||||
|
||||
.SH PLUGINS
|
||||
Every other section defines one plugin. The name of the section is used as name
|
||||
for the plugin and is used in logs to identify the plugin. There can be only
|
||||
one plugin of particular type tuning particular device. Conflicts are by
|
||||
default fixed by merging the options of both plugins together. This can be
|
||||
changed by "replace" option.
|
||||
|
||||
Every plugin section can contain following sections:
|
||||
|
||||
.TP
|
||||
type=
|
||||
Plugin type. Currently there are following plugins: disk, script, net, cpu.
|
||||
.TP
|
||||
devices=
|
||||
Comma separated list of devices which should be tuned by this plugin instance.
|
||||
If you omit this option, all found devices will be tuned.
|
||||
.TP
|
||||
replace=1
|
||||
If there is conflict between two plugins (meaning two plugins of the same
|
||||
type are trying to configure the same devices), then the plugin defined as
|
||||
last replaces all options defined by the previosly defined plugin.
|
||||
.LP
|
||||
Plugins can also have plugin related options.
|
||||
|
||||
.SH "EXAMPLE"
|
||||
.nf
|
||||
[main]
|
||||
# Includes plugins defined in "included" profile.
|
||||
include=included
|
||||
|
||||
# Define my_sysctl plugin
|
||||
[my_sysctl]
|
||||
type=sysctl
|
||||
# This plugin will replace any sysctl plugin defined in "included" profile
|
||||
replace=1
|
||||
# 256 KB default performs well experimentally.
|
||||
net.core.rmem_default = 262144
|
||||
net.core.wmem_default = 262144
|
||||
|
||||
# Define my_script plugin
|
||||
# Since there is no "replace=1" option, this plugin will not replace
|
||||
# any script plugin defined in "included" profile and both scripts
|
||||
# (profile.sh from this profile and script from "included" profile)
|
||||
# will be run.
|
||||
[my_script]
|
||||
type=script
|
||||
script=profile.sh
|
||||
.fi
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.LP
|
||||
tuned(8)
|
||||
.SH AUTHOR
|
||||
Written by Jan Kaluza <jkaluza@redhat.com>.
|
||||
.SH REPORTING BUGS
|
||||
Report bugs to <jkaluza@redhat.com>.
|
||||
105
tuned-adm.py
Executable file
105
tuned-adm.py
Executable file
|
|
@ -0,0 +1,105 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# tuned-adm: A command line utility for switching between user
|
||||
# definable tuning profiles.
|
||||
#
|
||||
# Copyright (C) 2012 Red Hat, Inc.
|
||||
# Authors: Jan Kaluza
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import locale
|
||||
import signal
|
||||
|
||||
PIDFILE = "/var/run/tuned/tuned.pid"
|
||||
|
||||
def usage():
|
||||
print """
|
||||
Usage: tuned-adm <command>
|
||||
|
||||
commands:
|
||||
help show this help message and exit
|
||||
list list all available and active profiles
|
||||
active show current active profile
|
||||
off switch off all tunning
|
||||
profile <profile-name> switch to given profile
|
||||
"""
|
||||
|
||||
class Tuned_adm:
|
||||
|
||||
def error(self, msg, exit_code = 1):
|
||||
print >>sys.stderr, msg
|
||||
sys.exit(exit_code)
|
||||
|
||||
def check_permissions(self):
|
||||
if not os.getuid() == 0:
|
||||
self.error("Only root can run this script.", 2)
|
||||
|
||||
def run(self, args):
|
||||
if args[0] == "list":
|
||||
#self.list()
|
||||
pass
|
||||
elif args[0] == "active":
|
||||
#self.active()
|
||||
#self.service_status("tuned")
|
||||
#self.service_status("ktune")
|
||||
pass
|
||||
elif args[0] == "off":
|
||||
self.check_permissions()
|
||||
#self.off()
|
||||
elif args[0] == "profile":
|
||||
if len(args) == 2:
|
||||
self.check_permissions()
|
||||
self.set_active_profile(args[1])
|
||||
else:
|
||||
self.error("Invalid profile specification. Use 'tuned-adm list' to get all available profiles.")
|
||||
else:
|
||||
self.error("Nonexistent argument '%s'." % args[0])
|
||||
|
||||
def set_active_profile(self, profile):
|
||||
pid = 0
|
||||
try:
|
||||
with open(PIDFILE) as f:
|
||||
pid = int(f.read())
|
||||
except (OSError,IOError) as e:
|
||||
self.error("Cannot read %s: %s" % (PIDFILE, str(e)))
|
||||
|
||||
if pid:
|
||||
try:
|
||||
with open("/etc/tuned/active_profile", "w") as f:
|
||||
f.write(profile)
|
||||
except (OSError,IOError) as e:
|
||||
log.error("Cannot write profile into /etc/tuned/active_profile: %s" % (e))
|
||||
os.kill(pid, signal.SIGHUP)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = sys.argv[1:]
|
||||
|
||||
if len(args) < 1:
|
||||
print >>sys.stderr, "Missing arguments."
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
if args[0] in [ "help", "--help", "-h" ]:
|
||||
usage()
|
||||
sys.exit(0)
|
||||
|
||||
tuned_adm = Tuned_adm()
|
||||
tuned_adm.run(args)
|
||||
|
||||
Loading…
Reference in a new issue