#!/usr/sbin/dtrace -Cs
#pragma D option quiet
/* I need process pid, his forks and life time */
proc:::create
{
printf("<fork ppid=%d cpid=%d execname=%s time=%d />\n",
pid,args[0]->pr_pid,execname,`lbolt*10/ `hz);
}
proc:::exec-success
{
printf("<process pid=%d execname=%s time=%d />\n",
pid,execname,`lbolt*10/ `hz);
}
proc:::exit
{
printf("<end pid=%d execname=%s time=%d />\n",
pid, execname,`lbolt*10/ `hz);
}
Then I enable anonymous tracing:
dtrace -AFs /boot/boot.d
reboot
After reboot I write a logfile and disable anonymous tracing:
dtrace -ae -o bootlog
dtrace -A
Logfile looks like this:
CPU FUNCTION
0 | exec_common:exec-success <process pid=1 execname=init time=63 />
0 | cfork:create <fork ppid=1 cpid=4 execname=init time=66 />
0 | exec_common:exec-success <process pid=4 execname=ksh93 time=67 />
0 | exec_common:exec-success <process pid=4 execname=autopush time=87 />
0 | proc_exit:exit <end pid=4 execname=autopush time=92 />
0 | cfork:create <fork ppid=1 cpid=5 execname=init time=92 />
0 | exec_common:exec-success <process pid=5 execname=ksh93 time=92 />
0 | exec_common:exec-success <process pid=5 execname=soconfig time=94 />
...
Now by help of a python it's possible to parse logfile. I've written a small script bootchart.py for parsing and chart construction. It would be great to trace and draw the cpu part but this is not implemented yet.
To create boot chart you need run bootchart.py with logfile as an argument:
bootchart.py bootlog
This is a boot chart example for OpenSolaris 2008.11: