summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Knirsch <pknirsch@hamburg.stuttgart.redhat.com>2009-02-23 18:03:35 +0100
committerPhilip Knirsch <pknirsch@hamburg.stuttgart.redhat.com>2009-02-23 18:03:35 +0100
commit80093be74fbed8d4459938e19ff00920a41a9712 (patch)
treec73b82af32e34b7a74bdfd4ca96c4ff3f6cd2465
parentc02f25afb09ff1f38484a8b69c4dcc85ed2378c7 (diff)
downloadtuned-80093be74fbed8d4459938e19ff00920a41a9712.tar.gz
tuned-80093be74fbed8d4459938e19ff00920a41a9712.tar.xz
tuned-80093be74fbed8d4459938e19ff00920a41a9712.zip
- Real first complete version with initscript, config file and
proper Makefile and packaging.
-rw-r--r--Makefile63
-rwxr-xr-xcontrib/diskdevstat98
-rwxr-xr-xcontrib/diskdevstat.stp93
-rwxr-xr-xcontrib/netdevstat98
-rwxr-xr-xcontrib/netdevstat.stp93
-rw-r--r--monitorplugins/disk.py2
-rw-r--r--monitorplugins/net.py2
-rwxr-xr-xtuned33
-rw-r--r--tuned.conf27
-rwxr-xr-xtuned.initscript102
-rw-r--r--tuned.py13
-rw-r--r--tuned.spec35
-rw-r--r--tuningplugins/disk.py2
-rw-r--r--tuningplugins/net.py2
14 files changed, 442 insertions, 221 deletions
diff --git a/Makefile b/Makefile
index f17879e..ba0a502 100644
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,32 @@
-NAME=tuned
-VERSION=$(shell awk '/^Version:/ {print $$2}' tuned.spec)
-RELEASE=$(shell awk '/^Release:/ {print $$2}' tuned.spec)
-VERSIONED_NAME=$(NAME)-$(VERSION)
+NAME = tuned
+VERSION = $(shell awk '/^Version:/ {print $$2}' tuned.spec)
+RELEASE = $(shell awk '/^Release:/ {print $$2}' tuned.spec)
+VERSIONED_NAME = $(NAME)-$(VERSION)
-DESTDIR=/
-MANDIR=/usr/share/man/
+DESTDIR = /
+MANDIR = /usr/share/man/
GITTAG = r$(subst .,-,$(VERSION))
DIRS = doc contrib tuningplugins monitorplugins
-FILES = tuned
-DOCS = AUTHORS ChangeLog COPYING INSTALL NEWS README tuned.spec
+FILES = tuned tuned.spec Makefile tuned.py tuned.initscript tuned.conf
+FILES_doc = doc/README.txt doc/TIPS.txt
+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
+DOCS = AUTHORS ChangeLog COPYING INSTALL NEWS README
archive:
rm -rf $(VERSIONED_NAME)
mkdir -p $(VERSIONED_NAME)
cp $(FILES) $(VERSIONED_NAME)/
cp $(DOCS) $(VERSIONED_NAME)/
+ for dir in $(DIRS); do \
+ mkdir -p $(VERSIONED_NAME)/$$dir; \
+ done;
+ cp $(FILES_doc) $(VERSIONED_NAME)/doc
+ cp $(FILES_contrib) $(VERSIONED_NAME)/contrib
+ cp $(FILES_tuningplugins) $(VERSIONED_NAME)/tuningplugins
+ cp $(FILES_monitorplugins) $(VERSIONED_NAME)/monitorplugins
tar cjf $(VERSIONED_NAME).tar.bz2 $(VERSIONED_NAME)
ln -fs $(VERSIONED_NAME).tar.bz2 latest-archive
@@ -28,25 +39,45 @@ srpm: archive
mkdir rpm-build-dir
rpmbuild --define "_sourcedir `pwd`/rpm-build-dir" --define "_srcrpmdir `pwd`/rpm-build-dir" \
--define "_specdir `pwd`/rpm-build-dir" --nodeps -ts $(VERSIONED_NAME).tar.bz2
- rm -rf rpm-build-dir
build:
- # Make Magicfilter
+ # Nothing to build
install:
mkdir -p $(DESTDIR)
# Install the binaries
- mkdir -p $(DESTDIR)/usr/bin/
+ mkdir -p $(DESTDIR)/usr/sbin/
+ install -m 0755 tuned $(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
+ install -m 0644 tuned.py $(DESTDIR)/usr/share/$(NAME)/
+ for file in $(FILES_tuningplugins); do \
+ install -m 0644 $$file $(DESTDIR)/usr/share/$(NAME)/tuningplugins; \
+ done
+ for file in $(FILES_monitorplugins); do \
+ install -m 0644 $$file $(DESTDIR)/usr/share/$(NAME)/monitorplugins; \
+ done
+
+ # Install contrib systemtap scripts
+ for file in $(FILES_contrib); do \
+ install -m 0755 $$file $(DESTDIR)/usr/sbin/; \
+ done
+
+ # Install config file
+ mkdir -p $(DESTDIR)/etc
+ install -m 0644 tuned.conf $(DESTDIR)/etc
- mkdir -p $(DESTDIR)/etc/alchemist/namespace/printconf
- install -m 0644 adl_files/rpm.adl adl_files/local.adl $(DESTDIR)/etc/alchemist/namespace/printconf/
+ # Install initscript
+ mkdir -p $(DESTDIR)/etc/rc.d/init.d
+ install -m 0755 tuned.initscript $(DESTDIR)/etc/rc.d/init.d/tuned
- # drop in some basics
- install -m 0644 printcap.local $(DESTDIR)/etc/
clean:
- rm -rf *.pyc monitorplugins/*.pyc tuningplugins/*.pyc
+ rm -rf *.pyc monitorplugins/*.pyc tuningplugins/*.pyc $(VERSIONED_NAME) rpm-build-dir
.PHONY: clean archive srpm tag
diff --git a/contrib/diskdevstat b/contrib/diskdevstat
new file mode 100755
index 0000000..a18d1b7
--- /dev/null
+++ b/contrib/diskdevstat
@@ -0,0 +1,98 @@
+#!/usr/bin/stap
+#
+# diskdevstat: A simple systemtap script to record harddisk activity
+# of processes and display statistics for read/write operations
+# Copyright (C) 2008, 2009 Red Hat, Inc.
+# Authors: Phil Knirsch
+#
+# 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.
+#
+
+global ifavg, iflast
+
+probe vfs.write
+{
+ if(pid() == 0 || devname == "N/A") {
+ next;
+ }
+ ms = gettimeofday_ms();
+ if(iflast[0, pid(), devname, execname(), uid()] == 0) {
+ iflast[0, pid(), devname, execname(), uid()] = ms;
+ } else {
+ diff = ms - iflast[0, pid(), devname, execname(), uid()];
+ iflast[0, pid(), devname, execname(), uid()] = ms;
+ ifavg[0, pid(), devname, execname(), uid()] <<< diff;
+ }
+}
+
+probe vfs.read
+{
+ if(pid() == 0 || devname == "N/A") {
+ next;
+ }
+ ms = gettimeofday_ms();
+ if(iflast[1, pid(), devname, execname(), uid()] == 0) {
+ iflast[1, pid(), devname, execname(), uid()] = ms;
+ } else {
+ diff = ms - iflast[1, pid(), devname, execname(), uid()];
+ iflast[1, pid(), devname, execname(), uid()] = ms;
+ ifavg[1, pid(), devname, execname(), uid()] <<< diff;
+ }
+}
+
+
+function print_activity()
+{
+ printf("\033[2J\033[1;1H")
+ printf("%5s %5s %-7s %9s %9s %9s %9s %9s %9s %9s %9s %-15s\n",
+ "PID", "UID", "DEV", "WRITE_CNT", "WRITE_MIN", "WRITE_MAX",
+ "WRITE_AVG", "READ_CNT", "READ_MIN", "READ_MAX", "READ_AVG",
+ "COMMAND")
+
+ foreach ([type, pid, dev, exec, uid] in ifavg-) {
+ nxmit = @count(ifavg[0, pid, dev, exec, uid])
+ nrecv = @count(ifavg[1, pid, dev, exec, uid])
+ write_min = nxmit ? @min(ifavg[0, pid, dev, exec, uid]) : 0
+ write_max = nxmit ? @max(ifavg[0, pid, dev, exec, uid]) : 0
+ write_avg = nxmit ? @avg(ifavg[0, pid, dev, exec, uid]) : 0
+ read_min = nrecv ? @min(ifavg[1, pid, dev, exec, uid]) : 0
+ read_max = nrecv ? @max(ifavg[1, pid, dev, exec, uid]) : 0
+ read_avg = nrecv ? @avg(ifavg[1, pid, dev, exec, uid]) : 0
+ if(type == 0 || nxmit == 0) {
+ printf("%5d %5d %-7s %9d %5d.%03d %5d.%03d %5d.%03d",
+ pid, uid, dev, nxmit,
+ write_min/1000, write_min%1000,
+ write_max/1000, write_max%1000,
+ write_avg/1000, write_avg%1000)
+ printf(" %9d %5d.%03d %5d.%03d %5d.%03d %-15s\n",
+ nrecv,
+ read_min/1000, read_min%1000,
+ read_max/1000, read_max%1000,
+ read_avg/1000, read_avg%1000,
+ exec)
+ }
+ }
+
+ print("\n")
+}
+
+probe timer.s(5), end, error
+{
+ print_activity()
+}
+
diff --git a/contrib/diskdevstat.stp b/contrib/diskdevstat.stp
deleted file mode 100755
index a049a97..0000000
--- a/contrib/diskdevstat.stp
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/stap
-#
-# diskdevstat: A simple systemtap script to record harddisk activity of processes and
-# display statistics for read/write operations
-# Copyright (C) 2008, 2009 Red Hat, Inc.
-# Authors: Phil Knirsch
-#
-# 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.
-#
-
-global ifavg, iflast, ifmin, ifmax;
-
-probe vfs.write
-{
- if(pid() == 0 || devname == "N/A") {
- next;
- }
- ns = gettimeofday_ms();
- if(iflast[0, pid(), devname, execname(), uid()] == 0) {
- iflast[0, pid(), devname, execname(), uid()] = ns;
- } else {
- diff = ns - iflast[0, pid(), devname, execname(), uid()];
- iflast[0, pid(), devname, execname(), uid()] = ns;
- if(ifmin[0, pid(), devname, execname(), uid()] == 0 || diff < ifmin[0, pid(), devname, execname(), uid()])
- ifmin[0, pid(), devname, execname(), uid()] = diff;
- if(diff > ifmax[0, pid(), devname, execname(), uid()])
- ifmax[0, pid(), devname, execname(), uid()] = diff;
- ifavg[0, pid(), devname, execname(), uid()] <<< diff;
- }
-}
-
-probe vfs.read
-{
- if(pid() == 0 || devname == "N/A") {
- next;
- }
- ns = gettimeofday_ms();
- if(iflast[1, pid(), devname, execname(), uid()] == 0) {
- iflast[1, pid(), devname, execname(), uid()] = ns;
- } else {
- diff = ns - iflast[1, pid(), devname, execname(), uid()];
- iflast[1, pid(), devname, execname(), uid()] = ns;
- if(ifmin[1, pid(), devname, execname(), uid()] == 0 || diff < ifmin[1, pid(), devname, execname(), uid()])
- ifmin[1, pid(), devname, execname(), uid()] = diff;
- if(diff > ifmax[1, pid(), devname, execname(), uid()])
- ifmax[1, pid(), devname, execname(), uid()] = diff;
- ifavg[1, pid(), devname, execname(), uid()] <<< diff;
- }
-}
-
-
-function print_activity()
-{
- printf("\033[2J\033[1;1H")
- printf("%5s %5s %-7s %9s %9s %9s %9s %9s %9s %9s %9s %-15s\n",
- "PID", "UID", "DEV", "WRITE_CNT", "WRITE_MIN", "WRITE_MAX", "WRITE_AVG", "READ_CNT", "READ_MIN", "READ_MAX", "READ_AVG", "COMMAND")
-
- foreach ([type, pid, dev, exec, uid] in ifavg-) {
- nxmit = @count(ifavg[0, pid, dev, exec, uid])
- nrecv = @count(ifavg[1, pid, dev, exec, uid])
- if(type == 0 || nxmit == 0) {
- printf("%5d %5d %-7s %9d %5d.%03d %5d.%03d %5d.%03d %9d %5d.%03d %5d.%03d %5d.%03d %-15s\n",
- pid, uid, dev,
- nxmit, ifmin[0, pid, dev, exec, uid]/1000, ifmin[0, pid, dev, exec, uid]%1000,
- ifmax[0, pid, dev, exec, uid]/1000, ifmax[0, pid, dev, exec, uid]%1000,
- nxmit ? @avg(ifavg[0, pid, dev, exec, uid])/1000 : 0, nxmit ? @avg(ifavg[0, pid, dev, exec, uid])%1000 : 0,
- nrecv, ifmin[1, pid, dev, exec, uid]/1000, ifmin[1, pid, dev, exec, uid]%1000,
- ifmax[1, pid, dev, exec, uid]/1000, ifmax[1, pid, dev, exec, uid]%1000,
- nrecv ? @avg(ifavg[1, pid, dev, exec, uid])/1000 : 0, nrecv ? @avg(ifavg[1, pid, dev, exec, uid])%1000 : 0,
- exec)
- }
- }
-
- print("\n")
-}
-
-probe timer.ms(5000), end, error
-{
- print_activity()
-}
-
diff --git a/contrib/netdevstat b/contrib/netdevstat
new file mode 100755
index 0000000..b2b4afc
--- /dev/null
+++ b/contrib/netdevstat
@@ -0,0 +1,98 @@
+#!/usr/bin/stap
+#
+# netdevstat: A simple systemtap script to record network activity of
+# processes and display statistics for transmit/receive operations
+# Copyright (C) 2008, 2009 Red Hat, Inc.
+# Authors: Phil Knirsch
+#
+# 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:
+#
+# Free Software Foundation, Inc.
+# 51 Franklin Street, Fifth Floor
+# Boston, MA 02110-1301, USA.
+#
+
+global ifavg, iflast;
+
+probe netdev.transmit
+{
+ if(pid() == 0) {
+ next;
+ }
+ ms = gettimeofday_ms();
+ if(iflast[0, pid(), dev_name, execname(), uid()] == 0) {
+ iflast[0, pid(), dev_name, execname(), uid()] = ms;
+ } else {
+ diff = ms - iflast[0, pid(), dev_name, execname(), uid()];
+ iflast[0, pid(), dev_name, execname(), uid()] = ms;
+ ifavg[0, pid(), dev_name, execname(), uid()] <<< diff;
+ }
+}
+
+probe netdev.receive
+{
+ if(pid() == 0) {
+ next;
+ }
+ ms = gettimeofday_ms();
+ if(iflast[1, pid(), dev_name, execname(), uid()] == 0) {
+ iflast[1, pid(), dev_name, execname(), uid()] = ms;
+ } else {
+ diff = ms - iflast[1, pid(), dev_name, execname(), uid()];
+ iflast[1, pid(), dev_name, execname(), uid()] = ms;
+ ifavg[1, pid(), dev_name, execname(), uid()] <<< diff;
+ }
+}
+
+function print_activity()
+{
+ printf("\033[2J\033[1;1H")
+ printf("%5s %5s %-7s %9s %9s %9s %9s %9s %9s %9s %9s %-15s\n",
+ "PID", "UID", "DEV",
+ "XMIT_CNT", "XMIT_MIN", "XMIT_MAX", "XMIT_AVG",
+ "RECV_CNT", "RECV_MIN", "RECV_MAX", "RECV_AVG",
+ "COMMAND")
+
+ foreach ([type, pid, dev, exec, uid] in ifavg-) {
+ nxmit = @count(ifavg[0, pid, dev, exec, uid])
+ nrecv = @count(ifavg[1, pid, dev, exec, uid])
+ xmit_min = nxmit ? @min(ifavg[0, pid, dev, exec, uid]) : 0
+ xmit_max = nxmit ? @max(ifavg[0, pid, dev, exec, uid]) : 0
+ xmit_avg = nxmit ? @avg(ifavg[0, pid, dev, exec, uid]) : 0
+ recv_min = nrecv ? @min(ifavg[1, pid, dev, exec, uid]) : 0
+ recv_max = nrecv ? @max(ifavg[1, pid, dev, exec, uid]) : 0
+ recv_avg = nrecv ? @avg(ifavg[1, pid, dev, exec, uid]) : 0
+ if(type == 0 || nxmit == 0) {
+ printf("%5d %5d %-7s %9d %5d.%03d %5d.%03d %5d.%03d ",
+ pid, uid, dev, nxmit,
+ xmit_min/1000, xmit_min%1000,
+ xmit_max/1000, xmit_max%1000,
+ xmit_avg/1000, xmit_avg%1000)
+ printf("%9d %5d.%03d %5d.%03d %5d.%03d %-15s\n",
+ nrecv,
+ recv_min/1000, recv_min%1000,
+ recv_max/1000, recv_max%1000,
+ recv_avg/1000, recv_avg%1000,
+ exec)
+ }
+ }
+
+ print("\n")
+}
+
+probe timer.s(5), end, error
+{
+ print_activity()
+}
+
diff --git a/contrib/netdevstat.stp b/contrib/netdevstat.stp
deleted file mode 100755
index b5b0c2a..0000000
--- a/contrib/netdevstat.stp
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/stap
-#
-# netdevstat: A simple systemtap script to record network activity of processes and
-# display statistics for transmit/receive operations
-# Copyright (C) 2008, 2009 Red Hat, Inc.
-# Authors: Phil Knirsch
-#
-# 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.
-#
-
-global ifavg, iflast, ifmin, ifmax;
-
-probe netdev.transmit
-{
- if(pid() == 0) {
- next;
- }
- ns = gettimeofday_ms();
- if(iflast[0, pid(), dev_name, execname(), uid()] == 0) {
- iflast[0, pid(), dev_name, execname(), uid()] = ns;
- } else {
- diff = ns - iflast[0, pid(), dev_name, execname(), uid()];
- iflast[0, pid(), dev_name, execname(), uid()] = ns;
- if(ifmin[0, pid(), dev_name, execname(), uid()] == 0 || diff < ifmin[0, pid(), dev_name, execname(), uid()])
- ifmin[0, pid(), dev_name, execname(), uid()] = diff;
- if(diff > ifmax[0, pid(), dev_name, execname(), uid()])
- ifmax[0, pid(), dev_name, execname(), uid()] = diff;
- ifavg[0, pid(), dev_name, execname(), uid()] <<< diff;
- }
-}
-
-probe netdev.receive
-{
- if(pid() == 0) {
- next;
- }
- ns = gettimeofday_ms();
- if(iflast[1, pid(), dev_name, execname(), uid()] == 0) {
- iflast[1, pid(), dev_name, execname(), uid()] = ns;
- } else {
- diff = ns - iflast[1, pid(), dev_name, execname(), uid()];
- iflast[1, pid(), dev_name, execname(), uid()] = ns;
- if(ifmin[1, pid(), dev_name, execname(), uid()] == 0 || diff < ifmin[1, pid(), dev_name, execname(), uid()])
- ifmin[1, pid(), dev_name, execname(), uid()] = diff;
- if(diff > ifmax[1, pid(), dev_name, execname(), uid()])
- ifmax[1, pid(), dev_name, execname(), uid()] = diff;
- ifavg[1, pid(), dev_name, execname(), uid()] <<< diff;
- }
-}
-
-
-function print_activity()
-{
- printf("\033[2J\033[1;1H")
- printf("%5s %5s %-7s %9s %9s %9s %9s %9s %9s %9s %9s %-15s\n",
- "PID", "UID", "DEV", "XMIT_CNT", "XMIT_MIN", "XMIT_MAX", "XMIT_AVG", "RECV_CNT", "RECV_MIN", "RECV_MAX", "RECV_AVG", "COMMAND")
-
- foreach ([type, pid, dev, exec, uid] in ifavg-) {
- nxmit = @count(ifavg[0, pid, dev, exec, uid])
- nrecv = @count(ifavg[1, pid, dev, exec, uid])
- if(type == 0 || nxmit == 0) {
- printf("%5d %5d %-7s %9d %5d.%03d %5d.%03d %5d.%03d %9d %5d.%03d %5d.%03d %5d.%03d %-15s\n",
- pid, uid, dev,
- nxmit, ifmin[0, pid, dev, exec, uid]/1000, ifmin[0, pid, dev, exec, uid]%1000,
- ifmax[0, pid, dev, exec, uid]/1000, ifmax[0, pid, dev, exec, uid]%1000,
- nxmit ? @avg(ifavg[0, pid, dev, exec, uid])/1000 : 0, nxmit ? @avg(ifavg[0, pid, dev, exec, uid])%1000 : 0,
- nrecv, ifmin[1, pid, dev, exec, uid]/1000, ifmin[1, pid, dev, exec, uid]%1000,
- ifmax[1, pid, dev, exec, uid]/1000, ifmax[1, pid, dev, exec, uid]%1000,
- nrecv ? @avg(ifavg[1, pid, dev, exec, uid])/1000 : 0, nrecv ? @avg(ifavg[1, pid, dev, exec, uid])%1000 : 0,
- exec)
- }
- }
-
- print("\n")
-}
-
-probe timer.ms(5000), end, error
-{
- print_activity()
-}
-
diff --git a/monitorplugins/disk.py b/monitorplugins/disk.py
index fb9eb56..f2844e8 100644
--- a/monitorplugins/disk.py
+++ b/monitorplugins/disk.py
@@ -34,7 +34,7 @@ class DiskMonitor:
self.devices[d]["max"] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
self.__updateStat__(d)
self.devices[d]["max"] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
- print self.devices
+ #print self.devices
def __calcdiff__(self, dev):
diff --git a/monitorplugins/net.py b/monitorplugins/net.py
index 0091b26..32042d8 100644
--- a/monitorplugins/net.py
+++ b/monitorplugins/net.py
@@ -33,7 +33,7 @@ class NetMonitor:
self.devices[d]["max"] = [70*1024*1024, 1, 70*1024*1024, 1]
self.__updateStat__(d)
self.devices[d]["max"] = [70*1024*1024, 1, 70*1024*1024, 1]
- print self.devices
+ #print self.devices
def __calcdiff__(self, dev):
l = []
diff --git a/tuned b/tuned
index 574265d..a1b6cab 100755
--- a/tuned
+++ b/tuned
@@ -20,9 +20,34 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
+import sys, os.path
-from tuned import tuned
+if __name__ == "__main__":
+ try:
+ pid = os.fork()
+ if pid > 0:
+ sys.exit(0)
+ except OSError, e:
+ sys.exit(1)
-tuned.init(".")
-tuned.run()
-tuned.cleanup()
+ os.chdir("/")
+ os.setsid()
+ os.umask(0)
+
+ try:
+ pid = os.fork()
+ if pid > 0:
+ sys.exit(0)
+ except OSError, e:
+ sys.exit(1)
+
+ sys.stdout = sys.stderr = open("/dev/null", 'a+')
+ TUNEDDIR="/usr/share/tuned"
+ if not TUNEDDIR in sys.path:
+ sys.path.append(TUNEDDIR)
+
+ from tuned import tuned
+
+ tuned.init(TUNEDDIR)
+ tuned.run()
+ tuned.cleanup()
diff --git a/tuned.conf b/tuned.conf
new file mode 100644
index 0000000..793d81e
--- /dev/null
+++ b/tuned.conf
@@ -0,0 +1,27 @@
+#
+# tuned configuration main service
+#
+
+[main]
+# Interval for monitoring and tuning. Default is 10s.
+interval=10
+
+#
+# Disk monitoring section
+#
+[DiskMonitor]
+
+#
+# Disk tuning section
+#
+[DiskTuning]
+
+#
+# Net monitoring section
+#
+[NetMonitor]
+
+#
+# Net tuning section
+#
+[NetTuning]
diff --git a/tuned.initscript b/tuned.initscript
new file mode 100755
index 0000000..dad1405
--- /dev/null
+++ b/tuned.initscript
@@ -0,0 +1,102 @@
+#!/bin/sh
+#
+# tuned Startup script for the tuned dynamic system tuning daemon
+# chkconfig: - 86 15
+# description: tuned is a dynamic system tuning daemon that uses various
+# monitoring resources to adapt system settings adaptively.
+
+### BEGIN INIT INFO
+# Provides:
+# Required-Start:
+# Required-Stop:
+# Should-Start:
+# Should-Stop:
+# Default-Start:
+# Default-Stop:
+# Short-Description: This service is a dynamic system tuning daemon
+# Description:
+### END INIT INFO
+
+# Source function library.
+. /etc/init.d/functions
+
+exec="/usr/sbin/tuned"
+prog="tuned"
+config="/etc/tuned.conf"
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+start () {
+ [ -x $exec ] || exit 5
+ [ -f $config ] || exit 6
+ echo -n $"Starting $prog: "
+ daemon $exec
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+}
+
+stop () {
+ echo -n $"Stopping $prog: "
+ killproc $prog
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ restart
+}
+
+force_reload() {
+ restart
+}
+
+rh_status() {
+ # run checks to determine if the service is running or use generic status
+ status $prog
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+case "$1" in
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart)
+ $1
+ ;;
+ reload)
+ rh_status_q || exit 7
+ $1
+ ;;
+ force-reload)
+ force_reload
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
+# vim:syntax=sh
diff --git a/tuned.py b/tuned.py
index 35604c5..6328aa3 100644
--- a/tuned.py
+++ b/tuned.py
@@ -1,9 +1,11 @@
-import time,os,locale
+import time,os,locale,ConfigParser
class Tuned:
def __init__(self):
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 \
@@ -21,9 +23,13 @@ class Tuned:
def init(self, path):
self.__initplugins__(path, "monitorplugins", self.mp)
self.__initplugins__(path, "tuningplugins", self.tp)
+ for p in self.mp:
+ p.config = self.config
+ for p in self.tp:
+ p.config = self.config
def run(self):
- print("Running...")
+ #print("Running...")
while True:
lh = {}
for p in self.mp:
@@ -33,6 +39,7 @@ class Tuned:
time.sleep(10)
def cleanup(self):
- print("Cleanup...")
+ pass
+ #print("Cleanup...")
tuned = Tuned()
diff --git a/tuned.spec b/tuned.spec
index 422b60f..32d65e8 100644
--- a/tuned.spec
+++ b/tuned.spec
@@ -6,6 +6,10 @@ License: GPLv2+
Group: System Environment/Daemons
Source: tuned-%{version}.tar.bz2
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+Requires(post): chkconfig
+Requires(preun): chkconfig
+Requires(preun): initscripts
+Requires(postun): initscripts
BuildArch: noarch
%description
@@ -13,7 +17,7 @@ The tuned package contains a daemon that tunes system settings dynamically.
%package utils
Summary: Disk and net monitoring systemtap scripts
-Requires: kernel-debuginfo
+Requires: systemtap kernel-debuginfo
Group: Applications/System
%description utils
@@ -31,18 +35,33 @@ make install DESTDIR=%{buildroot}
%clean
rm -rf %{buildroot}
+%post
+/sbin/chkconfig --add tuned
+
+%preun
+if [ $1 = 0 ] ; then
+ /sbin/service tuned stop >/dev/null 2>&1
+ /sbin/chkconfig --del tuned
+fi
+
+%postun
+if [ "$1" -ge "1" ] ; then
+ /sbin/service tuned condrestart >/dev/null 2>&1 || :
+fi
+
%files
%defattr(-,root,root)
-%{bin}/tuned
-%{datadir}/tuned.py
-%{datadir}/monitorplugins
-%{datadir}/tuningplugins
+%doc AUTHORS ChangeLog COPYING INSTALL NEWS README doc/*
+%{_initddir}/tuned
+%{_sysconfdir}/tuned.conf
+%{_sbindir}/tuned
+%{_datadir}/tuned
%files utils
-%{_bin}/netdevstat
-%{_bin}/diskdevstat
+%{_sbindir}/netdevstat
+%{_sbindir}/diskdevstat
%changelog
-* Thu Feb 19 2009 Phil Knirsch <pknirsch@redhat.com> - 0.1.0-1
+* Mon Feb 23 2009 Phil Knirsch <pknirsch@redhat.com> - 0.1.0-1
- Initial version
diff --git a/tuningplugins/disk.py b/tuningplugins/disk.py
index 638ca33..9d7d848 100644
--- a/tuningplugins/disk.py
+++ b/tuningplugins/disk.py
@@ -44,6 +44,6 @@ class DiskTuning:
if self.devidle[dev]["LEVEL"] > 0 and (self.devidle[dev]["READ"] == 0 or self.devidle[dev]["WRITE"] == 0):
self.devidle[dev]["LEVEL"] = 0
os.system("hdparm -S255 -B127 /dev/"+dev)
- print(load, self.devidle)
+ #print(load, self.devidle)
_plugin = DiskTuning()
diff --git a/tuningplugins/net.py b/tuningplugins/net.py
index 1245d90..3983b8d 100644
--- a/tuningplugins/net.py
+++ b/tuningplugins/net.py
@@ -44,6 +44,6 @@ class NetTuning:
if self.devidle[dev]["LEVEL"] > 0 and (self.devidle[dev]["READ"] == 0 or self.devidle[dev]["WRITE"] == 0):
self.devidle[dev]["LEVEL"] = 0
os.system("ethtool -s "+dev+" advertise 0x03F")
- print(load, self.devidle)
+ #print(load, self.devidle)
_plugin = NetTuning()