Zone-specific DTrace Commands in Solaris 10

by Brian K. Jones

I wanted to put a note here for myself, and for others who are looking for a way to get information about a particular executable running in a zone on their machine. While it is (to the best of my knowledge) not possible to do this from within the local zone itself, you can run dtrace from the global zone and specify the zone name and executable by using a logical AND in the predicate, like this:

dtrace -n 'syscall:::entry /zonename == "webserver" && execname == "httpd"/{ printf("%S", curpsinfo->pr_psargs); trace(pid) }'

This is a command I used to get some quick information about all of the httpd processes running on a web server that exists as a zone on a solaris 10 machine. Here's some output:

0 6485 write:entry /var/local/httpd/bin/httpd -DSSL\0 12248
0 6779 llseek:entry /var/local/httpd/bin/httpd -DSSL\0 12248
0 6489 close:entry /var/local/httpd/bin/httpd -DSSL\0 12248
0 6789 pollsys:entry /var/local/httpd/bin/httpd -DSSL\0 12248

The command is run from the global zone. This isn't exactly what I wanted -- I wanted all of the arguments passed to all of the system calls, but I got the arguments passed to the httpd process itself at start time instead. I'm still chugging through the documentation, so if I find more cool stuff, I'll put it here. Meanwhile, if you know how to do what I'm trying to do, or how to do some other cool stuff with DTrace, please share!!

Here are a few links about DTrace that I'm using to get more information. It's plenty to get you started, but not a lot of info on how to do anything remotely advanced. Even coverage of 'advanced' features is pretty dumbed down compared to the crazy stuff I'm seeing in some of the example scripts. Nonetheless, this stuff *is* useful:

http://www.snpnet.com/sun_DTrace/dtrace.html
http://users.tpg.com.au/adsln4yb/dtrace.html
http://www.sun.com/bigadmin/content/dtrace/
http://blogs.sun.com/bmc

3 Comments

David Comay
2006-08-02 23:59:37
Actually, DTrace is available from within non-global
zones in recent Solaris Express builds. You can do
this by assigning one or both of the following two
privileges - dtrace_proc and dtrace_user - to the
zone using the new limitpriv property and
then rebooting the zone.


dtrace_proc gives you access to the fasttrap
and pid providers while dtrace_user gives you
access to the "profile" and "syscall" providers.
This means that tools like plockstat(1M) are now
available inside the zone as well.


For an example, check out Dan Price's blog entry


http://blogs.sun.com/roller/page/dp?entry=dtrace_zones_crazy_delicious


2006-08-03 04:49:39
Thanks for this information! I finally went ahead and read parts of the Sun DTrace Guide, which has also been helpful, and I also discovered that Redhat and IBM (others?) have also teamed up on SystemTap, which aims at DTrace-like functionality for Linux. Nice!
pilau Rome
2007-03-16 02:07:41
I wanted to put a note here for myself, and for others who are looking for a way to get information about a particular executable running in a zone on their machine. While it is (to the best of my knowledge) not possible to do this from within the local zone itself, you can run dtrace from the global zone and specify the zone name and executable by using a logical AND in the predicate, like this:
I do not agree. Go to http://www.jobzbank.info/mac_Italy/aviculture_Lazio/pilau_Rome_1.html