From 8fb3af8d05555bc4a8206b7f524826bad77ad948 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Tue, 3 Mar 2009 19:43:26 +0200 Subject: initramfs: process accounting & misc fixes enable bootchartd to use kernel process accounting for noticing all processes. also fix various little bits around the initramfs init. --- bootchartd | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'bootchartd') diff --git a/bootchartd b/bootchartd index 0b0db4e..43fdfe9 100755 --- a/bootchartd +++ b/bootchartd @@ -17,8 +17,8 @@ PATH="/sbin:/bin:/usr/sbin:/usr/bin:$PATH" # Configuration for bootchartd, the bootchart logger script. TMPFS_SIZE=32m -SAMPLE_PERIOD=0.1 -PROCESS_ACCOUNTING="no" +SAMPLE_PERIOD=0.2 +PROCESS_ACCOUNTING="yes" BOOTLOG_DEST=/var/log/bootchart.tgz LOGDIR=/bootchart EXIT_PROC="mingetty agetty rungetty getty fgetty" @@ -97,7 +97,7 @@ do_logging() i=$(($i + 1)) done - [ -e kernel_pacct ] && accton off + [ -e kernel_pacct ] && accton } # Stop the boot logger. The lock file is removed to force the loggers in @@ -155,37 +155,43 @@ finalize() } case "$1" in -init) - # Started by the kernel or by the init script. +start-initfs) NEWROOT="$2" - mkdir "$LOGDIR" - cd "$LOGDIR" - ( + cleanup=true trap "not_stop_logging=false" USR1 - reexec=false - trap "reexec=true; not_stop_logging=false" USR2 + trap "cleanup=false; not_stop_logging=false" USR2 + mkdir "$LOGDIR" + cd "$LOGDIR" do_logging - if $reexec; then - mkdir "$NEWROOT$LOGDIR" - mv * "$NEWROOT$LOGDIR" - cp /sbin/bootchartd $NEWROOT/sbin - exec chroot $NEWROOT /sbin/bootchartd continue_logging \ - "$LOGDIR" $NEWROOT/dev/console 2>&1 - else - sleep $SAMPLE_PERIOD + if $cleanup; then sleep $SAMPLE_PERIOD finalize fi ) & + echo $! > $LOGDIR/bootchart.pid + ;; +stop-initfs) + NEWROOT="$2" + + cd "$LOGDIR" + mkdir "$NEWROOT$LOGDIR" + cp /sbin/bootchartd $NEWROOT/sbin + PID=`cat bootchart.pid` + kill -USR2 $PID + wait $PID + mv * "$NEWROOT$LOGDIR" ;; -continue_logging) - cd "$2" - trap "not_stop_logging=false" USR1 - do_logging - finalize +start-rootfs) + ( + trap "not_stop_logging=false" USR1 + cd "$LOGDIR" + do_logging + finalize + ) & + shift + exec "$@" ;; esac -- cgit v1.2.3