DTrace is an actively used programming language created in 2005.

14Years Old 1,025Users 0Jobs

Example code from the web:

# Syscall count by syscall
dtrace -n 'syscall:::entry { @num[probefunc] = count(); }'
# Syscall count by process
dtrace -n 'syscall:::entry { @num[pid,execname] = count(); }'

Example code from Linguist:

/*
 * This software is in the public domain.
 *
 * $Id: counts.d 10510 2005-08-15 01:46:19Z kateturner $
 */

#pragma D option quiet

self int tottime;
BEGIN {
	tottime = timestamp;
}

php$target:::function-entry
	@counts[copyinstr(arg0)] = count();
}

END {
	printf("Total time: %dus\n", (timestamp - tottime) / 1000);
	printf("# calls by function:\n");
	printa("%-40s %@d\n", @counts);
}

Example code from Wikipedia:

# New processes with arguments
dtrace -n 'proc:::exec-success { trace(curpsinfo->pr_psargs); }'

# Files opened by process
dtrace -n 'syscall::open*:entry { printf("%s %s",execname,copyinstr(arg0)); }'

# Syscall count by program
dtrace -n 'syscall:::entry { @num[execname] = count(); }'

# Syscall count by syscall
dtrace -n 'syscall:::entry { @num[probefunc] = count(); }'

# Syscall count by process
dtrace -n 'syscall:::entry { @num[pid,execname] = count(); }'

# Disk size by process
dtrace -n 'io:::start { printf("%d %s %d",pid,execname,args[0]->b_bcount); }'

# Pages paged in by process
dtrace -n 'vminfo:::pgpgin { @pg[execname] = sum(arg0); }'
Edit

Last updated February 11th, 2019