From: "Daniel P. Berrange" <berrange@redhat.com>
To: "Frank Ch. Eigler" <fche@redhat.com>
Cc: systemtap@sources.redhat.com
Subject: Re: command line arguments
Date: Fri, 24 Feb 2006 13:42:00 -0000 [thread overview]
Message-ID: <20060224134222.GA21829@redhat.com> (raw)
In-Reply-To: <20060223224218.GE20902@redhat.com>
On Thu, Feb 23, 2006 at 05:42:18PM -0500, Frank Ch. Eigler wrote:
> Hi -
>
> I committed a draft of command line argument support as per bug #1304.
> One part (plain substitution into scripts) is usable now. Another
> part (initializing globals at module init time) is sort of dormant.
>
> The way the first part works is by making any additional arguments
> passed to "stap" available to the script for substitution as string
> or number literals:
>
> # stap -e 'probe kernel.function(@1) { print($2) }' sys_open 4
>
> The @ vs $ distinction encodes whether the numbered argument should be
> pasted as a string or number literal. I considered guessing but
> heuristics don't seem to belong somewhere so critical.
>
> I'm open to suggestions about better notation than $n and @n. (#n is
> out because of comments; % and others because of arithmetic operators.)
The scenarios I'd like to use command line args in, are for tweaking
aspects of the data capture, say, sampling rate of a timer, or if I
was probing 'sys_read', some variable to control how often to log.
So I'd think named arguments would be clearer to use, possibly to set
global variables. So for example
global samplerate = 1000
probe timer.jiffies(samplerate) {
...
}
One could tweak the rate with
# stap --define samplerate=50 stuff.stp
Or another exaple, if one wanted to watch all file opens under a particular
directory
global prefix = "/"
probe kernel.function("sys_open") {
if ( isinstr(prefix, substr(user_string(filename),0,strlen(prefix)) ) {
print("Pid " . pid() . " opens " . user_strin(filename))
}
}
Then one could restrict it to just files under /etc with
# stap -D prefix=/etc watchopen.stp
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
next prev parent reply other threads:[~2006-02-24 13:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-23 22:42 Frank Ch. Eigler
2006-02-24 5:52 ` Martin Hunt
2006-02-24 12:24 ` Frank Ch. Eigler
2006-02-24 18:44 ` Martin Hunt
2006-02-25 21:38 ` Frank Ch. Eigler
2006-02-27 20:34 ` Martin Hunt
2006-02-24 13:42 ` Daniel P. Berrange [this message]
2006-02-24 15:51 ` Frank Ch. Eigler
2006-02-24 20:59 ` Roland McGrath
2006-02-24 21:22 ` Frank Ch. Eigler
2006-02-23 23:41 Stone, Joshua I
2006-02-24 1:00 ` Frank Ch. Eigler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060224134222.GA21829@redhat.com \
--to=berrange@redhat.com \
--cc=fche@redhat.com \
--cc=systemtap@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).