Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 24904 - Logging system needed for rc init scripts (/etc/init.d scripts)
Summary: Logging system needed for rc init scripts (/etc/init.d scripts)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-20 10:39 UTC by Dracula
Modified: 2005-11-20 02:47 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
This echos all output to /dev/kmsg (kernel 2.6.x only). (functions.sh.diff,2.48 KB, patch)
2003-11-09 10:42 UTC, Kurt Hindenburg
Details | Diff
A sample dmesg output with new the functions.sh (dmesg.1109,14.04 KB, text/plain)
2003-11-09 10:42 UTC, Kurt Hindenburg
Details
Patch for /sbin/functions.sh (functions.sh.diff2,2.63 KB, patch)
2003-11-14 22:59 UTC, Kurt Hindenburg
Details | Diff
/sbin/functions.sh patch for /dev/kmsg (functions.sh.diff,2.47 KB, patch)
2003-11-16 14:10 UTC, Kurt Hindenburg
Details | Diff
/sbin/functions.sh patch to send output to /dev/kmsg (functions.sh.diff,2.40 KB, patch)
2004-02-01 13:07 UTC, Kurt Hindenburg
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dracula 2003-07-20 10:39:39 UTC
One of the biggest problems I ran into with Gentoo was the fact that there's no
logging for the scripts that are run at boot time (the /etc/init.d scripts
linked in either the boot or default runlevels). This makes debugging very hard
when error messages scroll by in a hurry.

I understand it may not be possible to use the sys logger as it may not be
initialized yet at boot time, but some sort of logging that can be analyzed
later should be in place (such as teeing the output to a file).

Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 SpanKY gentoo-dev 2003-07-20 11:42:37 UTC
when the scripts error or show a warning they log ... 
Comment 2 Dracula 2003-07-20 14:18:41 UTC
where do they log??
Comment 3 Zhen Lin 2003-07-20 22:56:17 UTC
syslog, of course.

grep -r rc-scripts /var/log/

Only when ewarn or eerror is used.

However, stdout and stderr is NOT logged. 
Comment 4 Dracula 2003-07-20 23:01:47 UTC
Well, they should. I think this is a valid enhancement request. Usually the important information goes to stdout & stderr
Comment 5 Martin Schlemmer (RETIRED) gentoo-dev 2003-07-21 08:46:50 UTC
Its going to slow things a tad.  I will rather add it with a /etc/conf.d/rc
toggle, and maybe on that you can pass as kernel param.
Comment 6 Dracula 2003-07-21 10:31:27 UTC
I don't understand ... what's going to be slower? The whole boot process? Does it matter if it's 5 sec. slower? I would not care, a Linux machine is not something you have to reboot every 5 min. after the initial setup phase.

However, an option would be OK too, I suppose it could be used in the beginning to get things going and then it can be tunred off.

It would be really nice though to have a summary of the errors at the end of the boot process, to at least know whether everything went OK. A simple "No boot errors" or "Errors detected, see the log files in /var/log/rc-scripts..."
Comment 7 cobnet 2003-07-25 00:54:40 UTC
Hi, I also have the problem of not be able to see all of the output of the init scripts :(. I think it could be solved by:

1) Make the "pause" key work
2) Provide an option at boot time so that the system asks if he should start up script X for every script (I thought SuSE did it like this, Windows does (did?) this when booting in "Safe mode")
3) Make a logging facility
4) Make shift + PgUp work

But this view is an end user point of view :(. But I would say: just pick the fastest solution ;)...
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2003-10-13 15:37:29 UTC
If you can tell me how to make 1),3) and 4) work, as well as ctrl-c, I will
appreciate.
Comment 9 Kurt Hindenburg 2003-11-09 10:42:01 UTC
Created attachment 20477 [details, diff]
This echos all output to /dev/kmsg (kernel 2.6.x only).

This will echo all output to /dev/kmsg if it is writable (only 2.6.x kernels).

