To me, it seems that probably this doesn't work with DtraceToolkit scripts,
because some scripts takes actions before it receives the SIGINT signals.
However this could work with scripts that only need a delay.

Thanks Adam.

I write ktime because is not very easy to change scripts from dtrace.

Here is my little history"
At work we need to put monitoring scripts with errinfo, but it don’t 
have a -t flag ( time )so I made a change in order that you could call it 
Like this:

./errinfo
http://kbradero.neuroaio.biz/gnu/errinfo-scripteable

#cat > errinfo
 <paste the file>
^d
#chmod +x errinfo
./errinfo -t "time in seconds" -c -u $user     > output  


If you made a diff between this version and the original from 
DtraceToolkit-0.99 you could seed that the change are not so simple that 
You could do It (fast) with all.


Saludos!

-----Original Message-----
From: Adam Leventhal [mailto:[EMAIL PROTECTED] 
Sent: Miércoles, 14 de Noviembre de 2007 03:38 p.m.
To: jorge gmail
Cc: [email protected]
Subject: Re: [dtrace-discuss] automate DtraceToolkit scripts with ktime

Alternatively, you could modify the scripts so they exit after a specified
interval:

tick-1s
/i++ >= $1/
{
        exit(0);
}

Adam

On Wed, Nov 14, 2007 at 03:10:05PM -0600, jorge gmail wrote:
>  
> 
> Hi all,  i write a little program  that could be useful if you have
> DtraceToolkit. Almost all scripts wait until you press ctrl+c key, but
> 
> If want to automate this task this is not possible because you need to
stay
> in front of your terminal.
> 
>  
> 
> Ktime launch the program passed as parameter and wait <time>  ( in
seconds)
> until send  a ctr+c signal ( SIGINT) to the child process.
> 
>  
> 
>  
> 
> http://kbradero.neuroaio.biz/gnu/ktime/ktime.c  ( source code  online )
> 
> http://kbradero.neuroaio.biz/gnu/ktime/solaris/  binary 
> 
> Examples :
> 
> ./ktime shortlived.d 20 
> 
>  
> 
> Syntaxis:
> 
> ./ktime <program> <time>
> 
>  
> 
> #crontab -l 
> 
> * * * * * /tmp/test/DTraceToolkit-0.99/Bin/mon.sh
> 
>  
> 
> You could integrate in other scripts:
> 
>  
> 
> /tmp/test/DTraceToolkit-0.99/Bin/>#cat mon.sh
> 
> #!/bin/bash
> 
> cd /tmp/test/DTraceToolkit-0.99/Bin/
> 
> /tmp/test/DTraceToolkit-0.99/Bin/ktime errinfo 20  > state.txt
> 
> echo `date` >> state.txt
> 
>  
> 
>  
> 
>  
> 
>  
> 
> The code:
> 
>  
> 
> cat ktime.c
> 
> #include <stdio.h> 
> 
> #include <string.h>
> 
> #include <stdlib.h> 
> 
> #include <unistd.h>
> 
> #include <signal.h>
> 
>  
> 
>  
> 
> /*
> 
> Author: Jorge Alberto Garcia Gonzalez
> 
> email: jorge.garcia.gonzalez(en)gmail.com
> 
> Usage: ./ktime   shortlived.d  10
> 
>          ktime <program > <program parameters> <seconds until send ctrl+c
>
> 
> 
> way to compile: gcc ktime.c -o ktime
> 
> */
> 
> int main( int argc, char *argv[]){
> 
>         pid_t child_pid=0;
> 
>         char *arguments=NULL;
> 
>         int narguments= argc-2; /* chid arguments*/ 
> 
>         int i=argc-1 ;
> 
>         int element=1;
> 
>         int  lenarg=0;
> 
>         
> 
>  
> 
>         for( element=1; element <=argc-2  ;element++){
> 
>                         lenarg+= strlen(argv[ element ]) +1 ;
> 
>                         printf("%d \n",lenarg);
> 
>         }       
> 
>         lenarg+=1;
> 
>         element=1;
> 
>  
> 
>         arguments=(char *) malloc(  lenarg * sizeof(char)  );
> 
>  
> 
>         for( element=1; element <=argc-2  ; element++ ){
> 
>                 strcat( arguments, argv[ element ] );
> 
>                 strcat( arguments, " ");
> 
>                 /* 
> 
>                         printf("argumento: %s \n", argv[ element ] );
> 
>                 */
> 
>         }
> 
>  
> 
>                 /*
> 
>                         printf("child arguments: %s \n", arguments );
> 
>                 */
> 
>  
> 
>         if(   ( child_pid=fork()   )==0  ){
> 
>  
> //execl("/tmp/test/DTraceToolkit-0.99/Bin/errinfo","errinfo",(char *)0);
> 
>                  execv(argv[1],&arguments );
> 
>  
> 
>         }else
> 
>         { 
> 
>                 sleep(   atoi(argv[argc-1])  ) ;        
> 
>                 kill(child_pid,SIGINT)    ;     
> 
>                 //printf("child: %d is dead,
leaving...\n",(int)child_pid);
> 
>         }
> 
> return 0;
> 
> }
> 
>  
> 
>  
> 

> _______________________________________________
> dtrace-discuss mailing list
> [email protected]


-- 
Adam Leventhal, FishWorks                        http://blogs.sun.com/ahl

_______________________________________________
dtrace-discuss mailing list
[email protected]

Reply via email to