Hi I would like to see how the number of concurrent jobs in cron queue changes. I have located the piece of code I would be interested in: http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/cron/cron.c#2057 Can you please tell me how could I get the current value of qp->nrun? I tried: dtrace -n ''pid27208:cron:: '' dtrace: description ''pid27208:cron:: '' matched 324 probes CPU ID FUNCTION:NAME 0 55937 main:37c 0 55938 main:380 0 55939 main:384 0 55940 main:388 0 55941 main:38c 0 55942 main:390 0 55943 main:394 A lot more... but I do not get the functions names... Is DTRACE the correct tool to get such values? Any help would be greatly appreciated! Many thanks for your time Piotr -- This message posted from opensolaris.org
Adam Leventhal
2008-Jul-12 23:35 UTC
[dtrace-discuss] dtrace and cron - how to get qp->nrun?
> I would like to see how the number of concurrent jobs in cron queue > changes. I have located the piece of code I would be interested in: > http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/cron/cron.c#2057 > > Can you please tell me how could I get the current value of qp->nrun?You''ll want to instrument the entry probe for the ex() function: pidXXX::ex:entry The qp variable comes from an index into a global array. You''ll need to use another tool like mdb to determine the location of that variable, embed that location in the code, and use arg0 to determine e->etype as the index into the global array. Bear in mind, DTrace doesn''t yet support types from user processes, so you''ll need to either include those header files or define the types yourself. Take a look at the chapter on user-land tracing to get started: http://wikis.sun.com/display/DTrace/User+Process+Tracing> I tried: > dtrace -n ''pid27208:cron:: '' > dtrace: description ''pid27208:cron:: '' matched 324 probes > CPU ID FUNCTION:NAME > 0 55937 main:37c > 0 55938 main:380 > 0 55939 main:384 > 0 55940 main:388 > 0 55941 main:38c > 0 55942 main:390 > 0 55943 main:394 > A lot more... > > but I do not get the functions names...What you''ve done there is instrument every instruction in the cron binary -- probably not what you had in mind :-)> Is DTRACE the correct tool to get such values?It might be easier to use mdb(1). Adam -- Adam Leventhal, Fishworks http://blogs.sun.com/ahl
Hi Adam Many thanks for your answer and help! Piotr -- This message posted from opensolaris.org
For anyone interested: #!/usr/sbin/dtrace -s -32 #pragma D option quiet typedef struct { int njob; /* limit */ int nice; /* nice for execution */ int nwait; /* wait time to next execution attempt */ int nrun; /* number running */ } queue; queue *qp; dtrace:::BEGIN { printf("%-20s %s \n", "time", "nrun"); } pid$1::-:14dcc { qp = (queue *)copyin(0x0002df44, sizeof(queue)); printf("%-20Y %d\n",walltimestamp,qp->nrun); } and the output: root at sol10# ./cron.d 24666 time nrun 2008 Aug 11 14:24:00 5 2008 Aug 11 14:24:00 6 2008 Aug 11 14:25:00 6 2008 Aug 11 14:25:00 7 2008 Aug 11 14:25:00 8 2008 Aug 11 14:26:00 7 2008 Aug 11 14:26:00 6 2008 Aug 11 14:27:00 6 2008 Aug 11 14:28:00 5 2008 Aug 11 14:29:00 5 2008 Aug 11 14:30:00 5 2008 Aug 11 14:30:00 6 2008 Aug 11 14:30:00 7 2008 Aug 11 14:30:00 8 2008 Aug 11 14:32:00 5 Piotr -- This message posted from opensolaris.org