Roman Naumenko
2009-Oct-19 16:39 UTC
[dtrace-discuss] Running dtrace sript for defined period of time?
Hello, I''m building some simple monitoring tools to watch zfs storage servers. Is this possible to run dtrace script for example 10 seconds? (Of course it is, I just trying to figure out how). Right know it has to be stopped by "CTRL-C" I''m particulary interested in scripts like iscsiio.d, iscsiwho.d from http://www.solarisinternals.com/wiki/index.php/DTrace_Topics_iSCSI Thanks in advance, Roman Naumenko roman at frontline.ca -- This message posted from opensolaris.org
Angelo Rajadurai
2009-Oct-19 16:45 UTC
[dtrace-discuss] Running dtrace sript for defined period of time?
Add a tick-10s probe to the end and do an exit. Just note that tick-10s will fire in about 10 sec and this is not exactly at 10s. Here is what you need to add. tick-10s { exit(0); } -Angelo On Oct 19, 2009, at 12:39 PM, Roman Naumenko wrote:> Hello, > > I''m building some simple monitoring tools to watch zfs storage > servers. > > Is this possible to run dtrace script for example 10 seconds? (Of > course it is, I just trying to figure out how). Right know it has to > be stopped by "CTRL-C" > > I''m particulary interested in scripts like iscsiio.d, iscsiwho.d > from http://www.solarisinternals.com/wiki/index.php/DTrace_Topics_iSCSI > > Thanks in advance, > Roman Naumenko > roman at frontline.ca > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Chad Mynhier
2009-Oct-19 17:07 UTC
[dtrace-discuss] Running dtrace sript for defined period of time?
If you''re a little more concerned with getting it close to 10 seconds, you can use something like this: tick-1s / i++ >= 10 / { exit(0); } The reason the tick-10s probe might fire sooner than 10 seconds is that DTrace will use an existing probe if there is one. If script A is the first to create a tick-10s probe, it will fire after 10 seconds. If script B enables a tick-10s, it will fall into lockstep with script A. If script B is started 9 seconds after script A, the first time it will fire is after 1 second. The above trick really only gets you better resolution. Instead of your D script exiting sometime between 0 and 10 seconds, it would exit sometime between 9 and 10 seconds. Chad On Mon, Oct 19, 2009 at 12:45 PM, Angelo Rajadurai <Angelo.Rajadurai at sun.com> wrote:> Add a tick-10s probe to the end and do an exit. Just note that tick-10s will > fire in about 10 sec and this is not exactly at 10s. > > Here is what you need to add. > > tick-10s > { > ? ? ? ?exit(0); > } > > -Angelo > > On Oct 19, 2009, at 12:39 PM, Roman Naumenko wrote: > >> Hello, >> >> I''m building some simple monitoring tools to watch zfs storage servers. >> >> Is this possible to run dtrace script for example 10 seconds? (Of course >> it is, I just trying to figure out how). Right know it has to be stopped by >> "CTRL-C" >> >> I''m particulary interested in scripts like iscsiio.d, iscsiwho.d from >> http://www.solarisinternals.com/wiki/index.php/DTrace_Topics_iSCSI >> >> Thanks in advance, >> Roman Naumenko >> roman at frontline.ca >> -- >> This message posted from opensolaris.org >> _______________________________________________ >> dtrace-discuss mailing list >> dtrace-discuss at opensolaris.org > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
Roman Naumenko
2009-Oct-20 12:48 UTC
[dtrace-discuss] Running dtrace sript for defined period of time?
> If you''re a little more concerned with getting it > close to 10 seconds, > you can use something like this: > > tick-1s > / i++ >= 10 / > { > exit(0);How this script should look to have this 10 sec intervals? #!/usr/sbin/dtrace -s /* * iscsiio.d - Report iSCSI I/O. Solaris Nevada, DTrace. * * This traces requested iSCSI data I/O events when run on an iSCSI server. * The output reports iSCSI read and write I/O while this script was running. * * USAGE: iscsiio.d # Hit Ctrl-C to end * * FIELDS: * REMOTE IP IP address of the client * EVENT Data I/O event (read/write) * COUNT Number of I/O events * Kbytes Total data Kbytes transferred * KB/sec Average data Kbytes/sec transferred */ #pragma ident "@(#)iscsiio.d 1.2 07/03/27 SMI" #pragma D option quiet dtrace:::BEGIN { printf("Tracing... Hit Ctrl-C to end.\n"); start = timestamp; } iscsi*:::data-send { @num[args[0]->ci_remote, "read"] = count(); @bytes[args[0]->ci_remote, "read"] = sum(args[1]->ii_datalen); @rate[args[0]->ci_remote, "read"] = sum(args[1]->ii_datalen); } iscsi*:::data-receive { @num[args[0]->ci_remote, "write"] = count(); @bytes[args[0]->ci_remote, "write"] = sum(args[1]->ii_datalen); @rate[args[0]->ci_remote, "write"] = sum(args[1]->ii_datalen); } iscsi*:::scsi-command /args[2]->ic_cdb[0] == 0x0a || args[2]->ic_cdb[0] == 0x2a/ { /* * scsi-command writes also move data. Their codes are in * /usr/include/sys/scsi/generic/commands.h . */ @num[args[0]->ci_remote, "write"] = count(); @bytes[args[0]->ci_remote, "write"] = sum(args[1]->ii_datalen); @rate[args[0]->ci_remote, "write"] = sum(args[1]->ii_datalen); } dtrace:::END { normalize(@rate, (timestamp - start) * 1024 / 1000000000); printf(" %-26s %8s %8s %10s %10s\n", "REMOTE IP", "EVENT", "COUNT", "Kbytes", "KB/sec"); normalize(@bytes, 1024); printa(" %-26s %8s %@8d %@10d %@10d\n", @num, @bytes, @rate); } -- This message posted from opensolaris.org
Angelo Rajadurai
2009-Oct-20 12:55 UTC
[dtrace-discuss] Running dtrace sript for defined period of time?
Hi Roman: It should be -Angelo #!/usr/sbin/dtrace -s /* * iscsiio.d - Report iSCSI I/O. Solaris Nevada, DTrace. * * This traces requested iSCSI data I/O events when run on an iSCSI server. * The output reports iSCSI read and write I/O while this script was running. * * USAGE: iscsiio.d # Hit Ctrl-C to end * * FIELDS: * REMOTE IP IP address of the client * EVENT Data I/O event (read/write) * COUNT Number of I/O events * Kbytes Total data Kbytes transferred * KB/sec Average data Kbytes/sec transferred */ #pragma ident "@(#)iscsiio.d 1.2 07/03/27 SMI" #pragma D option quiet dtrace:::BEGIN { printf("Tracing... Hit Ctrl-C to end.\n"); start = timestamp; } iscsi*:::data-send { @num[args[0]->ci_remote, "read"] = count(); @bytes[args[0]->ci_remote, "read"] = sum(args[1]->ii_datalen); @rate[args[0]->ci_remote, "read"] = sum(args[1]->ii_datalen); } iscsi*:::data-receive { @num[args[0]->ci_remote, "write"] = count(); @bytes[args[0]->ci_remote, "write"] = sum(args[1]->ii_datalen); @rate[args[0]->ci_remote, "write"] = sum(args[1]->ii_datalen); } iscsi*:::scsi-command /args[2]->ic_cdb[0] == 0x0a || args[2]->ic_cdb[0] == 0x2a/ { /* * scsi-command writes also move data. Their codes are in * /usr/include/sys/scsi/generic/commands.h . */ @num[args[0]->ci_remote, "write"] = count(); @bytes[args[0]->ci_remote, "write"] = sum(args[1]->ii_datalen); @rate[args[0]->ci_remote, "write"] = sum(args[1]->ii_datalen); } dtrace:::END { normalize(@rate, (timestamp - start) * 1024 / 1000000000); printf(" %-26s %8s %8s %10s %10s\n", "REMOTE IP", "EVENT", "COUNT", "Kbytes", "KB/sec"); normalize(@bytes, 1024); printa(" %-26s %8s %@8d %@10d %@10d\n", @num, @bytes, @rate); } tick-1s /i++ >=10/ { exit(0); }
Chad Mynhier
2009-Oct-20 12:59 UTC
[dtrace-discuss] Running dtrace sript for defined period of time?
On Tue, Oct 20, 2009 at 8:48 AM, Roman Naumenko <roman at frontline.ca> wrote:>> If you''re a little more concerned with getting it >> close to 10 seconds, >> you can use something like this: >> >> tick-1s >> / i++ >= 10 / >> { >> ? ? exit(0); > > How this script should look to have this 10 sec intervals?You just need to append this extra clause to the end of the file, like this: [ ... ] dtrace:::END { ? ? ? ?normalize(@rate, (timestamp - start) * 1024 / 1000000000); ? ? ? ?printf(" ? %-26s %8s %8s %10s %10s\n", "REMOTE IP", "EVENT", "COUNT", ? ? ? ? ? ?"Kbytes", "KB/sec"); ? ? ? ?normalize(@bytes, 1024); ? ? ? ?printa(" ? %-26s %8s %@8d %@10d %@10d\n", @num, @bytes, @rate); } tick-1s / i++ >= 10 / { exit(0); } Chad
Roman Naumenko
2009-Oct-20 16:54 UTC
[dtrace-discuss] Running dtrace sript for defined period of time?
Works! Is there much overhead to have this script running from time to time on a loaded storage server? It''s for 10-20 targets on 1GigE interfaces working with 8 disks raid10 array. -- Roman -- This message posted from opensolaris.org
James Litchfield
2009-Oct-20 20:07 UTC
[dtrace-discuss] Running dtrace sript for defined period of time?
It depends on the number of activities that DTrace will be recording. It a small number, the load will be light. If a large number, the load will be more. If a large number, you''d want to look at manipulating aggsize and aggrate. It also depends on how many CPUs there are. You might perhaps reduce the load by having @r... and @w... aggregations for the read and write cases. You avoid use of a key that is essentially of no use. Another win is that you will have more effective space available for storing aggregation data.The trade off is that you''re now doubling the number of extractions from the kernel by the userland DTrace process as well as doubling the kernel memory consumption. Jim Litchfield ===========Roman Naumenko wrote:> Works! > > Is there much overhead to have this script running from time to time on a loaded storage server? > It''s for 10-20 targets on 1GigE interfaces working with 8 disks raid10 array. > > -- > Roman >