This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to filter unnecessary info from stap output?


On Thu, 2012-03-15 at 10:51 +0800, ch huang wrote:
> i want observer ext module action, i write the following script
> 
> 
> # cat exec.stp -o file
> probe module("ext3").function("*").call {
> printf("%s -> %s\n", thread_indent(1), probefunc())
> }
> probe module("ext3").function("*").return {
> printf("%s <- %s\n", thread_indent(-1), probefunc())
> }
> 
> but i want stap output in file,when i run like 'echo "aaa" > ufile '
> command ,not always flood the output file with like
> '   10 pdflush(32612): <- ext3_write_super
>      0 pdflush(32612): -> ext3_write_inode
>      4 pdflush(32612): <- ext3_write_inode
>      0 pdflush(32612): -> ext3_write_inode
>      3 pdflush(32612): <- ext3_write_inode
>      0 pdflush(32612): -> ext3_write_inode
>      3 pdflush(32612): <- ext3_write_inode
>      0 pdflush(32612): -> ext3_write_inode
>      3 pdflush(32612): <- ext3_write_inode ' such unnecessary info ,any help?

Do you want to filter out kernel probes triggered from stap itself or
just pdflush? The program stapio is responsible for writing out the
file. If so then you can filter those two out using something like:

probe module("ext3").function("*").call {
  if (execname() == "stapio" || execname() == "pdflush")
    next;

  printf("%s -> %s\n", thread_indent(1), probefunc());
}

You can also use a similar mechanism for selecting only a specific
target process that you are interested in. For example to see the probes
just for the execution of 'echo "aaa" > ufile' of the above you could
do:

probe module("ext3").function("*").call {
  if (target() == pid())
    printf("%s -> %s\n", thread_indent(1), probefunc())
}
probe module("ext3").function("*").return {
  if (target() == pid())
    printf("%s <- %s\n", thread_indent(-1), probefunc())
}

$ stap script.stp -c 'echo "aaa" > ufile'

Where target() is the process id target process (given with -c above).

Cheers,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]