[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Silent stderr patch
From: |
Christopher P. Lindsey |
Subject: |
Silent stderr patch |
Date: |
Tue, 26 Sep 2006 14:31:56 -0500 |
User-agent: |
Mutt/1.5.10i |
Yesterday we had a problem with a networked filesystem going down, killing
lots of different servers on various systems. I wanted to log in via
the serial console to make system changes, but monit kept failing to start
processes and was writing tons of stuff to stderr. This meant that the
console was bogged down with noise and clutter, making simple shell commands
difficult and a vi session nearly impossible.
"Wouldn't it be great," I thought while rapidly hitting CTRL-L as
/etc/inittab started to resemble a screenshot from The Matrix, "if there
was a monit directive to disable stderr output?"
Thus, a patch was born. Included below is some code that adds a
'nostderr' directive. If enabled in /etc/monitrc like
set nostderr
monit will no longer produce copious quantities of console clutter.
Chris
----------------------------------------------------------------------
diff -rc monit-4.8.1/l.l monit-4.8.1-new/l.l
*** monit-4.8.1/l.l Sun Apr 9 15:50:59 2006
--- monit-4.8.1-new/l.l Tue Sep 26 13:50:01 2006
***************
*** 157,162 ****
--- 157,163 ----
certmd5 { return CERTMD5; }
pemfile { return PEMFILE; }
init { return INIT; }
+ nostderr { return NOSTDERR; }
allow { return ALLOW; }
read[-]?only { return READONLY; }
pidfile { return PIDFILE; }
diff -rc monit-4.8.1/log.c monit-4.8.1-new/log.c
*** monit-4.8.1/log.c Thu May 4 18:50:03 2006
--- monit-4.8.1-new/log.c Tue Sep 26 14:21:46 2006
***************
*** 365,371 ****
ASSERT(s);
! LOCK(log_mutex)
#ifdef HAVE_VA_COPY
va_copy(ap_copy, ap);
vfprintf(stderr, s, ap_copy);
--- 365,372 ----
ASSERT(s);
! if(! Run.nostderr) {
! LOCK(log_mutex)
#ifdef HAVE_VA_COPY
va_copy(ap_copy, ap);
vfprintf(stderr, s, ap_copy);
***************
*** 374,380 ****
vfprintf(stderr, s, ap);
#endif
fflush(stderr);
! END_LOCK;
if(Run.dolog) {
char datetime[STRLEN];
--- 375,382 ----
vfprintf(stderr, s, ap);
#endif
fflush(stderr);
! END_LOCK;
! }
if(Run.dolog) {
char datetime[STRLEN];
diff -rc monit-4.8.1/monitor.h monit-4.8.1-new/monitor.h
*** monit-4.8.1/monitor.h Thu Apr 27 15:52:31 2006
--- monit-4.8.1-new/monitor.h Tue Sep 26 12:45:03 2006
***************
*** 707,712 ****
--- 707,713 ----
int stopped; /**< TRUE if monit was stopped. Flag used by threads
*/
char *controlfile; /**< The file to read configuration from
*/
char *logfile; /**< The file to write logdata into
*/
+ char *nostderr;
char *localhostname; /**< The host name for localhost
*/
char *pidfile; /**< This programs pidfile
*/
char *statefile; /**< The file with the saved runtime state
*/
diff -rc monit-4.8.1/p.y monit-4.8.1-new/p.y
*** monit-4.8.1/p.y Wed May 10 15:29:00 2006
--- monit-4.8.1-new/p.y Tue Sep 26 13:19:08 2006
***************
*** 244,250 ****
}
%token IF ELSE THEN OR FAILED
! %token SET LOGFILE FACILITY DAEMON SYSLOG MAILSERVER HTTPD ALLOW ADDRESS INIT
%token READONLY CLEARTEXT MD5HASH SHA1HASH CRYPT
%token PEMFILE ENABLE DISABLE HTTPDSSL CLIENTPEMFILE ALLOWSELFCERTIFICATION
%token STATEFILE SEND EXPECT CYCLE COUNT REMINDER
--- 244,250 ----
}
%token IF ELSE THEN OR FAILED
! %token SET LOGFILE FACILITY DAEMON NOSTDERR SYSLOG MAILSERVER HTTPD ALLOW
ADDRESS INIT
%token READONLY CLEARTEXT MD5HASH SHA1HASH CRYPT
%token PEMFILE ENABLE DISABLE HTTPDSSL CLIENTPEMFILE ALLOWSELFCERTIFICATION
%token STATEFILE SEND EXPECT CYCLE COUNT REMINDER
***************
*** 297,302 ****
--- 297,303 ----
| setpid
| setstate
| setinit
+ | setnostderr
| checkproc optproclist
| checkfile optfilelist
| checkdev optdevlist
***************
*** 446,451 ****
--- 447,457 ----
}
;
+ setnostderr : SET NOSTDERR {
+ Run.nostderr= TRUE;
+ }
+ ;
+
setinit : SET INIT {
Run.init= TRUE;
}
***************
*** 1688,1693 ****
--- 1694,1700 ----
Run.MailFormat.from= NULL;
Run.MailFormat.subject= NULL;
Run.MailFormat.message= NULL;
+ Run.nostderr=NULL;
Run.localhostname= xstrdup(localhost);
depend_list= NULL;
Run.handler_init= TRUE;
- Silent stderr patch,
Christopher P. Lindsey <=