summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKey Meyer <kai@fiber.net>2009-04-27 19:12:14 -0400
committerFrank Ch. Eigler <fche@elastic.org>2009-04-27 19:12:14 -0400
commit676c0d81a7d650c8c4e25a7a2495d2b19b50b2b8 (patch)
tree043900d2ea5e7bcc827dae98db659cdf2d6e6b40
parent3b735623b8c878f52e0945074b4be4cdcd0bc257 (diff)
downloadsystemtap-steved-676c0d81a7d650c8c4e25a7a2495d2b19b50b2b8.tar.gz
systemtap-steved-676c0d81a7d650c8c4e25a7a2495d2b19b50b2b8.tar.xz
systemtap-steved-676c0d81a7d650c8c4e25a7a2495d2b19b50b2b8.zip
traceio: add human-readable byte-count output
-rwxr-xr-xtestsuite/systemtap.examples/io/traceio.stp21
1 files changed, 18 insertions, 3 deletions
diff --git a/testsuite/systemtap.examples/io/traceio.stp b/testsuite/systemtap.examples/io/traceio.stp
index a5d79fde..875000cb 100755
--- a/testsuite/systemtap.examples/io/traceio.stp
+++ b/testsuite/systemtap.examples/io/traceio.stp
@@ -1,6 +1,9 @@
#! /usr/bin/env stap
# traceio.stp
# Copyright (C) 2007 Red Hat, Inc., Eugene Teo <eteo@redhat.com>
+# Copyright (C) 2009 Kai Meyer <kai@unixlords.com>
+# Fixed a bug that allows this to run longer
+# And added the humanreadable function
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -19,11 +22,23 @@ probe vfs.write.return {
total_io[pid(),execname()] += $return
}
+function humanreadable(bytes) {
+ if (bytes > 1024*1024*1024) {
+ return sprintf("%d GiB", bytes/1024/1024/1024)
+ } else if (bytes > 1024*1024) {
+ return sprintf("%d MiB", bytes/1024/1024)
+ } else if (bytes > 1024) {
+ return sprintf("%d KiB", bytes/1024)
+ } else {
+ return sprintf("%d B", bytes)
+ }
+}
+
probe timer.s(1) {
foreach([p,e] in total_io- limit 10)
- printf("%8d %15s r: %8d MiB w: %8d MiB\n",
- p, e, reads[p,e]/1024/1024,
- writes[p,e]/1024/1024)
+ printf("%8d %15s r: %12s w: %12s\n",
+ p, e, humanreadable(reads[p,e]),
+ humanreadable(writes[p,e]))
printf("\n")
# Note we don't zero out reads, writes and total_io,
# so the values are cumulative since the script started.