From a4f3198f0b774528ef17dfb1ce5b3e70b6eb82fb Mon Sep 17 00:00:00 2001 From: William Cohen Date: Tue, 2 Feb 2010 14:19:02 -0500 Subject: Add iodevstats.stp example --- testsuite/systemtap.examples/io/iodevstats.meta | 13 +++++++++ testsuite/systemtap.examples/io/iodevstats.stp | 39 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 testsuite/systemtap.examples/io/iodevstats.meta create mode 100755 testsuite/systemtap.examples/io/iodevstats.stp (limited to 'testsuite/systemtap.examples/io') diff --git a/testsuite/systemtap.examples/io/iodevstats.meta b/testsuite/systemtap.examples/io/iodevstats.meta new file mode 100644 index 00000000..89277d2f --- /dev/null +++ b/testsuite/systemtap.examples/io/iodevstats.meta @@ -0,0 +1,13 @@ +title: List Executables Reading and Writing the Most Data by Device +name: iodevstats.stp +version: 1.0 +author: anonymous +keywords: io profiling +subsystem: io +status: production +exit: user-controlled +output: sorted-list +scope: system-wide +description: The iodevstats.stp script measures the amount of data successfully read and written by all the executables for each io device on the system. The output is sorted from greatest sum of bytes read and written to a device by an executable to the least. The output contains device major/minor number, the count of operations (reads and writes), the totals and averages for the number of bytes read and written. +test_check: stap -p4 iodevstats.stp +test_installcheck: stap iodevstats.stp -c "sleep 0.2" diff --git a/testsuite/systemtap.examples/io/iodevstats.stp b/testsuite/systemtap.examples/io/iodevstats.stp new file mode 100755 index 00000000..8925945f --- /dev/null +++ b/testsuite/systemtap.examples/io/iodevstats.stp @@ -0,0 +1,39 @@ +#! /usr/bin/env stap +global reads, writes, totals + +probe begin { printf("starting probe\n") } + +probe vfs.read.return { + count = $return + if ( count >= 0 ) { + e=execname(); + reads[e,dev] <<< count # statistics array + totals[e,dev] += count + } +} + +probe vfs.write.return { + count = $return + if (count >= 0 ) { + e=execname(); + writes[e,dev] <<< count # statistics array + totals[e,dev] += count + } +} + +probe end { + printf("\n%16s %8s %8s %8s %8s %8s %8s %8s\n", + "", "", "", "read", "read", "", "write", "write") + printf("%16s %8s %8s %8s %8s %8s %8s %8s\n", + "name", "device", "read", "KB tot", "B avg", "write", "KB tot", "B avg") + foreach ([name,dev] in totals- limit 20) { # sort by total io + printf("%16s %3d, %4d %8d %8d %8d %8d %8d %8d\n", + name, _dev_major(dev), _dev_minor(dev), + @count(reads[name,dev]), + (@count(reads[name,dev]) ? @sum(reads[name,dev])>>10 : 0 ), + (@count(reads[name,dev]) ? @avg(reads[name,dev]) : 0 ), + @count(writes[name,dev]), + (@count(writes[name,dev]) ? @sum(writes[name,dev])>>10 : 0 ), + (@count(writes[name,dev]) ? @avg(writes[name,dev]) : 0 )) + } +} -- cgit From 111dd9ac1d5e127b80c89be484be37ea326b449d Mon Sep 17 00:00:00 2001 From: William Cohen Date: Tue, 2 Feb 2010 14:32:38 -0500 Subject: Add nfs_func_users example. --- testsuite/systemtap.examples/io/nfs_func_users.meta | 13 +++++++++++++ testsuite/systemtap.examples/io/nfs_func_users.stp | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 testsuite/systemtap.examples/io/nfs_func_users.meta create mode 100755 testsuite/systemtap.examples/io/nfs_func_users.stp (limited to 'testsuite/systemtap.examples/io') diff --git a/testsuite/systemtap.examples/io/nfs_func_users.meta b/testsuite/systemtap.examples/io/nfs_func_users.meta new file mode 100644 index 00000000..e37d401a --- /dev/null +++ b/testsuite/systemtap.examples/io/nfs_func_users.meta @@ -0,0 +1,13 @@ +title: Tally the Number of NFS Functions Used by Each Process +name: nfs_func_users.stp +version: 1.0 +author: William Cohen +keywords: io profiling +subsystem: io +status: production +exit: user-controlled +output: sorted-list +scope: system-wide +description: The nfs_func_users.stp script counts the uses of NFS functions in the kernel on a per process bases. The output is sorted from the process with the greatest number of NFS functions called to the least. The output contains the executable name, the process number, and the total number of NFS functions called by the process. +test_check: stap -p4 nfs_func_users.stp +test_installcheck: stap nfs_func_users.stp -c "sleep 0.2" diff --git a/testsuite/systemtap.examples/io/nfs_func_users.stp b/testsuite/systemtap.examples/io/nfs_func_users.stp new file mode 100755 index 00000000..010db420 --- /dev/null +++ b/testsuite/systemtap.examples/io/nfs_func_users.stp @@ -0,0 +1,18 @@ +#!/usr/bin/env stap + +global nfsdcalls + +probe begin { + printf("Collecting top NFSD procs...\n") +} + +probe kernel.function("*@fs/nfs/*proc.c") ?, + module("nfs").function("*@fs/nfs/*proc.c") ? { + nfsdcalls[execname(), pid()]++ +} + +probe end { + printf("\nname(pid) nfs ops\n"); + foreach ([name,p] in nfsdcalls- limit 20) + printf("%s(%d) %d\n", name, p, nfsdcalls[name, p]) +} -- cgit