diff options
| -rwxr-xr-x | ext3calltimes | 160 | ||||
| -rwxr-xr-x | funccount.sh | 57 | ||||
| -rwxr-xr-x | kernelcalltimes | 177 | ||||
| -rw-r--r-- | lockd/lockd_listener.stp (renamed from lockd_listener.stp) | 0 | ||||
| -rw-r--r-- | net/inet_bind.stp (renamed from sys_bind/inet_bind.stp) | 0 | ||||
| -rw-r--r-- | net/ipv6_bind.stp (renamed from bind.stp) | 0 | ||||
| -rw-r--r-- | nfs/nfs4_lck.stp (renamed from nfs4_lck.stp) | 0 | ||||
| -rw-r--r-- | nfs/nfs4_lookup_root.stp (renamed from nfs4_lookup_root.stp) | 0 | ||||
| -rw-r--r-- | nfs/nfs4_xattr.stp (renamed from nfs4_xattr.stp) | 0 | ||||
| -rw-r--r-- | nfs/nfs_auth.stp (renamed from nfs_auth.stp) | 0 | ||||
| -rw-r--r-- | nfs/nfs_get_sb.stp (renamed from nfs_get_sb.stp) | 0 | ||||
| -rw-r--r-- | nfs/nfs_umount.stp (renamed from nfs_umount.stp) | 0 | ||||
| -rw-r--r-- | nfs/nfs_unlink.stp (renamed from nfsunlink.stp) | 0 | ||||
| -rw-r--r-- | nfs/nfsd_mount_opts.stp (renamed from mnt.stp) | 4 | ||||
| -rw-r--r-- | nfsd/nfsd4_acl.stp (renamed from nfsd4_acl.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd4_callback.stp (renamed from prob.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd4_secinfo.stp (renamed from nfsd4_secinfo.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd_auth.stp (renamed from nfsd_auth.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd_cacheio.stp (renamed from cacheio.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd_deleg.stp (renamed from nfsd_deleg.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd_dispatch.stp (renamed from nfsd_dispatch.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd_exports.stp (renamed from exports.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd_fh.stp (renamed from nfsd_fh.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd_lookup.stp (renamed from nfsd_lookup.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd_permission.stp (renamed from nfsd_permission.stp) | 0 | ||||
| -rw-r--r-- | nfsd/nfsd_setattr.stp (renamed from nfsd_setattr.stp) | 0 | ||||
| -rw-r--r-- | nfsd/svc_export.stp (renamed from svc_export.stp) | 0 | ||||
| -rw-r--r-- | sunrpc/rpc_killall.stp (renamed from rpc.stp) | 4 | ||||
| -rw-r--r-- | sunrpc/xprt.stp (renamed from xprt.stp) | 0 | ||||
| -rw-r--r-- | sys/open_namei.stp (renamed from open_namei.stp) | 0 | ||||
| -rw-r--r-- | sys/sysmount.stp (renamed from sysmount.stp) | 0 | ||||
| -rwxr-xr-x | syscalltimes | 248 |
32 files changed, 4 insertions, 646 deletions
diff --git a/ext3calltimes b/ext3calltimes deleted file mode 100755 index 675c9ab..0000000 --- a/ext3calltimes +++ /dev/null @@ -1,160 +0,0 @@ -#!/bin/bash -do_sort=0 -sort_ave=0 -sort_cnt=0 -sort_min=0 -sort_max=0 -sort_tot=0 -show_all=1 -pname="" -verbose="" -function usage { - echo "Usage: ext3calltimes [-Aachnmtv]" - echo " -A - Do all possible sorting" - echo " -a - sort by Ave ns" - echo " -c - sort by Count" - echo " -n - sort by Min ns" - echo " -m - sort by Max ns" - echo " -p - process name to monitor" - echo " -t - sort by Total ns" - echo " -v - turn on SystemTap debugging" - echo " -h - print this help text" -} -while getopts Aachnmp:tv option; do - case $option in - A) sort_ave=1; sort_cnt=1; sort_min=1; - sort_max=1; sort_tot=1; do_sort=1;; - a) sort_ave=1; do_sort=1;; - c) sort_cnt=1; do_sort=1 ;; - n) sort_min=1; do_sort=1 ;; - m) sort_max=1; do_sort=1 ;; - p) pname=$OPTARG;; - t) sort_tot=1; do_sort=1 ;; - v) verbose="-v "$verbose ;; - h|?|*) usage - exit 1;; - esac -done - -if [ $do_sort -eq 1 ]; then - show_all=0 -fi -echo "Creating and building SystemTap module..." - -stap "$verbose" -e ' -global timebyfunc, top -global start, pname_str - -probe begin { - pname_str = "'$pname'" - if (pname_str != "") { - printf("Collecting ext3 data on '%s' - type Ctrl-C to print output and exit...\n", pname_str); - } else - printf("Collecting ext3 data - type Ctrl-C to print output and exit...\n") -} - -probe module("ext3").function("*@fs/ext3/*") -{ - if (pname_str != "") { - if (execname() == pname_str) - start[probefunc(), tid()] = gettimeofday_ns() - } else - start[probefunc(), tid()] = gettimeofday_ns() -} -probe module("ext3").function("*@fs/ext3/*").return -{ - if (!([probefunc(), tid()] in start)) next - - delta = gettimeofday_ns() - start[probefunc(), tid()] - timebyfunc[probefunc()] <<< delta - - delete start[probefunc(), tid()] -} -function print_header() { - printf("%-26s %10s %12s %12s %12s %12s\n", - "Call", "Count", "Total ns", - "Avg ns", "Min ns", "Max ns") -} -probe end { - if ('$sort_ave' != 0) { - printf("\nSorted ext3 data by Avg ns \n") - print_header() - foreach (call in timebyfunc) - top[call] = @avg(timebyfunc[call]) - foreach (call in top- limit 20) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - delete top - } - if ('$sort_cnt' != 0) { - printf("\nSorted ext3 data by Count\n") - print_header() - foreach (call in timebyfunc) - top[call] = @count(timebyfunc[call]) - foreach (call in top- limit 20) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - delete top - } - if ('$sort_tot' != 0) { - printf("\nSorted ext3 data by Total ns\n") - print_header() - foreach (call in timebyfunc) - top[call] = @sum(timebyfunc[call]) - foreach (call in top- limit 20) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - delete top - } - if ('$sort_min' != 0) { - printf("\nSorted ext3 data by Min ns\n") - print_header() - foreach (call in timebyfunc) - top[call] = @min(timebyfunc[call]) - foreach (call in top- limit 20) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - delete top - } - if ('$sort_max' != 0) { - printf("\nSorted ext3 data by Max ns\n") - print_header() - foreach (call in timebyfunc) - top[call] = @min(timebyfunc[call]) - foreach (call in top- limit 20) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - delete top - } - if ('$show_all' != 0) { - print_header() - foreach (call in timebyfunc) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - } - delete timebyfunc -}' diff --git a/funccount.sh b/funccount.sh deleted file mode 100755 index 0ba1ee4..0000000 --- a/funccount.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -pname="" -verbose="" - -function usage { - echo "Usage: funccount [process]" -} -if [ $# -eq 1 ]; then - pname=$1 -fi - -echo "Creating and building SystemTap module..." - -stap "$verbose" -e ' -global timebyfunc, pages, page_sz -global start, pname_str, totcalls - -probe begin { - pname_str = "'$pname'" - printf("Collecting data for %s - type Ctrl-C to print output and exit...\n", pname_str); -} - -probe kernel.function("mpage_readpages") -{ - if ($nr_pages && execname() == pname_str) { - start[$nr_pages] = gettimeofday_ns() - pages=$nr_pages - } -} -probe kernel.function("mpage_readpages").return -{ - if (pages == 0) - next - - delta = gettimeofday_ns() - start[pages] - timebyfunc[pages] <<< delta - page_sz[pages] = pages - - delete start[pages] - pages=0 -} -function print_header() { - printf("%-19s %10s %12s\n", - "Call", "Count", "Total ns") -} -probe end { - print_header() - foreach (page in page_sz-) { - printf("mpage_readpages(%d) %10d %12d\n", page_sz[page], - @count(timebyfunc[page]), @sum(timebyfunc[page])) - totcalls += @count(timebyfunc[page]) - } - printf("Total Calls: %d\n", totcalls); - - delete page_sz - delete timebyfunc -}' diff --git a/kernelcalltimes b/kernelcalltimes deleted file mode 100755 index 0f88caf..0000000 --- a/kernelcalltimes +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash -do_sort=0 -sort_ave=0 -sort_cnt=0 -sort_min=0 -sort_max=0 -sort_tot=0 -show_all=1 -pname="" -verbose="" -function usage { - echo "Usage: ext3calltimes [-Aachnmtv]" - echo " -A - Do all possible sorting" - echo " -a - sort by Ave ns" - echo " -c - sort by Count" - echo " -n - sort by Min ns" - echo " -m - sort by Max ns" - echo " -p - process name to monitor" - echo " -t - sort by Total ns" - echo " -v - turn on SystemTap debugging" - echo " -h - print this help text" -} -while getopts Aachnmp:tv option; do - case $option in - A) sort_ave=1; sort_cnt=1; sort_min=1; - sort_max=1; sort_tot=1; do_sort=1;; - a) sort_ave=1; do_sort=1;; - c) sort_cnt=1; do_sort=1 ;; - n) sort_min=1; do_sort=1 ;; - m) sort_max=1; do_sort=1 ;; - p) pname=$OPTARG;; - t) sort_tot=1; do_sort=1 ;; - v) verbose="-v "$verbose ;; - h|?|*) usage - exit 1;; - esac -done - -if [ $do_sort -eq 1 ]; then - show_all=0 -fi -echo "Creating and building SystemTap module..." - -stap "$verbose" -e ' -global timebyfunc, top -global start, pname_str - -probe begin { - pname_str = "'$pname'" - if (pname_str != "") { - printf("Collecting ext3 data on '%s' - type Ctrl-C to print output and exit...\n", pname_str); - } else - printf("Collecting ext3 data - type Ctrl-C to print output and exit...\n") -} - -probe kernel.function("*@mm/readahead.c") -{ - if (pname_str != "") { - if (execname() == pname_str) - start[probefunc(), tid()] = gettimeofday_ns() - } else - start[probefunc(), tid()] = gettimeofday_ns() -} -probe kernel.function("*@mm/readahead.c").return -{ - if (!([probefunc(), tid()] in start)) next - - delta = gettimeofday_ns() - start[probefunc(), tid()] - timebyfunc[probefunc()] <<< delta - - delete start[probefunc(), tid()] -} -probe kernel.function("*@mm/filemap.c") -{ - if (pname_str != "") { - if (execname() == pname_str) - start[probefunc(), tid()] = gettimeofday_ns() - } else - start[probefunc(), tid()] = gettimeofday_ns() -} -probe kernel.function("*@mm/filemap.c").return -{ - if (!([probefunc(), tid()] in start)) next - - delta = gettimeofday_ns() - start[probefunc(), tid()] - timebyfunc[probefunc()] <<< delta - - delete start[probefunc(), tid()] -} -function print_header() { - printf("%-26s %10s %12s %12s %12s %12s\n", - "Call", "Count", "Total ns", - "Avg ns", "Min ns", "Max ns") -} -probe end { - if ('$sort_ave' != 0) { - printf("\nSorted ext3 data by Avg ns \n") - print_header() - foreach (call in timebyfunc) - top[call] = @avg(timebyfunc[call]) - foreach (call in top- limit 20) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - delete top - } - if ('$sort_cnt' != 0) { - printf("\nSorted ext3 data by Count\n") - print_header() - foreach (call in timebyfunc) - top[call] = @count(timebyfunc[call]) - foreach (call in top- limit 20) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - delete top - } - if ('$sort_tot' != 0) { - printf("\nSorted ext3 data by Total ns\n") - print_header() - foreach (call in timebyfunc) - top[call] = @sum(timebyfunc[call]) - foreach (call in top- limit 20) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - delete top - } - if ('$sort_min' != 0) { - printf("\nSorted ext3 data by Min ns\n") - print_header() - foreach (call in timebyfunc) - top[call] = @min(timebyfunc[call]) - foreach (call in top- limit 20) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - delete top - } - if ('$sort_max' != 0) { - printf("\nSorted ext3 data by Max ns\n") - print_header() - foreach (call in timebyfunc) - top[call] = @min(timebyfunc[call]) - foreach (call in top- limit 20) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - delete top - } - if ('$show_all' != 0) { - print_header() - foreach (call in timebyfunc) - printf("%-26s %10d %12d %12d %12d %12d\n", call, - @count(timebyfunc[call]), - @sum(timebyfunc[call]), - @avg(timebyfunc[call]), - @min(timebyfunc[call]), - @max(timebyfunc[call])) - } - delete timebyfunc -}' diff --git a/lockd_listener.stp b/lockd/lockd_listener.stp index ff845e6..ff845e6 100644 --- a/lockd_listener.stp +++ b/lockd/lockd_listener.stp diff --git a/sys_bind/inet_bind.stp b/net/inet_bind.stp index 621473a..621473a 100644 --- a/sys_bind/inet_bind.stp +++ b/net/inet_bind.stp diff --git a/bind.stp b/net/ipv6_bind.stp index 2a9db1c..2a9db1c 100644 --- a/bind.stp +++ b/net/ipv6_bind.stp diff --git a/nfs4_lck.stp b/nfs/nfs4_lck.stp index b170a95..b170a95 100644 --- a/nfs4_lck.stp +++ b/nfs/nfs4_lck.stp diff --git a/nfs4_lookup_root.stp b/nfs/nfs4_lookup_root.stp index 592af25..592af25 100644 --- a/nfs4_lookup_root.stp +++ b/nfs/nfs4_lookup_root.stp diff --git a/nfs4_xattr.stp b/nfs/nfs4_xattr.stp index 59b2280..59b2280 100644 --- a/nfs4_xattr.stp +++ b/nfs/nfs4_xattr.stp diff --git a/nfs_auth.stp b/nfs/nfs_auth.stp index c7fc739..c7fc739 100644 --- a/nfs_auth.stp +++ b/nfs/nfs_auth.stp diff --git a/nfs_get_sb.stp b/nfs/nfs_get_sb.stp index fed1c8e..fed1c8e 100644 --- a/nfs_get_sb.stp +++ b/nfs/nfs_get_sb.stp diff --git a/nfs_umount.stp b/nfs/nfs_umount.stp index e5f1164..e5f1164 100644 --- a/nfs_umount.stp +++ b/nfs/nfs_umount.stp diff --git a/nfsunlink.stp b/nfs/nfs_unlink.stp index 7fc417c..7fc417c 100644 --- a/nfsunlink.stp +++ b/nfs/nfs_unlink.stp diff --git a/mnt.stp b/nfs/nfsd_mount_opts.stp index 7a6df87..cd2ed96 100644 --- a/mnt.stp +++ b/nfs/nfsd_mount_opts.stp @@ -10,5 +10,5 @@ probe module("nfs").function("nfs_compare_mount_options") printf("acdirmin %d/%d\n", $a->acdirmin, $b->acdirmin); printf("acdirmax %d/%d\n", $a->acdirmax, $b->acdirmax); } -probe begin { log("starting probe") } -probe end { log("ending probe") } +probe begin { log("starting nfs_mount_opts") } +probe end { log("ending nfs_mount_opts probe") } diff --git a/nfsd4_acl.stp b/nfsd/nfsd4_acl.stp index e46403f..e46403f 100644 --- a/nfsd4_acl.stp +++ b/nfsd/nfsd4_acl.stp diff --git a/prob.stp b/nfsd/nfsd4_callback.stp index b0defc6..b0defc6 100644 --- a/prob.stp +++ b/nfsd/nfsd4_callback.stp diff --git a/nfsd4_secinfo.stp b/nfsd/nfsd4_secinfo.stp index aa91a26..aa91a26 100644 --- a/nfsd4_secinfo.stp +++ b/nfsd/nfsd4_secinfo.stp diff --git a/nfsd_auth.stp b/nfsd/nfsd_auth.stp index 6e2b4d2..6e2b4d2 100644 --- a/nfsd_auth.stp +++ b/nfsd/nfsd_auth.stp diff --git a/cacheio.stp b/nfsd/nfsd_cacheio.stp index 3dc0a8d..3dc0a8d 100644 --- a/cacheio.stp +++ b/nfsd/nfsd_cacheio.stp diff --git a/nfsd_deleg.stp b/nfsd/nfsd_deleg.stp index 02c7590..02c7590 100644 --- a/nfsd_deleg.stp +++ b/nfsd/nfsd_deleg.stp diff --git a/nfsd_dispatch.stp b/nfsd/nfsd_dispatch.stp index 15f9e6f..15f9e6f 100644 --- a/nfsd_dispatch.stp +++ b/nfsd/nfsd_dispatch.stp diff --git a/exports.stp b/nfsd/nfsd_exports.stp index ec73af8..ec73af8 100644 --- a/exports.stp +++ b/nfsd/nfsd_exports.stp diff --git a/nfsd_fh.stp b/nfsd/nfsd_fh.stp index 7c7fdbe..7c7fdbe 100644 --- a/nfsd_fh.stp +++ b/nfsd/nfsd_fh.stp diff --git a/nfsd_lookup.stp b/nfsd/nfsd_lookup.stp index 1c9e9b4..1c9e9b4 100644 --- a/nfsd_lookup.stp +++ b/nfsd/nfsd_lookup.stp diff --git a/nfsd_permission.stp b/nfsd/nfsd_permission.stp index 7e27ca5..7e27ca5 100644 --- a/nfsd_permission.stp +++ b/nfsd/nfsd_permission.stp diff --git a/nfsd_setattr.stp b/nfsd/nfsd_setattr.stp index b0cd7e0..b0cd7e0 100644 --- a/nfsd_setattr.stp +++ b/nfsd/nfsd_setattr.stp diff --git a/svc_export.stp b/nfsd/svc_export.stp index eb36538..eb36538 100644 --- a/svc_export.stp +++ b/nfsd/svc_export.stp diff --git a/rpc.stp b/sunrpc/rpc_killall.stp index 03d2bfa..7da2eb6 100644 --- a/rpc.stp +++ b/sunrpc/rpc_killall.stp @@ -11,6 +11,6 @@ probe module("sunrpc").function("rpc_release_calldata") { printf("rpc_release_calldata: ops %p calldata %p\n", $ops, $calldata); } -probe begin { log("starting probe") } -probe end { log("ending probe") } +probe begin { log("starting rpc_killall probe") } +probe end { log("ending rpc_killall probe") } diff --git a/xprt.stp b/sunrpc/xprt.stp index b6a0c73..b6a0c73 100644 --- a/xprt.stp +++ b/sunrpc/xprt.stp diff --git a/open_namei.stp b/sys/open_namei.stp index 3dda40a..3dda40a 100644 --- a/open_namei.stp +++ b/sys/open_namei.stp diff --git a/sysmount.stp b/sys/sysmount.stp index 24a5190..24a5190 100644 --- a/sysmount.stp +++ b/sys/sysmount.stp diff --git a/syscalltimes b/syscalltimes deleted file mode 100755 index 84ca77a..0000000 --- a/syscalltimes +++ /dev/null @@ -1,248 +0,0 @@ -#!/bin/bash - -# Syscalltimes systemtap script -# Copyright (C) 2007 IBM Corp. -# -# This file is part of systemtap, and is free software. You can -# redistribute it and/or modify it under the terms of the GNU General -# Public License (GPL); either version 2, or (at your option) any -# later version. - -### -### syscalltime - Combination shell/systemtap script to measure system call -### counts and times. Can be filtered by process IDs, process -### names and users. -### - -# Filter options -F_PIDSTR=""; F_PID=0 # Filter by process ID -F_EXECSTR=""; F_EXEC=0 # Filter by process name -F_UIDSTR=""; F_UID=0 # Filter by user -FILTER=0 # Any filters specified? - -# Print options -P_TOTALS=0 # Print totals -P_VERBOSE_STR="" # Print verbose build output - -DELIM="," - -function usage { - echo "USAGE: syscalltimes [-n pname]... [-p pid]... [-u username]..." - echo " [-v]... [-t] [-h]" - echo " -n pname # filter by this process name" - echo " -p pid # filter by this process ID" - echo " -u username # filter by this user" - echo " -t # print totals (default with filters: OFF" - echo " default without filters: ON)" - echo " -v # print verbose output during SystemTap module creation" - echo " -h # print this help text" - echo "" - echo "NOTE: This script can take long time to build. Use -v[vv] to monitor" - echo " the module creation and build process." -} - -# Process options -while getopts n:p:u:vth option; do - case $option in - n) let "F_EXEC++" - F_EXECSTR=$OPTARG$DELIM$F_EXECSTR ;; - - p) let "F_PID++" - F_PIDSTR=$OPTARG$DELIM$F_PIDSTR ;; - - u) uid=`awk -F: '$1 == name {print $3}' name=$OPTARG /etc/passwd` - if [[ $uid != "" ]]; then - let "F_UID++" - F_UIDSTR=$uid$DELIM$F_UIDSTR - else - echo "ERROR: Unknown user:" $OPTARG - let "ERROR++" - fi ;; - - v) P_VERBOSE_STR="-v "$P_VERBOSE_STR ;; - - t) P_TOTALS=1 ;; - - h|?|*) usage - exit 1 ;; - esac -done - -if [[ $ERROR > 0 ]]; then - exit 1 -fi - -if [[ $F_EXEC > 0 || $F_PID > 0 || $F_UID > 0 ]]; then - FILTER=1 -fi - -echo "Creating and building SystemTap module..." - -# -# SystemTap script -# -stap $P_VERBOSE_STR -e ' -global start, timebycall, timebypid, timebyuid, timebyexec -global f_exec_str, f_pid_str, f_uid_str -global f_exec, f_pid, f_uid -global prt_totals, filter_str - -probe begin { - printf("Collecting data - type Ctrl-C to print output and exit...\n") - - # If no filters specified, skip filter processing - if ('$FILTER' == 0) { - filter_str = " (unfiltered)" - prt_totals = 1 // On by default if no filtering - next - } else - filter_str = " (filtered)" - - prt_totals = '$P_TOTALS' - f_exec_str = "'$F_EXECSTR'" - f_pid_str = "'$F_PIDSTR'" - f_uid_str = "'$F_UIDSTR'" - - delim = "'$DELIM'" - - # Process names - if ('$F_EXEC') { - pname = tokenize(f_exec_str, delim) - while (pname != "") { - f_exec[pname] = 1 - pname = tokenize("", delim) - } - } - - # Process IDs - if ('$F_PID') { - pid = tokenize(f_pid_str, delim) - while (pid != "") { - f_pid[strtol(pid, 10)] = 1 - pid = tokenize("", delim) - } - } - - # User IDs - if ('$F_UID') { - uid = tokenize(f_uid_str, delim) - while (uid != "") { - f_uid[strtol(uid, 10)] = 1 - uid = tokenize("", delim) - } - } -} - -probe syscall.* { - start[name, tid()] = gettimeofday_ns() -} - -probe syscall.*.return { - # Skip if we have not seen this before - if (!([name, tid()] in start)) next - - delta = gettimeofday_ns() - start[name, tid()] - - # Check filters - if ('$FILTER') { - target = 0 - if (pid() in f_pid) { - timebypid[name, pid()] <<< delta - target = 1 - } - if (uid() in f_uid) { - timebyuid[name, uid()] <<< delta - target = 1 - } - if (execname() in f_exec) { - timebyexec[name, execname()] <<< delta - target = 1 - } - } else - target = 1 - - # Totals - if (target && prt_totals) - timebycall[name] <<< delta - - delete start[name, tid()] -} - -function print_header() { - printf("%22s %10s %12s %12s %12s %12s\n", - "System Call", "Count", "Total ns", - "Avg ns", "Min ns", "Max ns") -} - -probe end { - if (prt_totals) { - printf("\nTimes for all processes%s:\n\n", filter_str) - print_header() - foreach (call in timebycall) - printf("%22s %10d %12d %12d %12d %12d\n", call, - @count(timebycall[call]), - @sum(timebycall[call]), - @avg(timebycall[call]), - @min(timebycall[call]), - @max(timebycall[call])) - } - - if ('$F_PID') { - curpid = -1 - foreach ([call, pid-] in timebypid) { - if (curpid != pid) { - curpid = pid - printf("\nTimes for process ID %d:\n\n", curpid) - print_header() - } - printf("%22s %10d %12d %12d %12d %12d\n", call, - @count(timebypid[call, pid]), - @sum(timebypid[call, pid]), - @avg(timebypid[call, pid]), - @min(timebypid[call, pid]), - @max(timebypid[call, pid])) - } - printf("\n") - } - - if ('$F_EXEC') { - curexec = "" - foreach ([call, exec-] in timebyexec) { - if (curexec != exec) { - curexec = exec - printf("\nTimes for process name %s:\n\n", curexec) - print_header() - } - printf("%22s %10d %12d %12d %12d %12d\n", call, - @count(timebyexec[call, exec]), - @sum(timebyexec[call, exec]), - @avg(timebyexec[call, exec]), - @min(timebyexec[call, exec]), - @max(timebyexec[call, exec])) - } - printf("\n") - } - - if ('$F_UID') { - curuid = -1 - foreach ([call, uid-] in timebyuid) { - if (curuid != uid) { - curuid = uid - printf("\nTimes for user ID %d:\n\n", curuid) - print_header() - } - printf("%22s %10d %12d %12d %12d %12d\n", call, - @count(timebyuid[call, uid]), - @sum(timebyuid[call, uid]), - @avg(timebyuid[call, uid]), - @min(timebyuid[call, uid]), - @max(timebyuid[call, uid])) - } - printf("\n") - } - - delete timebycall - delete timebypid - delete timebyuid - delete timebyexec -}' |