It patches /sbin/functions.sh
Comment 10 Kurt Hindenburg 2003-11-09 10:42:58 UTC
Created attachment 20478 [details]
A sample dmesg output with new the functions.sh
Comment 11 Kurt Hindenburg 2003-11-09 10:45:25 UTC
You'll need to add this to /etc/conf.d/rc:

# Set to "yes" to log all init.d/ messages to /dev/kmsg
RC_USE_KMSG="yes"
Comment 12 Kurt Hindenburg 2003-11-14 22:59:42 UTC
Created attachment 20771 [details, diff]
Patch for /sbin/functions.sh

This patch actually works.  I had to change the * to ^ due to bash weirdness.
Comment 13 Martin Schlemmer (RETIRED) gentoo-dev 2003-11-16 09:20:48 UTC
Two issues:
1) We do not want to do this if $EBUILD is set.  A better way might be
to check for $myservice, which means we will be in a rc-script.
2) I do not think we want colors in there.

Alternatively, we might want to prepend $myservice to the messages, and
maybe pipe all stderr to kmsg as well ...

Other than this it looks like a workable start.

Comments?
Comment 14 SpanKY gentoo-dev 2003-11-16 09:28:52 UTC
i like the idea of checking $myservice because ebuilds arent the only thing
that uses functions.sh for einfo/ebegin/etc...
Comment 15 Kurt Hindenburg 2003-11-16 14:10:00 UTC
Created attachment 20834 [details, diff]
/sbin/functions.sh patch for /dev/kmsg

Here's another patch:
1. Checks for $EBUILD
2. Removes all color to /dev/kmsg output.

Still need to do:
1. Use $myservice instead of $BUILD;  this doesn't appear to be a simple thing.

2. Send stderr to /dev/kmsg.
Comment 16 Kurt Hindenburg 2003-11-16 14:12:29 UTC
On another note in /sbin/functions.sh, I really dislike this :

 # Should we use color?
 RC_NOCOLOR="no"

First it is a double-negative and is confusing.  It should just be 
RC_COLOR, which everyone would understand.

I could put together a patch if you think it would be accepted.
Comment 17 Kurt Hindenburg 2003-11-16 15:34:48 UTC
Is this the correct method to determine if $myservice is an init.d/ script? 

echo_kmsg() {
   if [ -n "${myservice}" ] && [ -e "/etc/init.d/${myservice}" ] && 
      [ "${RC_USE_KMSG}" = "yes" ] && [ -w /dev/kmsg ]
   then
      echo ${*} >> /dev/kmsg
   fi
}
Comment 18 Kurt Hindenburg 2004-02-01 13:07:52 UTC
Created attachment 24776 [details, diff]
/sbin/functions.sh patch to send output to /dev/kmsg

This removes the ENDCOL since it messes up the dmesg output.  Also ebegin
output will not have a newline.
Comment 19 John Nilsson 2005-01-08 15:48:55 UTC
Soo... this is getting rather old. Any plans to accept this?
Comment 20 SpanKY gentoo-dev 2005-01-09 12:59:00 UTC
nope

i have a small patch to do logging via blogd like SuSE does it
Comment 21 Kurt Hindenburg 2005-01-09 13:13:32 UTC
Why use blogd?  Everyone running 2.6.x has /dev/kmesg.

Not that I really care... this is so old it is not even funny anymore.
Comment 22 SpanKY gentoo-dev 2005-01-09 13:26:28 UTC
- not everyone uses 2.6
- not everyone makes /dev/kmsg available
- blogd is transparent and requires no modifications to baselayout except to start and stop it
- the current solution provided here does not catch the output generated by applications (the rc system said 'error' but that's useless unless you see the error message generated by the app itself)
Comment 23 SpanKY gentoo-dev 2005-11-20 02:47:59 UTC
blogd has been integrated into stable baselayout