[csw-devel] SF.net SVN: gar:[18434] csw/mgar/pkg/monit/trunk

bdwalton at users.sourceforge.net bdwalton at users.sourceforge.net
Sat Jun 16 05:03:08 CEST 2012


Revision: 18434
          http://gar.svn.sourceforge.net/gar/?rev=18434&view=rev
Author:   bdwalton
Date:     2012-06-16 03:03:08 +0000 (Sat, 16 Jun 2012)
Log Message:
-----------
monit/trunk: patch out usr/local references (disable /usr/local/etc/monitrc as a config file location)

Modified Paths:
--------------
    csw/mgar/pkg/monit/trunk/Makefile

Added Paths:
-----------
    csw/mgar/pkg/monit/trunk/files/0002-fix-usr-local-references-drop-usr-local-etc-monitrc-.patch

Modified: csw/mgar/pkg/monit/trunk/Makefile
===================================================================
--- csw/mgar/pkg/monit/trunk/Makefile	2012-06-16 02:38:23 UTC (rev 18433)
+++ csw/mgar/pkg/monit/trunk/Makefile	2012-06-16 03:03:08 UTC (rev 18434)
@@ -17,6 +17,7 @@
 MASTER_SITES = http://mmonit.com/monit/dist/
 DISTFILES  = $(DISTNAME).tar.gz
 PATCHFILES += 0001-Drop-some-build-flags-that-get-hard-coded-by-configu.patch
+PATCHFILES += 0002-fix-usr-local-references-drop-usr-local-etc-monitrc-.patch
 
 GARCOMPILER = GNU
 BUILD64_ONLY = 1

