diff options
author | William Cohen <wcohen@localhost.localdomain> | 2008-04-24 12:20:13 -0400 |
---|---|---|
committer | William Cohen <wcohen@localhost.localdomain> | 2008-04-24 12:20:13 -0400 |
commit | 7f79ea13a0f64573ce13353257d322ae49ef0c27 (patch) | |
tree | 60de8da5af4c2bcc26abfb9430fdca66bdc20b98 /testsuite/systemtap.examples/nettop.stp | |
parent | f90f92615df6ff2a62282359281889597e5dbf17 (diff) | |
download | systemtap-steved-7f79ea13a0f64573ce13353257d322ae49ef0c27.tar.gz systemtap-steved-7f79ea13a0f64573ce13353257d322ae49ef0c27.tar.xz systemtap-steved-7f79ea13a0f64573ce13353257d322ae49ef0c27.zip |
Move examples to testsuite/systemtap.examples
Diffstat (limited to 'testsuite/systemtap.examples/nettop.stp')
-rwxr-xr-x | testsuite/systemtap.examples/nettop.stp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/nettop.stp b/testsuite/systemtap.examples/nettop.stp new file mode 100755 index 00000000..96db413a --- /dev/null +++ b/testsuite/systemtap.examples/nettop.stp @@ -0,0 +1,42 @@ +#! /usr/bin/env stap + +global ifxmit, ifrecv + +probe netdev.transmit +{ + ifxmit[pid(), dev_name, execname(), uid()] <<< length +} + +probe netdev.receive +{ + ifrecv[pid(), dev_name, execname(), uid()] <<< length +} + + +function print_activity() +{ + printf("%5s %5s %-7s %7s %7s %7s %7s %-15s\n", + "PID", "UID", "DEV", "XMIT_PK", "RECV_PK", + "XMIT_KB", "RECV_KB", "COMMAND") + + foreach ([pid, dev, exec, uid] in ifrecv-) { + n_xmit = @count(ifxmit[pid, dev, exec, uid]) + n_recv = @count(ifrecv[pid, dev, exec, uid]) + printf("%5d %5d %-7s %7d %7d %7d %7d %-15s\n", + pid, uid, dev, n_xmit, n_recv, + n_xmit ? @sum(ifxmit[pid, dev, exec, uid])/1024 : 0, + n_recv ? @sum(ifrecv[pid, dev, exec, uid])/1024 : 0, + exec) + } + + print("\n") + + delete ifxmit + delete ifrecv +} + +probe timer.ms(5000), end, error +{ + print_activity() +} + |