diff options
Diffstat (limited to 'testsuite/systemtap.examples')
-rw-r--r-- | testsuite/systemtap.examples/index.html | 3 | ||||
-rw-r--r-- | testsuite/systemtap.examples/index.txt | 7 | ||||
-rwxr-xr-x | testsuite/systemtap.examples/io/traceio2.stp | 2 | ||||
-rw-r--r-- | testsuite/systemtap.examples/keyword-index.html | 3 | ||||
-rw-r--r-- | testsuite/systemtap.examples/keyword-index.txt | 7 | ||||
-rw-r--r-- | testsuite/systemtap.examples/process/plimit.meta | 7 | ||||
-rwxr-xr-x | testsuite/systemtap.examples/process/plimit.stp | 78 |
7 files changed, 106 insertions, 1 deletions
diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index f2b7066f..55fea0fb 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -169,6 +169,9 @@ keywords: <a href="keyword-index.html#SCHEDULER">SCHEDULER</a> <br> <li><a href="process/pf2.stp">process/pf2.stp</a> - Profile kernel functions<br> keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <br> <p>The pf2.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top ten kernel functions with samples.</p></li> +<li><a href="process/plimit.stp">process/plimit.stp</a> - print resource limits<br> +keywords: <a href="keyword-index.html#PROCESS">PROCESS</a> <br> +<p>The script prints a variety of resource limits for a given pid, like /proc/$$/limits on recent kernels.</p></li> <li><a href="process/schedtimes.stp">process/schedtimes.stp</a> - Track Time Processes Spend in Various States using Tracepoints<br> keywords: <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#SCHEDULER">SCHEDULER</a> <a href="keyword-index.html#TIME">TIME</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <br> <p>The schedtimes.stp script instruments the scheduler to track the amount of time that each process spends running, sleeping, queued, and waiting for io. On exit the script prints out the accumulated time for each state of processes observed. Optionally, this script can be used with the '-c' or '-x' options to focus on a specific PID.</p></li> diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index e880c746..16b45aac 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -407,6 +407,13 @@ keywords: profiling samples. +process/plimit.stp - print resource limits +keywords: process + + The script prints a variety of resource limits for a given pid, like + /proc/$$/limits on recent kernels. + + process/schedtimes.stp - Track Time Processes Spend in Various States using Tracepoints keywords: process scheduler time tracepoint diff --git a/testsuite/systemtap.examples/io/traceio2.stp b/testsuite/systemtap.examples/io/traceio2.stp index 1abea45d..797f3062 100755 --- a/testsuite/systemtap.examples/io/traceio2.stp +++ b/testsuite/systemtap.examples/io/traceio2.stp @@ -1,6 +1,6 @@ #! /usr/bin/env stap -global device_of_interest, dev +global device_of_interest probe begin { /* The following is not the most efficient way to do this. diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index f09a20b3..1a2855e1 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -297,6 +297,9 @@ keywords: <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-inde <li><a href="process/forktracker.stp">process/forktracker.stp</a> - Trace Creation of Processes<br> keywords: <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#SCHEDULER">SCHEDULER</a> <br> <p>The forktracker.stp script prints out a time-stamped entry showing each fork and exec operation on the machine. This can be useful for determine what process is creating a flurry of short-lived processes.</p></li> +<li><a href="process/plimit.stp">process/plimit.stp</a> - print resource limits<br> +keywords: <a href="keyword-index.html#PROCESS">PROCESS</a> <br> +<p>The script prints a variety of resource limits for a given pid, like /proc/$$/limits on recent kernels.</p></li> <li><a href="process/schedtimes.stp">process/schedtimes.stp</a> - Track Time Processes Spend in Various States using Tracepoints<br> keywords: <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#SCHEDULER">SCHEDULER</a> <a href="keyword-index.html#TIME">TIME</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <br> <p>The schedtimes.stp script instruments the scheduler to track the amount of time that each process spends running, sleeping, queued, and waiting for io. On exit the script prints out the accumulated time for each state of processes observed. Optionally, this script can be used with the '-c' or '-x' options to focus on a specific PID.</p></li> diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 853198d3..6de9c330 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -605,6 +605,13 @@ keywords: process scheduler determine what process is creating a flurry of short-lived processes. +process/plimit.stp - print resource limits +keywords: process + + The script prints a variety of resource limits for a given pid, like + /proc/$$/limits on recent kernels. + + process/schedtimes.stp - Track Time Processes Spend in Various States using Tracepoints keywords: process scheduler time tracepoint diff --git a/testsuite/systemtap.examples/process/plimit.meta b/testsuite/systemtap.examples/process/plimit.meta new file mode 100644 index 00000000..d5cd4e8b --- /dev/null +++ b/testsuite/systemtap.examples/process/plimit.meta @@ -0,0 +1,7 @@ +title: print resource limits +name: plimit.stp +keywords: process +subsystem: general +description: The script prints a variety of resource limits for a given pid, like /proc/$$/limits on recent kernels. +test_check: stap -gp4 plimit.stp $$ +test_installcheck: stap -g plimit.stp $$ diff --git a/testsuite/systemtap.examples/process/plimit.stp b/testsuite/systemtap.examples/process/plimit.stp new file mode 100755 index 00000000..1a389468 --- /dev/null +++ b/testsuite/systemtap.examples/process/plimit.stp @@ -0,0 +1,78 @@ +#!/usr/bin/env stap +# plimit.stp +# Copyright (C) 2006 Red Hat, Inc., Eugene Teo <eteo@redhat.com> +# +# 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 +# published by the Free Software Foundation. +# + +%{ + #include <linux/sched.h> + #include <linux/list.h> +%} + +function getrlimit:string (rlim:long, pid:long) %{ /* pure */ + struct task_struct *p; + struct list_head *_p, *_n; + static char cur_buf[24], max_buf[24]; + long int cur, max; + + list_for_each_safe(_p, _n, ¤t->tasks) { + p = list_entry(_p, struct task_struct, tasks); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12) + cur = p->signal->rlim[THIS->rlim].rlim_cur; + max = p->signal->rlim[THIS->rlim].rlim_max; +#else + cur = p->rlim[THIS->rlim].rlim_cur; + max = p->rlim[THIS->rlim].rlim_max; +#endif + if (p->pid == (int)THIS->pid) { + if (cur == -1 && max == -1) + strcat(THIS->__retvalue, "unlimited unlimited"); + else if (cur == -1) + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%-9s %-9ld", + "unlimited", max); + else if (max == -1) + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%-9ld %-9s", + cur, "unlimited"); + else + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%-9ld %-9ld", + cur, max); + } + } +%} + +function task_execname_by_pid:string (pid:long) %{ /* pure */ + struct task_struct *p; + struct list_head *_p, *_n; + list_for_each_safe(_p, _n, ¤t->tasks) { + p = list_entry(_p, struct task_struct, tasks); + if (p->pid == (int)THIS->pid) + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", p->comm); + } +%} + +probe begin +{ + printf("%d: -%s\n", $1, task_execname_by_pid($1)) + /* include/asm-generic/resource.h */ + printf(" resource current maximum\n") + printf("coredump(blocks) %s\n", getrlimit(4, $1)) + printf("data(bytes) %s\n", getrlimit(2, $1)) + printf("max nice %s\n", getrlimit(13, $1)) + printf("file size(blocks) %s\n", getrlimit(1, $1)) + printf("pending signals %s\n", getrlimit(11, $1)) + printf("max locked memory(bytes) %s\n", getrlimit(8, $1)) + printf("max memory size(bytes) %s\n", getrlimit(5, $1)) + printf("open files %s\n", getrlimit(7, $1)) + printf("POSIX message queues(bytes) %s\n", getrlimit(12, $1)) + printf("max rt priority %s\n", getrlimit(14, $1)) + printf("stack size(bytes) %s\n", getrlimit(3, $1)) + printf("cpu time(seconds) %s\n", getrlimit(0, $1)) + printf("max user processes %s\n", getrlimit(6, $1)) + printf("virtual memory(bytes) %s\n", getrlimit(9, $1)) + printf("file locks %s\n", getrlimit(10, $1)) + + exit() +} |