[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Misc monit questions
From: |
Martin Pala |
Subject: |
Re: Misc monit questions |
Date: |
Mon, 12 May 2003 08:50:58 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030314 |
arthur.chereau wrote:
3) I use syslog-ng and it is configured to get monit messages. But monit logs
also
appear on the console, although they are not emerg or alert logs (that is the
only logs
syslog-ng sends to the console). Is it because monit was started by init and
how can I
avoid this ?
This is because monit logs to the standard output whenever it has
controling terminal too.
To stop these messages (which are unwelcomed in such case) i think it
will be good to disable default logging to standard output in present
log() interface (probably we can keep exception for the cases where
monit don't have configured logging target - Run.dolog). On the places
where output to the terminal is needed, it will be better to use either
printf() or fprintf(stdout, ...) function directly.
not tested (keeps the above mentioned exception):
void log(const char *format, ...) {
va_list ap;
char msg[STRLEN];
ASSERT(format);
va_start(ap,format);
vsnprintf(msg, STRLEN, format, ap);
va_end(ap);
if(!Run.dolog && Run.have_tty) {
fprintf(stdout, "%s", msg);
fflush(stdout);
}
if(Run.use_syslog) {
syslog(LOG_ERR|LOG_USER, "%s", msg);
} else if(LOG) {
fprintf(LOG,"[%s] %s", timestr(), msg);
}
}
Then use of log() function must be revised and printf() or
fprintf(stdout, ...) should be added where needed.
What about it?
Cheers,
Martin