summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Knirsch <pknirsch@hamburg.stuttgart.redhat.com>2009-03-25 17:42:43 +0100
committerPhilip Knirsch <pknirsch@hamburg.stuttgart.redhat.com>2009-03-25 17:42:43 +0100
commit019e5d08cc04c5bbe5a16edb2fe8d2b3023a00a1 (patch)
treea73958377d27a7d713407784f44188096ddad72b
parentccd7b1e2608520610e34feed95931f41c233f459 (diff)
downloadtuned-019e5d08cc04c5bbe5a16edb2fe8d2b3023a00a1.zip
tuned-019e5d08cc04c5bbe5a16edb2fe8d2b3023a00a1.tar.gz
tuned-019e5d08cc04c5bbe5a16edb2fe8d2b3023a00a1.tar.xz
- Updated diskdevstat and netdevstat to have command line arguments
- Added the possibility to output a histogram at the end of the run for detailed information about the collected data
-rwxr-xr-xcontrib/diskdevstat60
-rwxr-xr-xcontrib/netdevstat58
-rw-r--r--doc/README.utils18
3 files changed, 126 insertions, 10 deletions
diff --git a/contrib/diskdevstat b/contrib/diskdevstat
index 1c98fd5..3652555 100755
--- a/contrib/diskdevstat
+++ b/contrib/diskdevstat
@@ -2,6 +2,12 @@
#
# diskdevstat: A simple systemtap script to record harddisk activity
# of processes and display statistics for read/write operations
+#
+# Usage: diskdevstat [Update interval] [Total duration] [Display histogram at the end]
+#
+# Update interval and total duration are in seconds. Display histogram only requires a
+# 3rd option to exist to be enabled.
+#
# Copyright (C) 2008, 2009 Red Hat, Inc.
# Authors: Phil Knirsch
#
@@ -9,12 +15,12 @@
# 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
#
@@ -23,7 +29,19 @@
# Boston, MA 02110-1301, USA.
#
-global ifavg, iflast
+global ifavg, iflast, rtime, interval, duration, histogram
+
+probe begin
+{
+ rtime = 0;
+ interval = 5;
+ duration = 86400;
+ histogram = 0;
+
+%( $# > 0 %? interval = $1; %)
+%( $# > 1 %? duration = $2; %)
+%( $# > 2 %? histogram = 1; %)
+}
probe vfs.write
{
@@ -91,8 +109,40 @@ function print_activity()
print("\n")
}
-probe timer.s(5), end, error
+function print_histogram()
+{
+ 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 %-15s\n", pid, uid, dev, exec)
+ if (nxmit > 0) {
+ printf(" WRITE histogram\n")
+ print(@hist_log(ifavg[0, pid, dev, exec, uid]))
+ }
+ if (nrecv > 0) {
+ printf(" READ histogram\n")
+ print(@hist_log(ifavg[1, pid, dev, exec, uid]))
+ }
+ }
+ }
+}
+
+probe timer.s(1)
{
- print_activity()
+ rtime = rtime + 1;
+ if (rtime % interval == 0) {
+ print_activity()
+ }
+ if (rtime >= duration) {
+ exit();
+ }
}
+probe end, error
+{
+ if (histogram == 1) {
+ print_histogram();
+ }
+ exit();
+}
diff --git a/contrib/netdevstat b/contrib/netdevstat
index 491f376..44627a8 100755
--- a/contrib/netdevstat
+++ b/contrib/netdevstat
@@ -2,6 +2,12 @@
#
# netdevstat: A simple systemtap script to record network activity of
# processes and display statistics for transmit/receive operations
+#
+# Usage: netdevstat [Update interval] [Total duration] [Display histogram at the end]
+#
+# Update interval and total duration are in seconds. Display histogram only requires a
+# 3rd option to exist to be enabled.
+#
# Copyright (C) 2008, 2009 Red Hat, Inc.
# Authors: Phil Knirsch
#
@@ -23,7 +29,19 @@
# Boston, MA 02110-1301, USA.
#
-global ifavg, iflast;
+global ifavg, iflast, rtime, interval, duration, histogram
+
+probe begin
+{
+ rtime = 0;
+ interval = 5;
+ duration = 86400;
+ histogram = 0;
+
+%( $# > 0 %? interval = $1; %)
+%( $# > 1 %? duration = $2; %)
+%( $# > 2 %? histogram = 1; %)
+}
probe netdev.transmit
{
@@ -91,8 +109,42 @@ function print_activity()
print("\n")
}
-probe timer.s(5), end, error
+function print_histogram()
{
- print_activity()
+ 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 %-15s\n", pid, uid, dev, exec)
+
+ if (nxmit > 0) {
+ printf(" WRITE histogram\n")
+ print(@hist_log(ifavg[0, pid, dev, exec, uid]))
+ }
+
+ if (nrecv > 0) {
+ printf(" READ histogram\n")
+ print(@hist_log(ifavg[1, pid, dev, exec, uid]))
+ }
+ }
+ }
+}
+
+probe timer.s(1)
+{
+ rtime = rtime + 1;
+ if (rtime % interval == 0) {
+ print_activity()
+ }
+ if (rtime >= duration) {
+ exit();
+ }
}
+probe end, error
+{
+ if (histogram == 1) {
+ print_histogram();
+ }
+ exit();
+}
diff --git a/doc/README.utils b/doc/README.utils
index 66f9937..c6cb929 100644
--- a/doc/README.utils
+++ b/doc/README.utils
@@ -21,8 +21,22 @@ 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
+will start the scripts. Both can take up to 3 parameters:
+
+diskdevstat [Update interval] [Total duration] [Display histogram at the end]
+netdevstat [Update interval] [Total duration] [Display histogram at the end]
+
+Update interval:
+ Time in seconds between updates for the display. Default: 5
+
+Total duration:
+ Time in seconds for the whole run. Default: 86400 (1 day)
+
+Display histogram at the end:
+ Flag if at the end of the execution a histogram for the whole collected
+ data.
+
+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: