Hi dtrace-discuss, Having recently upgraded to OS X 10.5 I''m relatively new to DTrace, so apologies if this has been covered before; I did search the archives and didn''t find anything though. As a DTrace starter project I''d like to understand how to extract common performance metrics before diving too far in. One of these common metrics is load average, which I thought would be pretty easy. However, I''m confused by this code snippet (from http://www.brendangregg.com/DTrace/iotop): """ /* fetch 1 min load average */ this->load1a = `hp_avenrun[0] / 65536; this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536; """ I can''t figure out where hp_avenrun is defined. I searched http://wikis.sun.com/display/DTrace as well as looking at all the probes on my system ($ sudo dtrace -l | grep hp_avenrun) and came up empty. So my question is, when reading d scripts, how should I go about finding out what these mysterious variables are? Thanks, Travis
Travis Crawford wrote:> However, I''m confused by this code snippet (from > http://www.brendangregg.com/DTrace/iotop): > > """ > /* fetch 1 min load average */ > this->load1a = `hp_avenrun[0] / 65536; > this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536; > """ > > I can''t figure out where hp_avenrun is defined. I searched > http://wikis.sun.com/display/DTrace as well as looking at all the > probes on my system ($ sudo dtrace -l | grep hp_avenrun) and came up > empty. > > So my question is, when reading d scripts, how should I go about > finding out what these mysterious variables are?The ` (backtick) is used to access to access kernel variables in DTrace scripts. The best way to find what these do is to use the OpenGrok source browser at http://src.opensolaris.org. The hp_avenrun variable is defined here: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/clock.c#97 Menno -- Menno Lageman - Sun Microsystems - http://blogs.sun.com/menno
Hi Travis - Your first clue here is the backtick operator (`) used to extract hp_avenrun[0]. The backtick operator is used to read the value of kernel variables, which will be specific to the running kernel. That is, Solaris, Mac OS X (Darwin), FreeBSD and all other kernels with DTrace will not have portability when it comes to dtrace scripts that use the backtick variable, since by definition they will be kernel specific. hp_avenrun[] is a Solaris kernel variable: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/clock.c#97 For some kernel variables (like avenrun), you could look around for something similar in your target kernel: kilroy> nm -x /mach_kernel | grep avenrun 004d25ac 0f 08 0000 0002dbb9 _avenrun kilroy> Of course, without the source, it''s not clear what the variable type is.... So....your example below is specific to Solaris. If you see the backtick operator, think "kernel specific". HTH, /jim Travis Crawford wrote:> Hi dtrace-discuss, > > Having recently upgraded to OS X 10.5 I''m relatively new to DTrace, so > apologies if this has been covered before; I did search the archives > and didn''t find anything though. > > As a DTrace starter project I''d like to understand how to extract > common performance metrics before diving too far in. One of these > common metrics is load average, which I thought would be pretty easy. > However, I''m confused by this code snippet (from > http://www.brendangregg.com/DTrace/iotop): > > """ > /* fetch 1 min load average */ > this->load1a = `hp_avenrun[0] / 65536; > this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536; > """ > > I can''t figure out where hp_avenrun is defined. I searched > http://wikis.sun.com/display/DTrace as well as looking at all the > probes on my system ($ sudo dtrace -l | grep hp_avenrun) and came up > empty. > > So my question is, when reading d scripts, how should I go about > finding out what these mysterious variables are? > > Thanks, > Travis > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
Thanks Menno and Jim! I''m looking around the Apple documentation to hopefully find where they store the load average. Yes, it would be nice to have all the source available; I should take a better look at opensolaris. --travis On Mon, Mar 31, 2008 at 12:02 AM, Jim Mauro <James.Mauro at sun.com> wrote:> Hi Travis - Your first clue here is the backtick operator (`) used to > extract hp_avenrun[0]. The backtick operator is used to read the > value of kernel variables, which will be specific to the running kernel. > That is, Solaris, Mac OS X (Darwin), FreeBSD and all other kernels > with DTrace will not have portability when it comes to dtrace scripts > that use the backtick variable, since by definition they will be kernel > specific. > > hp_avenrun[] is a Solaris kernel variable: > > http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/clock.c#97 > > For some kernel variables (like avenrun), you could look around for > something > similar in your target kernel: > > kilroy> nm -x /mach_kernel | grep avenrun > 004d25ac 0f 08 0000 0002dbb9 _avenrun > kilroy> > > Of course, without the source, it''s not clear what the variable type is.... > > So....your example below is specific to Solaris. If you see the backtick > operator, think "kernel specific". > > HTH, > /jim > > > > Travis Crawford wrote: > > Hi dtrace-discuss, > > > > Having recently upgraded to OS X 10.5 I''m relatively new to DTrace, so > > apologies if this has been covered before; I did search the archives > > and didn''t find anything though. > > > > As a DTrace starter project I''d like to understand how to extract > > common performance metrics before diving too far in. One of these > > common metrics is load average, which I thought would be pretty easy. > > However, I''m confused by this code snippet (from > > http://www.brendangregg.com/DTrace/iotop): > > > > """ > > /* fetch 1 min load average */ > > this->load1a = `hp_avenrun[0] / 65536; > > this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536; > > """ > > > > I can''t figure out where hp_avenrun is defined. I searched > > http://wikis.sun.com/display/DTrace as well as looking at all the > > probes on my system ($ sudo dtrace -l | grep hp_avenrun) and came up > > empty. > > > > So my question is, when reading d scripts, how should I go about > > finding out what these mysterious variables are? > > > > Thanks, > > Travis > > _______________________________________________ > > dtrace-discuss mailing list > > dtrace-discuss at opensolaris.org > > >
Sean McGrath - Sun Microsystems Ireland
2008-Mar-30 22:17 UTC
[dtrace-discuss] howto measure CPU load
Travis Crawford stated: < Thanks Menno and Jim! I''m looking around the Apple documentation to < hopefully find where they store the load average. Yes, it would be < nice to have all the source available; I should take a better look at < opensolaris. Why not browse the Apple port of The DTraceToolkit itself ? It uses averunnable.ldavg instead of the Solaris specific hp_avenrun. Found from having a look at the OS-X port of DTrace at: http://www.opensource.apple.com/darwinsource Regards, Sean. . < < --travis < < < On Mon, Mar 31, 2008 at 12:02 AM, Jim Mauro <James.Mauro at sun.com> wrote: < > Hi Travis - Your first clue here is the backtick operator (`) used to < > extract hp_avenrun[0]. The backtick operator is used to read the < > value of kernel variables, which will be specific to the running kernel. < > That is, Solaris, Mac OS X (Darwin), FreeBSD and all other kernels < > with DTrace will not have portability when it comes to dtrace scripts < > that use the backtick variable, since by definition they will be kernel < > specific. < > < > hp_avenrun[] is a Solaris kernel variable: < > < > http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/clock.c#97 < > < > For some kernel variables (like avenrun), you could look around for < > something < > similar in your target kernel: < > < > kilroy> nm -x /mach_kernel | grep avenrun < > 004d25ac 0f 08 0000 0002dbb9 _avenrun < > kilroy> < > < > Of course, without the source, it''s not clear what the variable type is.... < > < > So....your example below is specific to Solaris. If you see the backtick < > operator, think "kernel specific". < > < > HTH, < > /jim < > < > < > < > Travis Crawford wrote: < > > Hi dtrace-discuss, < > > < > > Having recently upgraded to OS X 10.5 I''m relatively new to DTrace, so < > > apologies if this has been covered before; I did search the archives < > > and didn''t find anything though. < > > < > > As a DTrace starter project I''d like to understand how to extract < > > common performance metrics before diving too far in. One of these < > > common metrics is load average, which I thought would be pretty easy. < > > However, I''m confused by this code snippet (from < > > http://www.brendangregg.com/DTrace/iotop): < > > < > > """ < > > /* fetch 1 min load average */ < > > this->load1a = `hp_avenrun[0] / 65536; < > > this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536; < > > """ < > > < > > I can''t figure out where hp_avenrun is defined. I searched < > > http://wikis.sun.com/display/DTrace as well as looking at all the < > > probes on my system ($ sudo dtrace -l | grep hp_avenrun) and came up < > > empty. < > > < > > So my question is, when reading d scripts, how should I go about < > > finding out what these mysterious variables are? < > > < > > Thanks, < > > Travis < > > _______________________________________________ < > > dtrace-discuss mailing list < > > dtrace-discuss at opensolaris.org < > > < > < _______________________________________________ < dtrace-discuss mailing list < dtrace-discuss at opensolaris.org -- Sean. .
Sean, thanks for the pointer. This was actually super helpful because in the Apple dtrace tarball there''s a port of the dtrace toolkit; these examples are going to answer a lot of questions. On Mon, Mar 31, 2008 at 12:17 AM, Sean McGrath - Sun Microsystems Ireland <Sean.McGrath at sun.com> wrote:> Travis Crawford stated: > > < Thanks Menno and Jim! I''m looking around the Apple documentation to > < hopefully find where they store the load average. Yes, it would be > < nice to have all the source available; I should take a better look at > < opensolaris. > > Why not browse the Apple port of The DTraceToolkit itself ? > > It uses averunnable.ldavg instead of the Solaris specific hp_avenrun. > Found from having a look at the OS-X port of DTrace at: > http://www.opensource.apple.com/darwinsource > > Regards, > Sean. > > > . > < > < --travis > < > < > < On Mon, Mar 31, 2008 at 12:02 AM, Jim Mauro <James.Mauro at sun.com> wrote: > < > Hi Travis - Your first clue here is the backtick operator (`) used to > < > extract hp_avenrun[0]. The backtick operator is used to read the > < > value of kernel variables, which will be specific to the running kernel. > < > That is, Solaris, Mac OS X (Darwin), FreeBSD and all other kernels > < > with DTrace will not have portability when it comes to dtrace scripts > < > that use the backtick variable, since by definition they will be kernel > < > specific. > < > > < > hp_avenrun[] is a Solaris kernel variable: > < > > < > http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/clock.c#97 > < > > < > For some kernel variables (like avenrun), you could look around for > < > something > < > similar in your target kernel: > < > > < > kilroy> nm -x /mach_kernel | grep avenrun > < > 004d25ac 0f 08 0000 0002dbb9 _avenrun > < > kilroy> > < > > < > Of course, without the source, it''s not clear what the variable type is.... > < > > < > So....your example below is specific to Solaris. If you see the backtick > < > operator, think "kernel specific". > < > > < > HTH, > < > /jim > < > > < > > < > > < > Travis Crawford wrote: > < > > Hi dtrace-discuss, > < > > > < > > Having recently upgraded to OS X 10.5 I''m relatively new to DTrace, so > < > > apologies if this has been covered before; I did search the archives > < > > and didn''t find anything though. > < > > > < > > As a DTrace starter project I''d like to understand how to extract > < > > common performance metrics before diving too far in. One of these > < > > common metrics is load average, which I thought would be pretty easy. > < > > However, I''m confused by this code snippet (from > < > > http://www.brendangregg.com/DTrace/iotop): > < > > > < > > """ > < > > /* fetch 1 min load average */ > < > > this->load1a = `hp_avenrun[0] / 65536; > < > > this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536; > < > > """ > < > > > < > > I can''t figure out where hp_avenrun is defined. I searched > < > > http://wikis.sun.com/display/DTrace as well as looking at all the > < > > probes on my system ($ sudo dtrace -l | grep hp_avenrun) and came up > < > > empty. > < > > > < > > So my question is, when reading d scripts, how should I go about > < > > finding out what these mysterious variables are? > < > > > < > > Thanks, > < > > Travis > < > > _______________________________________________ > < > > dtrace-discuss mailing list > < > > dtrace-discuss at opensolaris.org > < > > > < > > < _______________________________________________ > < dtrace-discuss mailing list > < dtrace-discuss at opensolaris.org > > -- > Sean. > . >
Hello all DTrace gurus, In my company we are developing a system in order to collect, store, aggregate and produce graphs based on DTrace probes results. The idea is to access remotely to any DTrace system capable, remotely, to discover then push DTrace scripts automatically and get results to store and graph them. We did it with Solaris 10, and today we access remotely to DTrace using the Common Agent Containers (code name CACAO). Is anyone know if this type of agent are also implemented in OS X, FreeBSD or any other OS that are DTrace capable? thanks Sylvain QUARTIER email: squartier at infovista.com
On Mar 30, 2008, at 3:17 PM, Sean McGrath - Sun Microsystems Ireland wrote:> Why not browse the Apple port of The DTraceToolkit itself ? > > It uses averunnable.ldavg instead of the Solaris specific hp_avenrun. > Found from having a look at the OS-X port of DTrace at: > http://www.opensource.apple.com/darwinsource > > < > > As a DTrace starter project I''d like to understand how to > extract > < > > common performance metrics before diving too far in. One of > these > < > > common metrics is load average, which I thought would be > pretty easy. > < > > However, I''m confused by this code snippet (from > < > > http://www.brendangregg.com/DTrace/iotop):It''s even easier than that, because Apple included much (all?) of Brendan''s DTrace Toolkit in Mac OS X. The amazing thing? It''s already in your path: $ cd /usr/bin $ grep ''Brendan Gregg'' * | wc -l 94 This includes /usr/bin/iotop. Brendan, if you don''t write that damned blog post about this, I will! Adam -- Adam Leventhal, Fishworks http://blogs.sun.com/ahl