Passing command line parameters to DTrace scripts

May 2, 2009 · Filed Under General Solaris topics · Comment 

When you’re writing a DTrace script, often you’d like to pass some parameter in command line. Such an easy task might be really hard unless you read a docs.sun.com section about DTrace scripting, particularly a section about command line parameters macros.

As with sh or bash, you can access command line parameters via $0..$9 macroses. But there’s a catch. Values of these macroses should match a certain definition – a number, an identifier or a string. If there isn’t a match here, you’ll get an error.

Let’s start with a simple script. Read more

Solaris 10 zones: part one – a working example

May 2, 2009 · Filed Under General Solaris topics · 10 Comments 

Many of you have already heard about Solaris 10 zones – it’s a virtualization technology which allows you to create isolated and secure environments for running applications. For end-users these environments look just like separate abstract machines with Solaris 10 installed on them. Inside each zone, all the processes don’t see anything happening in all the other zones on a system. Isolation is done on such a level that processes of one zone can’t see or affect processes of any other zone.

All of this is done on a software level, and by default every Solaris 10 machine has a global zone – only from this zone you can view processes of all the rest zones on your system. You probably didn’t even notice, but upon the completion of your Solaris 10 install, you’re immediately put into the global zone. It’s very easy to see this zone:

solaris# zoneadm list -vc
ID NAME             STATUS         PATH
0 global           running        /

Read more

DTrace: Aggregations

May 2, 2009 · Filed Under General Solaris topics · 1 Comment 

Quite often it is more important for you to see the whole picture, rather than to know each case when a particular probe fires. For instance, observing a process which consumes a lot of CPU time according to prstat, we ask ourselves: what is this process doing? And often we think about the overall number of system calls executed by this process, and not every particular one of these system calls.

DTrace aggregations are created specifically for answering such questions. Working with sets of numerical data, aggregation functions help us to easily determing average, min and max values of data sets, count numbers and sums of elements in these data sets, and even build frequency distributions.

Read more

DTrace: $target macro variable

May 2, 2009 · Filed Under General Solaris topics · 1 Comment 

Macro variables are meant to make your life MUCH easier when scripting with DTrace. Names of such variables must begin with a $ sign, and DTrace will automatically replace all the macro variables with the appropriate values when parsing your script.

Full list of macro variables can be found here, I will only talk about $target variable this time.

$target specifies the PID of the process you associate with your DTrace script.

Read more

DTrace options: flowindent

May 2, 2009 · Filed Under General Solaris topics · Comment 

One of the most useful (for me) options in DTrace is flowindent. All it does is indent the entry to each function with “->”, and mark the return from this function with “<-”. Doesn’t seem like much, does it? But just look at the results!

The following example catches all the probes of the fbt provided. By default (that’s our case since we’re not changing any other options but flowindent), DTrace registers and prints to the standard output all the probes matched in the tracing process.

Read more

DTrace: count system calls for any process

May 2, 2009 · Filed Under General Solaris topics · Comment 

One more variation of using DTrace allows to track which system calls are made from a certain process. Or do the same for lots of processes, if you use execname and not PIDs…

Such a command line will show you all system calls made by Xorg in the last 5 seconds:

solaris# dtrace -n 'syscall:::entry /execname == "Xorg"/ {@[probefunc] = count(); } tick-5sec {printa(@); clear(@);}'
dtrace: description 'syscall:::entry ' matched 227 probes
CPU     ID                    FUNCTION:NAME
0  36588                       :tick-5sec
writev                                                           20
lwp_sigmask                                                      38
setcontext                                                       38
setitimer                                                        75
read                                                            422
pollsys                                                         426

pS: some time later I’ll hopefully write more about what DTrace and D language are

Basic usage of DTrace

May 2, 2009 · Filed Under General Solaris topics · 2 Comments 

I’m slowly getting used to seeing and using DTrace in my everyday work…

For example, here’s a start of the most basic analysis.

My setup: The system is constantly busy with something, and our task is to find what’s responsible for this. How? One of the possible solutions is to simply watch the system for a certain period of time (5 seconds in our case) to see what process makes most system calles… And it’s clearly seen now that the most active consumer of system calls is Java VM which happens to run a very complex graphics applet at this very moment.

Read more

What’s new in Solaris 10?

May 2, 2009 · Filed Under General Solaris topics, News · 2 Comments 

Here are just some of the revolutionary changes introduced in Solaris 10:

DTrace – dynamic tracing

DTrace allows you to dynamically trace anything and everything in real time. You can observe processes both in userland and kernel space, watch them as closely as you want and this all with virtually no performance impact. This allows DTrace to be used on a production system being absolutely sure it’s not going to considerably slow the system down or crash it.
I think it’s one of the best Solaris 10 innovations – all the administrators and developers will like it.

ZFS file system (zettabyte file system)

Read more

DTrace: observing PHP

May 1, 2009 · Filed Under General Solaris topics · 1 Comment 

I’ve finally got some spare time to download a PEAR module for DTrace. What a great module! I’ve found a little problem with it, wrote a letter to Wez Furlong, and he immediately changed the source code to make it work even better. Thanks a lot, Wez! :)

So, here it is – my first PHP Dtrace script: php-scripts-snoop.d

Read more

Zones in Solaris 10: part two – types of resources

May 1, 2009 · Filed Under General Solaris topics · 1 Comment 

Now that we know how to create non-global zones in Solaris, it’s probably time to learn some basics of zones configuration. Most work is done with zonecfg which has been mentioned in my Solaris zones: a working example post.

Example of fully configuring a Solaris 10 zone

For starters, let’s have a look at the full configuration of our zone. You’ve probably guessed by now, that we only specified the minimal number of parameters when creating our zone. Now I’ll show you how to get a full view of our zone’s configuration, and I’ll also talk a bit about types of resources you can allocate to a non-global zone.

Read more

« Previous PageNext Page »