Greetings, is there a way to specify probes and other dtrace operations via command line parameters, like " BEGIN { usr_exec=$$1; usr_syscall=$$2; } syscall::usr_syscall:entry /execname == usr_exec && guard++ == 0/ { ... " [this does not work] This would make it possible to create "generic" dtrace scripts. Otherwise, some shellscript with sed-magic would need to be used. thanks Joachim -- Joachim Worringen, Software Architect, Dolphin Interconnect Solutions phone ++49/(0)228/324 08 17 - http://www.dolphinics.com
On Tue, Aug 19, 2008 at 04:59:31PM +0200, Joachim Worringen wrote:> Greetings, > > is there a way to specify probes and other dtrace operations via command > line parameters, like > " > > BEGIN > { > usr_exec=$$1; > usr_syscall=$$2; > } > > syscall::usr_syscall:entry > /execname == usr_exec && guard++ == 0/ > { > ... > " > [this does not work] > > This would make it possible to create "generic" dtrace scripts. > > Otherwise, some shellscript with sed-magic would need to be used. > > thanks JoachimYou have both asked and answered your own question :) See http://wikis.sun.com/display/DTrace/Scripting -Mike -- Mike Shapiro, Sun Microsystems Fishworks. blogs.sun.com/mws/
Hi Joachim, You can''t use variables, but you can use parameters from the command-line: ---8<--- arg.d ---8<--- #!/usr/sbin/dtrace -s pid$target::$1:entry { @[$$1] = count(); } ---8<--- arg.d ---8<--- # ./arg.d -p `pgrep -n firefox` malloc dtrace: script ''./arg.d'' matched 4 probes ^C malloc 50262 Adam On Tue, Aug 19, 2008 at 04:59:31PM +0200, Joachim Worringen wrote:> Greetings, > > is there a way to specify probes and other dtrace operations via command > line parameters, like > " > > BEGIN > { > usr_exec=$$1; > usr_syscall=$$2; > } > > syscall::usr_syscall:entry > /execname == usr_exec && guard++ == 0/ > { > ... > " > [this does not work] > > This would make it possible to create "generic" dtrace scripts. > > Otherwise, some shellscript with sed-magic would need to be used. > > thanks Joachim > > -- > Joachim Worringen, Software Architect, Dolphin Interconnect Solutions > phone ++49/(0)228/324 08 17 - http://www.dolphinics.com > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Fishworks http://blogs.sun.com/ahl
Adam Leventhal wrote:> Hi Joachim, > > You can''t use variables, but you can use parameters from the command-line: > > ---8<--- arg.d ---8<--- > > #!/usr/sbin/dtrace -s > > pid$target::$1:entry > { > @[$$1] = count(); > } > > ---8<--- arg.d ---8<--- > > # ./arg.d -p `pgrep -n firefox` malloc > dtrace: script ''./arg.d'' matched 4 probes > ^C > malloc 50262Thanks, this will be fine as well. Don''t need variables, although they might make things clearer in longer scripts. Still, it would be nice to have some sort of builtin getopt() to build more robust native dtrace scripts - with more than one macro argument, confusion is guaranteed now. And sed-preprocssing is addional overhead when writing and maintaining a script. Before asking this question, I checked the dtrace user guide and failed to find this information - now it''s obvious... sorry. Joachim -- Joachim Worringen, Software Architect, Dolphin Interconnect Solutions phone ++49/(0)228/324 08 17 - http://www.dolphinics.com