Added: csw/mgar/pkg/monit/trunk/files/0002-fix-usr-local-references-drop-usr-local-etc-monitrc-.patch
===================================================================
--- csw/mgar/pkg/monit/trunk/files/0002-fix-usr-local-references-drop-usr-local-etc-monitrc-.patch	                        (rev 0)
+++ csw/mgar/pkg/monit/trunk/files/0002-fix-usr-local-references-drop-usr-local-etc-monitrc-.patch	2012-06-16 03:03:08 UTC (rev 18434)
@@ -0,0 +1,315 @@
+From 37a0f9a55f325d568fae29bf7eb6a6846d9047bf Mon Sep 17 00:00:00 2001
+From: Ben Walton <bwalton at opencsw.org>
+Date: Sat, 16 Jun 2012 04:56:23 +0200
+Subject: [PATCH] fix usr/local references (drop /usr/local/etc/monitrc as an
+ option)
+
+Signed-off-by: Ben Walton <bwalton at opencsw.org>
+---
+ libmonit/src/system/Command.c |    2 +-
+ libmonit/src/system/Command.h |    2 +-
+ libmonit/test/CommandTest.c   |    4 ++--
+ monit.1                       |   50 ++++++++++++++++++++---------------------
+ monitrc                       |    4 ++--
+ src/file.c                    |   10 +++------
+ src/file.h                    |    5 ++---
+ 7 files changed, 36 insertions(+), 41 deletions(-)
+
+diff --git a/libmonit/src/system/Command.c b/libmonit/src/system/Command.c
+index cd7b001..8d72952 100644
+--- a/libmonit/src/system/Command.c
++++ b/libmonit/src/system/Command.c
+@@ -78,7 +78,7 @@ struct Process_T {
+         OutputStream_T out;
+         char *working_directory;
+ };
+-const char *Command_Path = "PATH=/bin:/usr/bin:/usr/local/bin:/opt/csw/bin:/usr/sfw/bin";
++const char *Command_Path = "PATH=/bin:/usr/bin:/opt/csw/bin:/usr/sfw/bin";
+ 
+ 
+ /* --------------------------------------------------------------- Private */
+diff --git a/libmonit/src/system/Command.h b/libmonit/src/system/Command.h
+index c2a364a..ba62123 100644
+--- a/libmonit/src/system/Command.h
++++ b/libmonit/src/system/Command.h
+@@ -49,7 +49,7 @@
+ #define T Command_T
+ typedef struct T *T;
+ /** 
+- * Default Path for Command: <code>PATH=/bin:/usr/bin:/usr/local/bin:/opt/csw/bin:/usr/sfw/bin</code>. 
++ * Default Path for Command: <code>PATH=/bin:/usr/bin:/opt/csw/bin:/usr/sfw/bin</code>. 
+  * May be overridden by Command_setEnv() 
+  */
+ extern const char *Command_Path;
+diff --git a/libmonit/test/CommandTest.c b/libmonit/test/CommandTest.c
+index 1428401..013e454 100644
+--- a/libmonit/test/CommandTest.c
++++ b/libmonit/test/CommandTest.c
+@@ -136,7 +136,7 @@ int main(void) {
+                 Command_T c = Command_new("/bin/sh", "-c", "ps -aef|grep monit", NULL);
+                 assert(c);
+                 // Check default PATH
+-                assert(Str_isEqual(Command_getEnv(c, "PATH"), "/bin:/usr/bin:/usr/local/bin:/opt/csw/bin:/usr/sfw/bin"));
++                assert(Str_isEqual(Command_getEnv(c, "PATH"), "/bin:/usr/bin:/opt/csw/bin:/usr/sfw/bin"));
+                 // Set and get
+                 Command_setEnv(c, "LANG", "C");
+                 assert(Str_isEqual(Command_getEnv(c, "LANG"), "C"));
+@@ -144,7 +144,7 @@ int main(void) {
+                 assert(Str_isEqual(Command_getEnv(c, "SHELL"), "/bin/bash"));
+                 // setEnvString
+                 // Check default PATH
+-                assert(Str_isEqual(Command_getEnv(c, "PATH"), "/bin:/usr/bin:/usr/local/bin:/opt/csw/bin:/usr/sfw/bin"));
++                assert(Str_isEqual(Command_getEnv(c, "PATH"), "/bin:/usr/bin:/opt/csw/bin:/usr/sfw/bin"));
+                 // Set and get env string
+                 Command_vSetEnv(c, "PATH=/usr/bin;SHELL=/bin/bash");
+                 assert(Str_isEqual(Command_getEnv(c, "PATH"), "/usr/bin"));
+diff --git a/monit.1 b/monit.1
+index d95d6fc..8d8803b 100644
+--- a/monit.1
++++ b/monit.1
+@@ -461,7 +461,7 @@ command line. Here is what you must add to /etc/inittab:
+ .PP
+ .Vb 2
+ \&  # Run Monit in standard run\-levels
+-\&  mo:2345:respawn:/usr/local/bin/monit \-Ic /etc/monitrc
++\&  mo:2345:respawn:/usr/foo/bin/monit \-Ic /etc/monitrc
+ .Ve
+ .PP
+ After you have modified init's configuration file, you can run
+@@ -1245,7 +1245,7 @@ optionally specify the uid and gid the executed program should
+ switch to upon start. For instance:
+ .Sp
+ .Vb 2
+-\& exec "/usr/local/tomcat/bin/startup.sh"
++\& exec "/usr/foo/tomcat/bin/startup.sh"
+ \&      as uid nobody and gid nobody
+ .Ve
+ .Sp
+@@ -1408,9 +1408,9 @@ changed. The following illustrates this for the apache web
+ server:
+ .PP
+ .Vb 3
+-\& check file httpd.conf path /usr/local/apache/conf/httpd.conf
++\& check file httpd.conf path /usr/foo/apache/conf/httpd.conf
+ \&     if changed sha1 checksum 
+-\&        then exec "/usr/local/apache/bin/apachectl graceful"
++\&        then exec "/usr/foo/apache/bin/apachectl graceful"
+ .Ve
+ .PP
+ If you plan to use the checksum statement for security reasons,
+@@ -1458,9 +1458,9 @@ reload apache if the \fIhttpd.conf\fR (apache's configuration file)
+ was changed. Like so:
+ .PP
+ .Vb 3
+-\& check file httpd.conf with path /usr/local/apache/conf/httpd.conf
++\& check file httpd.conf with path /usr/foo/apache/conf/httpd.conf
+ \&   if changed timestamp
+-\&      then exec "/usr/local/apache/bin/apachectl graceful"
++\&      then exec "/usr/foo/apache/bin/apachectl graceful"
+ .Ve
+ .PP
+ The constant timestamp version is useful for monitoring systems
+@@ -1511,7 +1511,7 @@ third-party applications, until the vendor fix a problem:
+ .Vb 3
+ \& check file server.pid path /var/run/server.pid
+ \&       if timestamp > 7 days 
+-\&          then exec "/usr/local/server/restart\-server"
++\&          then exec "/usr/foo/server/restart\-server"
+ .Ve
+ .SS "\s-1FILE\s0 \s-1SIZE\s0 \s-1TESTING\s0"
+ .IX Subsection "FILE SIZE TESTING"
+@@ -1579,10 +1579,10 @@ To rotate a log file:
+ .Vb 3
+ \& check file myapp.log with path /var/log/myapp.log
+ \&    if size > 50 MB then 
+-\&       exec "/usr/local/bin/rotate /var/log/myapp.log myapp"
++\&       exec "/usr/foo/bin/rotate /var/log/myapp.log myapp"
+ .Ve
+ .PP
+-where /usr/local/bin/rotate may be a simple script, such as:
++where /usr/foo/bin/rotate may be a simple script, such as:
+ .PP
+ .Vb 3
+ \& #/bin/bash
+@@ -1778,7 +1778,7 @@ Monit does not start a possible cracked program or script.
+ Example:
+ .PP
+ .Vb 2
+-\& check file monit.bin with path "/usr/local/bin/monit"
++\& check file monit.bin with path "/usr/foo/bin/monit"
+ \&       if failed permission 0555 then unmonitor
+ .Ve
+ .PP
+@@ -2558,7 +2558,7 @@ control file.
+ An example:
+ .PP
+ .Vb 2
+-\& check program myscript with path "/usr/local/bin/myscript.sh"
++\& check program myscript with path "/usr/foo/bin/myscript.sh"
+ \&       if status != 0 then alert
+ .Ve
+ .PP
+@@ -3028,11 +3028,11 @@ possibly cracked apache binary.
+ .PP
+ .Vb 7
+ \& (1) check process apache 
+-\& (2)    with pidfile "/usr/local/apache/logs/httpd.pid"
++\& (2)    with pidfile "/usr/foo/apache/logs/httpd.pid"
+ \& (3)    ...
+ \& (4)    depends on httpd
+ \& (5)
+-\& (6) check file httpd with path /usr/local/apache/bin/httpd
++\& (6) check file httpd with path /usr/foo/apache/bin/httpd
+ \& (7)    if failed checksum then unmonitor
+ .Ve
+ .PP
+@@ -3506,7 +3506,7 @@ The simplest form is just the check statement. In this example we
+ check to see if the server is running and log a message if not:
+ .PP
+ .Vb 1
+-\& check process resin with pidfile /usr/local/resin/srun.pid
++\& check process resin with pidfile /usr/foo/resin/srun.pid
+ .Ve
+ .PP
+ Checking process without pidfile:
+@@ -3519,9 +3519,9 @@ To have Monit start the server if it's not running, add a start
+ statement:
+ .PP
+ .Vb 3
+-\& check process resin with pidfile /usr/local/resin/srun.pid
+-\&       start program = "/usr/local/resin/bin/srun.sh start"
+-\&       stop program = "/usr/local/resin/bin/srun.sh stop"
++\& check process resin with pidfile /usr/foo/resin/srun.pid
++\&       start program = "/usr/foo/resin/bin/srun.sh start"
++\&       stop program = "/usr/foo/resin/bin/srun.sh stop"
+ .Ve
+ .PP
+ Here's a more advanced example for monitoring an apache
+@@ -3669,7 +3669,7 @@ binary:
+ \&       if failed host www.tildeslash.com port 80 then restart
+ \&       depends on apache_bin
+ \&
+-\& check file apache_bin with path /usr/local/apache/bin/httpd
++\& check file apache_bin with path /usr/foo/apache/bin/httpd
+ \&       if failed checksum then unmonitor
+ .Ve
+ .PP
+@@ -3690,9 +3690,9 @@ server and then an Asterisk server
+ .PP
+ .Vb 12
+ \& check process freeswitch 
+-\&    with pidfile /usr/local/freeswitch/log/freeswitch.pid
+-\&  start program = a\*^XX/usr/local/freeswitch/bin/freeswitch \-nc \-hpa\*^XX
+-\&  stop program = a\*^XX/usr/local/freeswitch/bin/freeswitch \-stopa\*^XX
++\&    with pidfile /usr/foo/freeswitch/log/freeswitch.pid
++\&  start program = a\*^XX/usr/foo/freeswitch/bin/freeswitch \-nc \-hpa\*^XX
++\&  stop program = a\*^XX/usr/foo/freeswitch/bin/freeswitch \-stopa\*^XX
+ \&  if totalmem > 1000.0 MB for 5 cycles then alert
+ \&  if totalmem > 1500.0 MB for 5 cycles then alert
+ \&  if totalmem > 2000.0 MB for 5 cycles then restart
+@@ -3797,7 +3797,7 @@ statement and a file check dependency:
+ \&      depend httpd_bin
+ \&      group apache
+ \&
+-\& check file httpd_bin with path /usr/local/apache/bin/httpd
++\& check file httpd_bin with path /usr/foo/apache/bin/httpd
+ \&       alert security at bar on {checksum, timestamp, 
+ \&                  permission, uid, gid}
+ \&             with mail\-format {subject: Alaaarrm! on $HOST}
+@@ -3878,7 +3878,7 @@ Finally an example with all statements:
+ \&       depends on datafs
+ \&       group server
+ \&
+-\& check file httpd.pid with path /usr/local/apache/logs/httpd.pid
++\& check file httpd.pid with path /usr/foo/apache/logs/httpd.pid
+ \&       group server
+ \&       if timestamp > 7 days then restart
+ \&       every 2 cycles
+@@ -3888,12 +3888,12 @@ Finally an example with all statements:
+ \& check file httpd.conf with path /etc/httpd/httpd.conf
+ \&       group server
+ \&       if timestamp was changed 
+-\&          then exec "/usr/local/apache/bin/apachectl graceful"
++\&          then exec "/usr/foo/apache/bin/apachectl graceful"
+ \&       every 2 cycles
+ \&       alert bofh at bar with mail\-format {from: monit at foo.bar.no}
+ \&       depends on datafs
+ \&
+-\& check file httpd_bin with path /usr/local/apache/bin/httpd
++\& check file httpd_bin with path /usr/foo/apache/bin/httpd
+ \&       group server
+ \&       if failed checksum and expect the sum
+ \&          8f7f419955cefa0b33a2ba316cba3659 then unmonitor
+diff --git a/monitrc b/monitrc
+index 82d1648..77ae611 100644
+--- a/monitrc
++++ b/monitrc
+@@ -144,7 +144,7 @@ set httpd port 2812 and
+ ## be grouped using the GROUP option. More than one group can be specified by
+ ## repeating the 'group name' statement.
+ #    
+-#  check file apache_bin with path /usr/local/apache/bin/httpd
++#  check file apache_bin with path /usr/foo/apache/bin/httpd
+ #    if failed checksum and 
+ #       expect the sum 8f7f419955cefa0b33a2ba316cba3659 then unmonitor
+ #    if failed permission 755 then unmonitor
+@@ -164,7 +164,7 @@ set httpd port 2812 and
+ ## statement. This service depends on another service (apache_bin) which
+ ## is defined above.
+ #    
+-#  check process apache with pidfile /usr/local/apache/logs/httpd.pid
++#  check process apache with pidfile /usr/foo/apache/logs/httpd.pid
+ #    start program = "/etc/init.d/httpd start" with timeout 60 seconds
+ #    stop program  = "/etc/init.d/httpd stop"
+ #    if cpu > 60% for 2 cycles then alert
+diff --git a/src/file.c b/src/file.c
+index 82bffb6..42e4d6d 100644
+--- a/src/file.c
++++ b/src/file.c
+@@ -161,8 +161,8 @@ time_t file_getTimestamp(char *object, mode_t type) {
+ 
+ /**
+  * Search the system for the monit control file. Try first ~/.monitrc,
+- * if that fails try /etc/monitrc, then SYSCONFDIR/monitrc (default:
+- * /usr/local/etc/monitrc) and finally ./monitrc.
++ * if that fails try /etc/monitrc, then SYSCONFDIR/monitrc
++ * and finally ./monitrc.
+  * Exit the application if the control file was not found.
+  * @return The location of monits control file (monitrc)
+  */
+@@ -182,15 +182,11 @@ char *file_findControlFile() {
+   if(file_exist(rcfile)) {
+     return rcfile;
+   }
+-  snprintf(rcfile, STRLEN, "/usr/local/etc/%s", MONITRC);
+-  if(file_exist(rcfile)) {
+-    return rcfile;
+-  }
+   if(file_exist(MONITRC)) {
+     snprintf(rcfile, STRLEN, "%s/%s", Run.Env.cwd, MONITRC);
+     return rcfile;
+   }
+-  LogError("%s: Cannot find the control file at ~/.%s, /etc/%s, %s/%s, /usr/local/etc/%s or at ./%s \n",
++  LogError("%s: Cannot find the control file at ~/.%s, /etc/%s, %s/%s or at ./%s \n",
+       prog, MONITRC, MONITRC, SYSCONFDIR, MONITRC, MONITRC, MONITRC);
+   exit(1);
+   
+diff --git a/src/file.h b/src/file.h
+index 453b8b0..31278f7 100644
+--- a/src/file.h
++++ b/src/file.h
+@@ -58,9 +58,8 @@ time_t file_getTimestamp(char *object, mode_t type);
+ 
+ /**
+  * Search the system for the monit control file. Try first ~/.monitrc,
+- * if that fails try /etc/monitrc, then /usr/local/etc/monitrc and
+- * finally ./monitrc.  Exit the application if the control file was
+- * not found.
++ * if that fails try /etc/monitrc and finally ./monitrc.  Exit the
++ * application if the control file was not found.
+  * @return The location of monits control file (monitrc)
+  */
+ char *file_findControlFile();
+-- 
+1.7.10.3
+

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list