- Real first complete version with initscript, config file and
proper Makefile and packaging.
This commit is contained in:
parent
c02f25afb0
commit
80093be74f
14 changed files with 442 additions and 221 deletions
63
Makefile
63
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/
|
||||
|
||||
mkdir -p $(DESTDIR)/etc/alchemist/namespace/printconf
|
||||
install -m 0644 adl_files/rpm.adl adl_files/local.adl $(DESTDIR)/etc/alchemist/namespace/printconf/
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
||||
|
|
|
|||
98
contrib/diskdevstat
Executable file
98
contrib/diskdevstat
Executable file
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
@ -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()
|
||||
}
|
||||
|
||||
98
contrib/netdevstat
Executable file
98
contrib/netdevstat
Executable file
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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 = []
|
||||
|
|
|
|||
33
tuned
33
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()
|
||||
|
|
|
|||
27
tuned.conf
Normal file
27
tuned.conf
Normal file
|
|
@ -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]
|
||||
102
tuned.initscript
Executable file
102
tuned.initscript
Executable file
|
|
@ -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
|
||||
13
tuned.py
13
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()
|
||||
|
|
|
|||
35
tuned.spec
35
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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue