Monday, January 12, 2009

Boot chart with help of DTrace and Python

Anonymous tracing allows to receive more interesting information about Solaris booting process. I use a simple D-script (boot.d):

#!/usr/sbin/dtrace -Cs
#pragma D option quiet
/* I need process pid, his forks and life time */
printf("<fork ppid=%d cpid=%d execname=%s time=%d />\n",
pid,args[0]->pr_pid,execname,`lbolt*10/ `hz);

printf("<process pid=%d execname=%s time=%d />\n",
pid,execname,`lbolt*10/ `hz);


printf("<end pid=%d execname=%s time=%d />\n",
pid, execname,`lbolt*10/ `hz);

Then I enable anonymous tracing:

dtrace -AFs /boot/boot.d

After reboot I write a logfile and disable anonymous tracing:

dtrace -ae -o bootlog
dtrace -A

Logfile looks like this:

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 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 with logfile as an argument: bootlog

This is a boot chart example for OpenSolaris 2008.11:


Anonymous said...

your post is helpful and informative

web design India

Unknown said...

Talk about understatement! This is slick; thank you for sharing it.

Anonymous said...

Great blog and nice post I am trying to maintain a list of cute blogs. Thanks and nice collection of blogs. I’m going to have to browse through those. it’s nice I can come and read your blog.
ccna ccent

M. Behrens said...

Could this be used to monitor a specific process - say to capture the performance of a particular process over a period of time? I'm new to could a specific PID be used to manually capture the stats of a running process (as apposed to all the processes)? Good stuff - thanks.

alhazred said...

It's easy to make on already loaded system. To create the boot chart is probably just need to find the desired command from the file and make the graph only for it

Unknown said...

Just tried this on snv_134 and got the following:

line 7: failed to resolve `lbolt: Unknown symbol name

Looking through /dev/ksyms, I see a multitude of local <...>_lbolt objects, but no global lbolt object.

alhazred said...

It seems this is due clock driven lbolt migration. Not tested, but I think now need use next function:
lbolt = args[1];

How to determine PXE mac address when booting illumos via PXELinux/iPXE

In illumos, if you need to determine the interface which was used for booting via PXE then it's possible to use "boot-mac" pro...