Hello everyone, FAI always saves the whole dmesg output on softupdates. This results in "errors"/unknown lines (error.log) even if those kernel messages were sent long ago, but you probably already known about them and you don't want to be disturbed by these old messages every time again. (Of course you can add more "rules" to savelog.LAST.source, but you don't want to disable serious error messages.)
So where did this lead us: You could delete the whole kernel ringbuffer (dmesg -c) on every softupdate, but then you have to search for old dmesg outputs in the FAI logs, instead of just typing dmesg - not practical. Our idea is to set a marker to the kernel ringbuffer (if you want to) and only save the dmesg output since the last softupdate. An example implementation (for FAI 3.4.7) is attached to this mail. While implementing this feature we were wondering why subroutines:save_dmesg is called twice (in two tasks) - the only explanation we had, that you have the dmesg.log even if a later task fails, but this output would still be incomplete (and possibly useless) if an event occurs a few seconds after saving the dmesg. Comments welcome! Best regards, Manuel Hachtkemper PS: Despite we think shortening the dmesg.log should be useful for most users we could think of a hook for this feature, but therefor it would be useful to make save_dmesg a task (and the information of previous actions would be helpful, too).
--- fai.orig 2011-08-04 14:36:55.184052445 +0200 +++ fai 2011-08-04 14:21:15.000000000 +0200 @@ -303,6 +303,11 @@ export fai_rundate=$(date +'%Y%m%d_%H%M%S') export LOGDIR=/var/log/fai/$HOSTNAME/$action-$fai_rundate mkdir -p $LOGDIR + + # keep information about previous symlink targets + previous_last_action_dir=$(readlink -nf $LOGDIR/../last-$action) + previous_last_dir=$(readlink -nf $LOGDIR/../last) + ln -snf $action-$fai_rundate $LOGDIR/../last-$action ln -snf $action-$fai_rundate $LOGDIR/../last fi
--- subroutines.orig 2011-08-04 14:37:48.073652791 +0200 +++ subroutines 2011-08-05 12:08:23.000000000 +0200 @@ -81,9 +81,35 @@ mount -o rw,remount $1 } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +### BEGIN SUBROUTINE INFO +# Provides-Var: none +# Requires-Var: $FAI_ACTION $LOGDIR $previous_last_action +# Short-Description: save dmesg output to $LOGDIR +### END SUBROUTINE INFO + save_dmesg() { - dmesg > $LOGDIR/dmesg.log + # set a marker to dmesg to only show messages since the last run + if [ "${DMESG_SHORTLOG:-0}" -eq 1 ]; then + if [ "$FAI_ACTION" = softupdate ]; then + dmesg_marker=${previous_last_action_dir##*/} + if ! dmesg | fgrep -q "$dmesg_marker"; then + unset dmesg_marker + fi + fi + fi + + # if DMESG_SHORTLOG is unset, not equals 1, dmesg_marker not + # availabe or FAI_ACTION is not softupdate save the whole output of dmesg + if [ -z "$dmesg_marker" ]; then + dmesg + else + dmesg | sed -e "1,/$dmesg_marker/d" + fi > $LOGDIR/dmesg.log + + if [ "${DMESG_SHORTLOG:-0}" -eq 1 ]; then + echo FAI marker: "${LOGDIR##*/}" > /dev/kmsg + fi } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - umount_csspace() { @@ -497,8 +523,6 @@ echo $$ > $stamp - save_dmesg - task partition task mountdisks task extrbase @@ -513,7 +537,7 @@ task chboot rm -f $stamp - save_dmesg # save again, because new messages could be created + save_dmesg task savelog if [ -f $stamp ]; then @@ -609,7 +633,6 @@ [ -f /var/lib/fai/disk_var.sh ] && cp -p /var/lib/fai/disk_var.sh $LOGDIR defnop wait_for_jobs - save_dmesg task mirror task debconf @@ -620,7 +643,6 @@ [ -f /proc/uptime ] && echo "The $FAI_ACTION took $[$(cut -d . -f 1 /proc/uptime)-$start_seconds] seconds." rm -f $stamp - # save again, because new messages could be created save_dmesg task savelog umount_csspace