sample
dtrace
printf instructions
Last update: 02.10.2011/bs
This page contains some printfs statements that can be used in dtrace
scripts.
Using dtrace builtin variables
printf( "Binary:
%16s,
Parameter 0: %16s \n", execname, copyinstr(arg0) );
Using p_user kernel variable
printf( "Executable:
%16s\n", curthread->t_procp->p_user.u_comm );
printf( "Parameter: %20s\n",
curthread->t_procp->p_user.u_psargs );
printf( "argc: %5d\n",
curthread->t_procp->p_user.u_argc );
printf( "pwd: %20s\n",
stringof( curthread->t_procp->p_user.u_cdir->v_path ) ) ;
printf( "root dir: %20s\n",
stringof( curthread->t_procp->p_user.u_rdir->v_path ) ) ;
printf(
"Parent process: %s\n" ,
curthread->t_procp->p_parent->p_user.u_comm );
printf( "Parent parent
process: %s\n" ,
curthread->t_procp->p_parent->p_parent->p_user.u_comm ) ;
Using p_cred kernel variable
printf( "Parent
effective
UID: %d\n", curthread->t_procp->p_parent->p_cred->cr_uid ) ;
printf(" Parent parent
effective UID: %d\n" ,
curthread->t_procp->p_parent->p_parent->p_cred->cr_uid )
;
printf(" Effective UID: %d\n" ,
curthread->t_procp->p_cred->cr_uid ) ;
printf(" Effective GID: %d\n" ,
curthread->t_procp->p_cred->cr_gid ) ;
printf(" Real UID: %d\n" ,
curthread->t_procp->p_cred->cr_ruid ) ;
printf(" Real GID: %d\n" ,
curthread->t_procp->p_cred->cr_rgid ) ;
printf(" Saved UID: %d\n" ,
curthread->t_procp->p_cred->cr_suid ) ;
printf(" Saved GID: %d\n" ,
curthread->t_procp->p_cred->cr_sgid ) ;
printf(" Number of groups: %d\n"
, curthread->t_procp->p_cred->cr_ngroups ) ;
printf(" Project ID: %d\n" ,
curthread->t_procp->p_cred->cr_projid ) ;
Using p_cred (cr_zone) kernel
variable
printf( "Zone: %s\n",
stringof(curthread->t_procp->p_parent->p_cred->cr_zone->zone_name)
)
;
printf(" Zone name: %s\n" ,
stringof( curthread->t_procp->p_cred->cr_zone->zone_name )
) ;
printf(" Zone nodename: %s\n" ,
stringof(
curthread->t_procp->p_cred->cr_zone->zone_nodename ) ) ;
printf(" Zone domain: %s\n" ,
stringof( curthread->t_procp->p_cred->cr_zone->zone_domain
) ) ;
printf(" Zone Rootpath: %s\n" ,
stringof(
curthread->t_procp->p_cred->cr_zone->zone_rootpath ) ) ;
printf(" Zone ID: %d\n" ,
curthread->t_procp->p_cred->cr_zone->zone_id ) ;
Using curpsinfo kernel variable
printf(" Process ID: %d\n",
curpsinfo->pr_pid ) ;
printf(" Parent Process ID: %d\n"
, curpsinfo->pr_ppid ) ;
printf(" PID of process leader:
%d\n", curpsinfo->pr_pgid );
printf(" Session ID: %d\n" ,
curpsinfo->pr_sid ) ;
printf(" Real User id: %d\n",
curpsinfo->pr_uid ) ;
printf(" Effective User ID:
%d\n", curpsinfo->pr_euid ) ;
printf(" Real Group ID: %d\n",
curpsinfo->pr_gid ) ;
printf(" Effective Group ID:
%d\n", curpsinfo->pr_egid ) ;
printf(" Task ID: %d\n",
curpsinfo->pr_taskid ) ;
printf(" Project ID: %d\n",
curpsinfo->pr_projid ) ;
printf(" Pool ID: %d\n",
curpsinfo->pr_poolid ) ;
printf(" Zone ID: %d\n",
curpsinfo->pr_zoneid ) ;