I've viewed bootchart source files for two days and by means of several hacks managed to receive boot charts for OpenSolaris. First of all I need to get uptime values in bootchart format (this is /proc/uptime content on linux). I've written the small utility (upt.c):
#include <sys/times.h>
#include <limits.h>
#include <dat/dat_platform_specific.h>
main {
struct tms ts;
clock_t t = times(&ts);
//we need jiffies from uptime value for bootchart
printf("%u\n",(unsigned long) ((DAT_UINT64) t*100 /CLK_TCK));
}
Now the main script for logging (/boot/bootchartd):
#!/usr/bin/bash
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/gnu/bin:$PATH"
# mounting dir for logging
mount -F tmpfs -o size=32m swap /var/log/bootchart
# start time hack for java parser
echo "001" > /var/log/bootchart/ps.log
echo " PID PPID S %CPU COMMAND" >> /var/log/bootchart/ps.log
echo " 1 0 S 0.0 kernel" >> /var/log/bootchart/ps.log
echo >> /var/log/bootchart/ps.log
while true; do
# uptime jiffies
uptime=`/sbin/upt`
echo $uptime
# Log the command output and removing pid 0 for preventing "No processes found" error
eval "ps -e -o pid,ppid,s,pcpu,comm"|grep -v sched
echo
/usr/gnu/bin/sleep 0.2
done >> /var/log/bootchart/ps.log
Let’s create directory /var/log/bootchart:
mkdir /var/log/bootchart
Next I move /sbin/init to /bin:
mv /sbin/init /bin
and create a new init:
cat /sbin/init
#!/bin/sh
/boot/bootchartd &
exec /bin/init
Now it's possible to reboot. After booting I write a header file:
echo "title = Boot chart for $( hostname | sed q ) ($( date ))" > /var/log/bootchart/header
echo "system.uname = $( uname -srvm | sed q )" >> /var/log/bootchart/header
if [ -f /etc/release ]; then
echo "system.release = $( sed q /etc/release )" >> /var/log/bootchart/header
else
echo "system.release = $( sed 's/\\.//g;q' /etc/issue )" >> /var/log/bootchart/header
fi
and create boot chart:
java -jar bootchart.jar
Parsing /var/log/bootchart
Wrote image: ./bootchart.png
This was the first boot chart created for OpenSolaris 2008.11 (Intel CPU 2.26GHz 512mb RAM). No disk and cpu utilization information yet:
Here the boot chart for snv101:
Very good work Alex. I wondered a while back when I was looking to reproduce this why they never shared their method and/or code. Thanks for sharing your time and effort.
ReplyDeleteIt would be great to see "Boot Charts" timing info combined into the OpenSolaris Bootscreen to provide a SMOOTH countdown for the Boot.
ReplyDeleteRob
Agree ;)
ReplyDelete