diff options
| author | Steve Dickson <steved@redhat.com> | 2008-10-23 08:59:29 -0400 |
|---|---|---|
| committer | Steve Dickson <steved@redhat.com> | 2008-10-23 08:59:29 -0400 |
| commit | 0a28dada02f341c3a5fdceb259f6afd0c4722a1f (patch) | |
| tree | 62963833db09a6a8506a4ffc32738194761c012c /stap_tutorial-1.0/examples | |
| parent | 85014ffa32c9c07487fa729d81a0795c4c3ea8c4 (diff) | |
| download | systemtap-0a28dada02f341c3a5fdceb259f6afd0c4722a1f.tar.gz systemtap-0a28dada02f341c3a5fdceb259f6afd0c4722a1f.tar.xz systemtap-0a28dada02f341c3a5fdceb259f6afd0c4722a1f.zip | |
Added tracemarks/nfs_lookup.mark
removed some old stuff
Diffstat (limited to 'stap_tutorial-1.0/examples')
| -rwxr-xr-x | stap_tutorial-1.0/examples/cmd-eval/cmd-eval-futexes.stp | 44 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/cmd-eval/cmd-eval-opens.stp | 73 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/cmd-eval/cmd-eval-rw.stp | 104 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/cmd-eval/cmd-eval-syscalls.stp | 33 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/fs-io-1.stp | 26 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/fs-io-2.stp | 26 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/helloworld.stp | 6 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/probe-types.stp | 38 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/read-write-1.stp | 25 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/read-write-2.stp | 27 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/read-write-3.stp | 35 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/socktop | 318 | ||||
| -rw-r--r-- | stap_tutorial-1.0/examples/tapset/fs.stp | 27 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/top-cs.stp | 29 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/top-ext3calls.stp | 19 | ||||
| -rwxr-xr-x | stap_tutorial-1.0/examples/top-syscalls.stp | 16 |
16 files changed, 0 insertions, 846 deletions
diff --git a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-futexes.stp b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-futexes.stp deleted file mode 100755 index 8f2b414..0000000 --- a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-futexes.stp +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env stap - -global target_pids, target_execs -global thread_thislock, thread_blocktime -global FUTEX_WAIT = 0, FUTEX_WAKE = 1 -global lock_waits - -probe process.exec_complete { - if (success && (ppid() in target_pids || pid() == target())) - target_pids[pid()] = kernel_string($filename) -} - -probe syscall.futex { - if (!(pid() in target_pids)) next - - if (op != FUTEX_WAIT) next # ignore originators of WAKE events - - t = tid() - thread_thislock[t] = $uaddr - thread_blocktime[t] = gettimeofday_us() -} - -probe syscall.futex.return { - if (!(pid() in target_pids)) next - - if (op != FUTEX_WAIT) next # ignore originators of WAKE events - - t = tid() - ts = thread_blocktime[t] - if (ts) { - elapsed = gettimeofday_us() - ts - lock_waits[pid(), thread_thislock[t]] <<< elapsed - delete thread_blocktime[t] - delete thread_thislock[t] - } -} - -probe end { - foreach ([pid, lock] in lock_waits) - printf ("%s[%d] lock %p contended %5d times, %9d avg us\n", - target_pids[pid], pid, lock, - @count(lock_waits[pid, lock]), - @avg(lock_waits[pid, lock])) -} diff --git a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-opens.stp b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-opens.stp deleted file mode 100755 index a040059..0000000 --- a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-opens.stp +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env stap - -global target_pids, target_execs -global opens_by_file_success, opens_by_exec_success, total_opens_success -global opens_by_file_fail, opens_by_exec_fail, total_opens_fail -global closes_by_exec, total_closes -global open_failure_by_type - -probe process.exec_complete { - if (success && (ppid() in target_pids || pid() == target())) { - target_pids[pid()] = kernel_string($filename) - target_execs[kernel_string($filename)] ++ - } -} - -probe syscall.open.return { - if (!(pid() in target_pids)) next - - if ($return >= 0) { - opens_by_exec_success[target_pids[pid()]] ++ - opens_by_file_success[user_string($filename)] ++ - total_opens_success ++ - } else { - opens_by_exec_fail[target_pids[pid()]] ++ - opens_by_file_fail[user_string($filename)] ++ - open_failure_by_type[retstr] ++ - total_opens_fail ++ - } -} - -probe syscall.close { - if (!(pid() in target_pids)) next - - closes_by_exec[target_pids[pid()]] ++ - total_closes ++ -} - -probe end { - prt_limit = 10 - - printf ("Total opens: %d (%d succeeded, %d failed)\n", - total_opens_success + total_opens_fail, - total_opens_success, total_opens_fail) - printf ("Total closes: %d\n\n", total_closes) - - printf ("# Binary Instances:\n") - foreach(name in target_execs) - printf("%d\t%s\n", target_execs[name], name) - - printf("\n# Successful Opens by Binary:\n") - foreach (name in opens_by_exec_success-) - printf("%d\t%s\n", opens_by_exec_success[name], name) - - printf("\n# Failed Opens by Binary:\n") - foreach (name in opens_by_exec_fail-) - printf("%d\t%s\n", opens_by_exec_fail[name], name) - - printf("\n# Successful Opens by File (top %d):\n", prt_limit) - foreach (name in opens_by_file_success- limit prt_limit) - printf("%d\t%s\n", opens_by_file_success[name], name) - - printf("\n# Failed Opens by File: (top %d)\n", prt_limit) - foreach (name in opens_by_file_fail- limit prt_limit) - printf("%d\t%s\n", opens_by_file_fail[name], name) - - printf("\n# Closes by Binary:\n") - foreach (name in closes_by_exec-) - printf("%d\t%s\n", closes_by_exec[name], name) - - printf("\n# Open Failures by Type:\n") - foreach (type in open_failure_by_type-) - printf("%d\t%s\n", open_failure_by_type[type], type) -} diff --git a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-rw.stp b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-rw.stp deleted file mode 100755 index f5107ff..0000000 --- a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-rw.stp +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env stap - -global target_pids, target_execs -global reads_by_file, reads_by_exec -global writes_by_file, writes_by_exec -global files, execs - -%{ -#include <linux/file.h> -%} - -function fd2name:string (fd:long) -%{ - char *start = NULL, buf[MAXSTRINGLEN]; - struct file *file = NULL; - struct vfsmount *mnt = NULL; - struct dentry *dentry = NULL; - - file = fget(THIS->fd); - if (file) { - mnt = (struct vfsmount *) kread(&(file->f_path.mnt)); - dentry = (struct dentry *) kread(&(file->f_path.dentry)); - if (mnt && dentry) - start = d_path(dentry, mnt, buf, MAXSTRINGLEN); - if (start > 0) - strlcpy(THIS->__retvalue, start, MAXSTRINGLEN); - fput(file); - } - CATCH_DEREF_FAULT(); -%} - -probe process.exec_complete { - if (success && (ppid() in target_pids || pid() == target())) { - target_pids[pid()] = kernel_string($filename) - target_execs[kernel_string($filename)] ++ - } -} - -probe syscall.read.return, syscall.readv.return { - if (!(pid() in target_pids)) next - - if ($return >= 0) { - fn = fd2name($fd) - exec = execname() - reads_by_file[fn] <<< $return - reads_by_exec[exec] <<< $return - files[fn] ++ - execs[exec] ++ - } -} - -probe syscall.write.return, syscall.writev.return { - if (!(pid() in target_pids)) next - - if ($return >= 0) { - fn = fd2name($fd) - exec = execname() - writes_by_file[fn] <<< $return - writes_by_exec[exec] <<< $return - files[fn] ++ - execs[exec] ++ - } -} - -probe end { - foreach (file in reads_by_file) { - total_read_cnt += @count(reads_by_file[file]) - total_read_bytes += @sum(reads_by_file[file]) - } - - foreach (file in writes_by_file) { - total_write_cnt += @count(writes_by_file[file]) - total_write_bytes += @sum(writes_by_file[file]) - } - - printf ("Total reads : %d cnt, %d KB\n", - total_read_cnt, total_read_bytes/1024) - printf ("Total writes: %d cnt, %d KB\n", - total_write_cnt, total_write_bytes/1024) - - printf ("\n# Binary Instances:\n") - foreach (name in target_execs) - printf("%d\t%s\n", target_execs[name], name) - - printf ("\nIO by Process:\n") - foreach (name in execs-) { - rd_cnt = @count(reads_by_exec[name]) - rd_sum = (rd_cnt > 0 ? @sum(reads_by_exec[name])/1024 : 0) - wr_cnt = @count(writes_by_exec[name]) - wr_sum = (wr_cnt > 0 ? @sum(writes_by_exec[name])/1024 : 0) - printf("%5d rds, %5d KB rd, %5d wrs, %5d KB wr: %s\n", - rd_cnt, rd_sum, wr_cnt, wr_sum, name) - } - - printf ("\nIO by File:\n") - foreach (name in files-) { - rd_cnt = @count(reads_by_file[name]) - rd_sum = (rd_cnt > 0 ? @sum(reads_by_file[name])/1024 : 0) - wr_cnt = @count(writes_by_file[name]) - wr_sum = (wr_cnt > 0 ? @sum(writes_by_file[name])/1024 : 0) - printf("%5d rds, %5d KB rd, %5d wrs, %5d KB wr: %s\n", - rd_cnt, rd_sum, wr_cnt, wr_sum, name) - } -} diff --git a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-syscalls.stp b/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-syscalls.stp deleted file mode 100755 index 17e7d95..0000000 --- a/stap_tutorial-1.0/examples/cmd-eval/cmd-eval-syscalls.stp +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env stap - -global target_pids, target_execs -global syscalls_per_exec, syscalls_by_exec, syscalls - -probe process.exec_complete { - if (success && (ppid() in target_pids || pid() == target())) { - target_pids[pid()] = kernel_string($filename) - target_execs[kernel_string($filename)] ++ - } -} - -probe syscall.* { - if (!(pid() in target_pids)) next - - syscalls_by_exec[name, target_pids[pid()]] ++ - syscalls_per_exec[target_pids[pid()]] ++ - syscalls[name] ++ -} - -probe end { - printf("\nIndividual System Calls by Binary:\n" ) - foreach ([name, exec] in syscalls_by_exec-) - printf("%8d %-20s\t%s\n", syscalls_by_exec[name, exec], name, exec) - - printf("\nTotal System Calls by Binary:\n" ) - foreach (exec in syscalls_per_exec-) - printf("%8d %-20s\n", syscalls_per_exec[exec], exec) - - printf("\nSystem Calls over all:\n") - foreach (name in syscalls-) - printf("%8d %-20s\n", syscalls[name], name) -} diff --git a/stap_tutorial-1.0/examples/fs-io-1.stp b/stap_tutorial-1.0/examples/fs-io-1.stp deleted file mode 100755 index 83462e9..0000000 --- a/stap_tutorial-1.0/examples/fs-io-1.stp +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env stap - -global reads, writes, total_io - -probe fs.read.return { - pname = execname() - reads[pname] += bytes - total_io[pname] += bytes -} - -probe fs.write.return { - pname = execname() - writes[pname] += bytes - total_io[pname] += bytes -} - -probe timer.s(10) { - foreach(pname in total_io- limit 10) - printf("%15s r: %8d KB w: %8d KB\n", - pname, reads[pname]/1024, writes[pname]/1024) - printf("\n") - delete reads - delete writes - delete total_io -} - diff --git a/stap_tutorial-1.0/examples/fs-io-2.stp b/stap_tutorial-1.0/examples/fs-io-2.stp deleted file mode 100755 index 09036b2..0000000 --- a/stap_tutorial-1.0/examples/fs-io-2.stp +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env stap - -global reads, writes, total_io - -probe fs.read.return { - fn = file2name($file) - reads[fn] += bytes - total_io[fn] += bytes -} - -probe fs.write.return { - fn = file2name($file) - writes[fn] += bytes - total_io[fn] += bytes -} - -probe timer.s(10) { - foreach(fname in total_io- limit 20) { - printf("r: %8d KB w: %8d KB %s\n", - reads[fname]/1024, writes[fname]/1024, fname) - } - printf("\n") - delete reads - delete writes - delete total_io -} diff --git a/stap_tutorial-1.0/examples/helloworld.stp b/stap_tutorial-1.0/examples/helloworld.stp deleted file mode 100755 index e08ecb8..0000000 --- a/stap_tutorial-1.0/examples/helloworld.stp +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env stap - -probe begin { - printf("Hello World!\n") - exit() -} diff --git a/stap_tutorial-1.0/examples/probe-types.stp b/stap_tutorial-1.0/examples/probe-types.stp deleted file mode 100755 index 08da226..0000000 --- a/stap_tutorial-1.0/examples/probe-types.stp +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env stap - -global reads, writes -global sema_contentions -global ext3_releases - -probe begin { - printf("Collecting data... ") -} - -probe kernel.function("sys_read") { - reads++ -} - -probe syscall.write { - writes++ -} - -probe timer.s (20) { - exit() -} - -probe module("ext3").function("ext3_release_file") { - ext3_releases++ -} - -probe kernel.statement("*@lib/semaphore-sleepers.c:82") { - sema_contentions++ -} - -probe end { - printf("done\n") - printf("# ext3 file releases = %d\n", ext3_releases) - printf("# semaphore contentions = %d\n", sema_contentions) - printf("# reads = %d\n", reads) - printf("# writes = %d\n", writes) -} - diff --git a/stap_tutorial-1.0/examples/read-write-1.stp b/stap_tutorial-1.0/examples/read-write-1.stp deleted file mode 100755 index 5abd35f..0000000 --- a/stap_tutorial-1.0/examples/read-write-1.stp +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env stap - -global reads, writes - -probe begin { - printf("Collecting data...\n") -} - -probe syscall.read { - reads[execname()]++ -} - -probe syscall.write { - writes[execname()]++ -} - -probe end { - printf("Reads by process name:\n") - foreach (name in reads-) - printf("%d\t%s\n", reads[name], name) - - printf("Writes by process name:\n") - foreach (name in writes-) - printf("%d\t%s\n", writes[name], name) -} diff --git a/stap_tutorial-1.0/examples/read-write-2.stp b/stap_tutorial-1.0/examples/read-write-2.stp deleted file mode 100755 index d6a647b..0000000 --- a/stap_tutorial-1.0/examples/read-write-2.stp +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env stap - -global reads, writes - -probe begin { - printf("Collecting data...\n") -} - -probe syscall.read.return { - if ($return > 0) - reads[execname()] += $return -} - -probe syscall.write.return { - if ($return > 0) - writes[execname()] += $return -} - -probe end { - printf("Bytes read by process name:\n") - foreach (name in reads-) - printf("%10d %s\n", reads[name], name) - - printf("Bytes written by process name:\n") - foreach (name in writes-) - printf("%10d %s\n", writes[name], name) -} diff --git a/stap_tutorial-1.0/examples/read-write-3.stp b/stap_tutorial-1.0/examples/read-write-3.stp deleted file mode 100755 index fef85a5..0000000 --- a/stap_tutorial-1.0/examples/read-write-3.stp +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env stap - -global reads, writes - -probe begin { - printf("Collecting data...\n") -} - -probe syscall.read.return { - if ($return > 0) - reads <<< $return -} - -probe syscall.write.return { - if ($return > 0) - writes <<< $return -} - -probe end { - printf("Read sizes summary:\n") - - printf("\tcount:%d, sum:%d, avg:%d, min:%d, max:%d\n", - @count(reads), @sum(reads), @avg(reads), - @min(reads), @max(reads)) - - print(@hist_log(reads)) - - printf("Write sizes summary:\n") - - printf("\tcount:%d, sum:%d, avg:%d, min:%d, max:%d\n", - @count(writes), @sum(writes), @avg(writes), - @min(writes), @max(writes)) - - print(@hist_log(writes)) -} diff --git a/stap_tutorial-1.0/examples/socktop b/stap_tutorial-1.0/examples/socktop deleted file mode 100755 index 123e37e..0000000 --- a/stap_tutorial-1.0/examples/socktop +++ /dev/null @@ -1,318 +0,0 @@ -#!/bin/bash - -# Socktop systemtap script -# Copyright (C) 2006 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. - -### -### socktop - Combination shell/systemtap script to track reads and writes -### on sockets by process. Can be filtered by process IDs and -### names, protocols, protocol families, users and socket type. -### - -# Filter options -F_PROTSTR=""; F_PROT=0 # Filter by protocol -F_FAMSTR=""; F_FAM=0 # Filter by protocol family -F_TYPESTR=""; F_TYPE=0 # Filter by socket type -F_PIDSTR=""; F_PID=0 # Filter by process ID -F_NAMESTR=""; F_NAME=0 # Filter by process name -F_UIDSTR=""; F_UID=0 # Filter by user -FILTER=0 # Any filters specified? - -# Print options -P_INTERVAL=5 # default interval between output -P_DEVICES=0 # default is don't display network device traffic -P_NUMTOP=10 # default number of processes and network devices to print - -DELIM="," - -function usage { - echo "USAGE: socktop [-d] [-i interval] [-N num] [-P protocol]... [-f family]..." - echo " [-t stype]... [-n pname]... [-p pid]... [-u username]... [-h]" - echo " -d # print network device traffic (default: off)" - echo " -i interval # interval in seconds between printing (default: $P_INTERVAL)" - echo " -N num # number of top processes and devices to print (default: $P_NUMTOP)" - echo " -f family # this protocol family only (default: all)" - echo " -P protocol # this protocol only (default: all)" - echo " -t stype # this socket type only (default: all)" - echo " -n pname # this process name only (default: all)" - echo " -p pid # this process ID only (default: all)" - echo " -u username # this user only (default: all)" - echo " -h # print this help text" - echo "" - echo "Protocol Families:" - echo " LOCAL, INET, INET6, IPX, NETLINK, X25, AX25, ATMPVC, APPLETALK, PACKET" - echo "" - echo "Protocols:" - echo " TCP, UDP, SCTP, IP, FC, ... (see /etc/protocols for complete list)" - echo "" - echo "Socket Types:" - echo " STREAM, DGRAM, RAW, RDM, SEQPACKET, DCCP, PACKET" -} - -# Process options -while getopts df:i:n:N:P:p:t:u:h option; do - case $option in - d) P_DEVICES=1 ;; - i) P_INTERVAL=$OPTARG ;; - N) P_NUMTOP=$OPTARG ;; - f) let "F_FAM++" - F_FAMSTR=$OPTARG$DELIM$F_FAMSTR ;; - n) let "F_NAME++" - F_NAMESTR=$OPTARG$DELIM$F_NAMESTR ;; - p) let "F_PID++" - F_PIDSTR=$OPTARG$DELIM$F_PIDSTR ;; - P) let "F_PROT++" - F_PROTSTR=$OPTARG$DELIM$F_PROTSTR ;; - t) let "F_TYPE++" - F_TYPESTR=$OPTARG$DELIM$F_TYPESTR ;; - 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 ;; - h|?|*) usage - exit 1 ;; - esac -done - -if [[ $ERROR > 0 ]]; then - exit 1 -fi - -if [[ $F_FAM > 0 || $F_NAME > 0 || $F_PID > 0 || - $F_PROT > 0 || $F_TYPE > 0 || $F_UID > 0 ]]; then - FILTER=1 -fi - -# -# Pass a timezone adjustment value to the stap script -# -TZ=`date "+%z"` -TZ_SIGN=`echo $TZ | cut -c1` -TZ_HOURS=`echo $TZ | cut -c2-3` -TZ_MINS=`echo $TZ | cut -c4-5` -TZ_ADJUST=$TZ_SIGN$((10#$TZ_HOURS*60*60+10#$TZ_MINS*60)) - -# -# Start the systemtap script -# -stap -e ' -global execname, user, if_tx, if_rx, if_dev -global sk_tx, sk_rx, sk_pid -global f_name_str, f_pid_str, f_prot_str, f_fam_str, f_type_str, f_uid_str -global f_name, f_pid, f_prot, f_fam, f_type, f_uid - -probe begin -{ - # If no filters specified, skip filter processing - if ('$FILTER' == 0) next - - f_name_str = "'$F_NAMESTR'" - f_pid_str = "'$F_PIDSTR'" - f_prot_str = "'$F_PROTSTR'" - f_fam_str = "'$F_FAMSTR'" - f_type_str = "'$F_TYPESTR'" - f_uid_str = "'$F_UIDSTR'" - - delim = "'$DELIM'" - error = 0 - - # Protocols - if ('$F_PROT') { - prot = tokenize(f_prot_str, delim) - while (prot != "") { - p = sock_prot_str2num(prot) - if (p < 0) { - printf("ERROR: Unknown protocol: %s\n", prot) - error++ - } else - f_prot[p] = 1 - prot = tokenize("", delim) - } - } - - # Protocol families - if ('$F_FAM') { - fam = tokenize(f_fam_str, delim) - while (fam != "") { - f = sock_fam_str2num(fam) - if (f < 0) { - printf("ERROR: Unknown protocol family: %s\n", fam) - error++ - } else - f_fam[f] = 1 - fam = tokenize("", delim) - } - } - - # Process names - if ('$F_NAME') { - pname = tokenize(f_name_str, delim) - while (pname != "") { - f_name[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) - } - } - - # Socket types - if ('$F_TYPE') { - stype = tokenize(f_type_str, delim) - while (stype != "") { - t = sock_type_str2num(stype) - if (t < 0) { - printf("ERROR: Unknown socket type: %s\n", stype) - error++ - } else - f_type[t] = 1 - stype = tokenize("", delim) - } - } - - # User IDs - if ('$F_UID') { - uid = tokenize(f_uid_str, delim) - while (uid != "") { - f_uid[strtol(uid, 10)] = 1 - uid = tokenize("", delim) - } - } - - if (error) exit() -} - -probe netdev.transmit -{ - if ('$P_DEVICES') { - if_tx[dev_name] <<< length - if_dev[dev_name] ++ - } -} - -probe netdev.receive -{ - if ('$P_DEVICES') { - if_rx[dev_name] <<< length - if_dev[dev_name] ++ - } -} - -probe socket.send -{ - if (!success) next - - pid = pid() - uid = uid() - ename = execname() - - # Check filters - if ('$FILTER') { - if ('$F_PROT' && !(protocol in f_prot)) next - if ('$F_FAM' && !(family in f_fam)) next - if ('$F_PID' && !(pid in f_pid)) next - if ('$F_NAME' && !(ename in f_name)) next - if ('$F_UID' && !(uid in f_uid)) next - if ('$F_TYPE' && !(type in f_type)) next - } - - execname[pid] = ename - user[pid] = uid - sk_tx[pid, protocol, family] <<< size - sk_pid[pid, protocol, family] += size -} - -probe socket.receive -{ - if (!success) next - - pid = pid() - uid = uid() - ename = execname() - - # Check filters - if ('$FILTER') { - if ('$F_PROT' && !(protocol in f_prot)) next - if ('$F_FAM' && !(family in f_fam)) next - if ('$F_PID' && !(pid in f_pid)) next - if ('$F_NAME' && !(ename in f_name)) next - if ('$F_UID' && !(uid in f_uid)) next - if ('$F_TYPE' && !(type in f_type)) next - } - - execname[pid] = ename - user[pid] = uid - sk_rx[pid, protocol, family] <<< size - sk_pid[pid, protocol, family] += size -} - -function print_activity() -{ - # Print top processes - max = '$P_NUMTOP' - time = gettimeofday_s() + '$TZ_ADJUST' - - printf("======================= %s ========================\n", ctime(time)) - printf("------------------------------- PROCESSES -------------------------------\n") - printf("%-5s %-5s %7s %7s %7s %7s %-4s %-8s %-15s\n", - "PID", "UID", "#SEND", "#RECV", "SEND_KB", - "RECV_KB", "PROT", "FAMILY", "COMMAND") - foreach ([pid, prot, fam] in sk_pid- limit max) { - n_sk_tx = @count(sk_tx[pid, prot, fam]) - n_sk_rx = @count(sk_rx[pid, prot, fam]) - printf("%-5d %-5d %7d %7d %7d %7d %-4s %-8s %-15s\n", - pid, user[pid], n_sk_tx, n_sk_rx, - n_sk_tx ? @sum(sk_tx[pid, prot, fam])/1024 : 0, - n_sk_rx ? @sum(sk_rx[pid, prot, fam])/1024 : 0, - sock_prot_num2str(prot), sock_fam_num2str(fam), - execname[pid]) - } - - # Print top network devices - if ('$P_DEVICES') { - max = '$P_NUMTOP' - printf("-------------------------------- DEVICES --------------------------------\n") - printf("%-7s %13s %13s %15s %15s\n", - "DEV", "#XMIT", "#RECV", "XMIT_KB", "RECV_KB") - foreach ([dev] in if_dev- limit max) { - n_if_tx = @count(if_tx[dev]) - n_if_rx = @count(if_rx[dev]) - printf("%-7s %13d %13d %15d %15d\n", dev, n_if_tx, n_if_rx, - n_if_tx ? @sum(if_tx[dev])/1024 : 0, - n_if_rx ? @sum(if_rx[dev])/1024 : 0) - } - } - - printf("=========================================================================\n\n") - - delete execname - delete user - delete sk_tx - delete sk_rx - delete sk_pid - delete if_tx - delete if_rx - delete if_dev -} - - -probe timer.s('$P_INTERVAL') -{ - print_activity() -} -' diff --git a/stap_tutorial-1.0/examples/tapset/fs.stp b/stap_tutorial-1.0/examples/tapset/fs.stp deleted file mode 100644 index 1ed9afa..0000000 --- a/stap_tutorial-1.0/examples/tapset/fs.stp +++ /dev/null @@ -1,27 +0,0 @@ - -probe fs.read.return = kernel.function("vfs_read").return { - bytes = ($return > 0 ? $return : 0) -} - -probe fs.write.return = kernel.function("vfs_write").return { - bytes = ($return > 0 ? $return : 0) -} - -function file2name:string(filep:long) -%{ - char *start = NULL, buf[MAXSTRINGLEN]; - struct dentry *dentry = NULL; - struct vfsmount *mnt = NULL; - struct file *file = (struct file *)(long) kread(&(THIS->filep)); - - if (file) { - mnt = (struct vfsmount *) kread(&(file->f_path.mnt)); - dentry = (struct dentry *) kread(&(file->f_path.dentry)); - } - if (mnt && dentry) - start = d_path(dentry, mnt, buf, MAXSTRINGLEN); - if (start > 0) - strlcpy(THIS->__retvalue, start, MAXSTRINGLEN); - - CATCH_DEREF_FAULT(); -%} diff --git a/stap_tutorial-1.0/examples/top-cs.stp b/stap_tutorial-1.0/examples/top-cs.stp deleted file mode 100755 index efe5769..0000000 --- a/stap_tutorial-1.0/examples/top-cs.stp +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env stap -# -# Continuously list the top context switchers -# - -global processes - -probe begin { - printf("Collecting data...\n") -} - -function print_top () { - printf("Process\t\t\t\tCount\n") - printf("--------------------------------------\n") - foreach (name in processes- limit 20) - printf("%-20s\t\t%5d\n",name, processes[name]) - printf("--------------------------------------\n\n") - delete processes -} - -probe scheduler.cpu_on { - processes[execname()]++ -} - -# print top context switchers every 10 seconds -probe timer.s(10) { - print_top () -} - diff --git a/stap_tutorial-1.0/examples/top-ext3calls.stp b/stap_tutorial-1.0/examples/top-ext3calls.stp deleted file mode 100755 index 039e6a1..0000000 --- a/stap_tutorial-1.0/examples/top-ext3calls.stp +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env stap - -global ext3calls - -probe begin { - printf("Collecting data...\n") -} - -probe kernel.function("*@fs/ext3") ?, - module("ext3").function("*@fs/ext3/*") ? -{ - ext3calls[probefunc()]++ -} - -probe end { - foreach (name in ext3calls- limit 20) - printf("%10d %s\n", ext3calls[name], name) -} - diff --git a/stap_tutorial-1.0/examples/top-syscalls.stp b/stap_tutorial-1.0/examples/top-syscalls.stp deleted file mode 100755 index a5288c6..0000000 --- a/stap_tutorial-1.0/examples/top-syscalls.stp +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env stap - -global syscalls - -probe begin { - printf("Collecting data...\n") -} - -probe syscall.* { - syscalls[name]++ -} - -probe end { - foreach (name in syscalls- limit 10) - printf("%10d %s\n", syscalls[name], name) -} |
