diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/Makefile.in monit/Makefile.in
--- monit.orig/Makefile.in Wed Aug 14 14:21:36 2002
+++ monit/Makefile.in Sun Aug 25 01:23:17 2002
@@ -31,7 +31,7 @@
# Programs (with common options):
SHELL = /bin/sh
-RM = /bin/rm -f
+RM = /bin/rm -fr
# Install modes
MODE_PROGS = 555
@@ -59,7 +59,7 @@
INCDIR = -I. -I./protocols -I./http
LIB = @LEXLIB@ @LIBS@
-DEFINES = address@hidden@ @EXTRA_DEFINES@
+DEFINES = address@hidden@
# ------------------------------------------------------------------- #
@@ -119,10 +119,11 @@
# remove configure files
distclean:: clean
- $(RM) config.cache config.log config.status Makefile
+ $(RM) config.cache config.log config.status Makefile config.h \
+ autom4te.cache
devclean:: clean distclean
- $(RM) configure
+ $(RM) configure config.h.in
install:: $(PROG)
$(INSTALL_DIR) $(DESTDIR)$(BINDIR) $(check-exit)
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/autogen.sh monit/autogen.sh
--- monit.orig/autogen.sh Wed Dec 31 16:00:00 1969
+++ monit/autogen.sh Sat Aug 17 15:48:41 2002
@@ -0,0 +1,52 @@
+#! /bin/sh
+# autogen.sh (borrowed from Gnet autogen.sh)
+#
+# This script is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+srcdir=$(dirname $0)
+test -z "$srcdir" && srcdir=.
+
+(test -f $srcdir/configure.ac) ||
+{
+ echo
+ echo -n "Error: directory "\`$srcdir\'" does not look like the"
+ echo " top level directory"
+ exit 1
+}
+
+DIE=0
+
+(autoconf --version) < /dev/null > /dev/null 2>&1 ||
+{
+ echo
+ echo -n "Error: \`autoconf\' must be installed"
+ DIE=1
+}
+
+if test "$DIE" -eq 1; then
+ exit 1
+fi
+
+if test -z "$*"; then
+ echo "Warning: I am going to run \`configure\' with no arguments."
+ echo "If you with to pass any to it, please specify them on the"
+ echo \`$0\'" command line."
+ echo
+fi
+
+echo "Running autoheader"
+autoheader
+echo "Running autoconf"
+autoconf
+
+conf_flags="--enable-compile-warnings"
+if test x$NOCONFIGURE = x; then
+ echo Running $srcdir/configure $conf_flags "$@" ...
+ $srcdir/configure $conf_flags "$@" \
+ && echo Now type \`make\' to compile || exit 1
+else
+ echo Skipping configure process
+fi
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/configure.ac monit/configure.ac
--- monit.orig/configure.ac Wed Dec 31 16:00:00 1969
+++ monit/configure.ac Sun Aug 25 01:24:15 2002
@@ -0,0 +1,117 @@
+# Process this file with autoconf to produce a configure script.
+#
+# $Id: $
+
+# autoconf requirement
+AC_PREREQ([2.53])
+
+# Init autoconf and automake
+AC_INIT([monit], [2.5.1], address@hidden)
+
+# Package info
+AC_REVISION([$Revision: $])
+AC_CONFIG_SRCDIR([monitor.c])
+
+# Check for programs
+AC_PROG_CC
+AC_PROG_GCC_TRADITIONAL
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AC_PROG_LEX
+ if test "$LEX" != flex; then
+ AC_MSG_ERROR([monit requires flex, not lex])
+ fi
+AC_PROG_YACC
+
+# Check for libraries
+AC_CHECK_LIB([socket], [socket])
+AC_CHECK_LIB([inet], [socket])
+AC_CHECK_LIB([nsl], [inet_addr])
+AC_CHECK_LIB([resolv], [inet_aton])
+# Wacky pthread madness
+pthread_libs=""
+AC_CHECK_LIB([pthread],
+ [pthread_create],
+ [pthread_libs="-lpthread"])
+AC_CHECK_LIB([c_r],
+ [pthread_create],
+ [pthread_libs="-lc_r"])
+if test "$pthread_libs"
+then
+ LIBS="$pthread_libs $LIBS"
+fi
+
+# Checks for header files.
+AC_HEADER_STAT
+AC_HEADER_STDC
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h getopt.h limits.h netdb.h netinet/in.h strings.h stropts.h sys/filio.h sys/ioctl.h syslog.h])
+
+# Check for types.
+AC_TYPE_MODE_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_PID_T
+AC_TYPE_SIGNAL
+
+# Check for structures.
+AC_STRUCT_TM
+AC_CHECK_MEMBERS([struct tm.tm_gmtoff])
+
+# Compiler characteristics
+AC_C_CONST
+
+# If the compiler is gcc, turn on warnings
+if test "x$GCC" = "xyes"; then
+ case " $CFLAGS " in
+ *[\ \ ]-Wall[\ \ ]*)
+ ;;
+ *)
+ CFLAGS="$CFLAGS -Wall"
+ ;;
+ esac
+fi
+
+# Checks for library functions.
+AC_FUNC_ERROR_AT_LINE
+AC_FUNC_FORK
+AC_FUNC_MALLOC
+AC_FUNC_STAT
+AC_FUNC_STRFTIME
+
+# The following is taken from fetchmail configure.in:
+# Find the right directory to put the root-mode PID file in
+AC_MSG_CHECKING([pid file location])
+if test -d "/var/run"
+then
+ AC_DEFINE([PIDDIR], "/var/run",
+ [Define to the pid storage directory.])
+ AC_MSG_RESULT([/var/run])
+elif test -d "/etc"
+then
+ AC_DEFINE([PIDDIR], "/etc",
+ [Define to the pid storage directory.])
+ AC_MSG_RESULT([/etc])
+fi
+
+# Backward compatibility until we get ride of arch settings
+if test `uname` = "SunOS"
+then
+ ARCH="SOLARIS"
+elif test `uname` = "Linux"
+then
+ ARCH="LINUX"
+elif test `uname` = "FreeBSD"
+then
+ ARCH="FREEBSD"
+else
+ AC_MSG_WARN([Architecture not supported: `uname`. Trying Linux compile.])
+ ARCH="LINUX"
+fi
+AC_SUBST(ARCH)
+AC_MSG_RESULT([Architecture is ${ARCH}])
+
+# Outputs
+AC_CONFIG_HEADER([config.h])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/configure.in monit/configure.in
--- monit.orig/configure.in Wed Aug 14 14:21:36 2002
+++ monit/configure.in Wed Dec 31 16:00:00 1969
@@ -1,104 +0,0 @@
-dnl Autoconfigure input file for monit
-dnl Jan-Henrik Haukeland,
-dnl
-dnl Process this file with autoconf to produce a configure script.
-dnl
-
-AC_INIT(monitor.c)
-
-dnl Check for architecture.
-if test `uname` = "SunOS"
-then
- ARCH="SOLARIS"
-elif test `uname` = "Linux"
-then
- ARCH="LINUX"
-elif test `uname` = "FreeBSD"
-then
- ARCH="FREEBSD"
-else
- AC_MSG_WARN(Architecture not supported: `uname`. Trying Linux compile)
- ARCH="LINUX"
-fi
-AC_SUBST(ARCH)
-AC_MSG_RESULT([Architure is ${ARCH}])
-
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_INSTALL
-AC_PROG_CPP
-AC_PROG_LEX
-if test ${LEX} != "flex"
-then
- AC_MSG_ERROR(monit needs flex to compile correctly)
-fi
-AC_PROG_YACC
-
-dnl Checks for libraries.
-AC_CHECK_FUNC(socket,
- AC_MSG_RESULT(using libc's socket),
- AC_CHECK_LIB(socket,socket)
- AC_CHECK_LIB(inet,socket))
-
-AC_CHECK_FUNC(inet_addr,
- AC_MSG_RESULT(using libc's inet_addr),
- AC_CHECK_LIB(nsl,inet_addr))
-
-AC_CHECK_FUNC(inet_aton,
- AC_MSG_RESULT(using libc's inet_aton),
- AC_CHECK_LIB(resolv,inet_aton))
-
-AC_CHECK_LIB(pthread, pthread_create,,
- AC_CHECK_LIB(pthreads, pthread_create,,))
-
-if test "$ARCH" = "FREEBSD"
-then
- LIBS="-pthread $LIBS"
-fi
-
-
-dnl Checks for header files.
-AC_HEADER_STDC
-AC_TYPE_SIZE_T
-AC_TYPE_PID_T
-AC_TYPE_SIGNAL
-AC_CHECK_HEADERS(pthread.h unistd.h fcntl.h sys/fcntl.h memory.h sys/socket.h sys/wait.h)
-
-dnl Checks for tm_gmtoff in tm struct in time.h
-EXTRA_DEFINES=""
-AC_CACHE_CHECK([for tm_gmtoff in time.h],
- have_tm_gmtoff, [
- AC_EGREP_HEADER(tm_gmtoff, time.h, [have_tm_gmtoff=yes],
- [have_tm_gmtoff=no])
- ])
-if test $have_tm_gmtoff = yes; then
- EXTRA_DEFINES="-DHAVE_TM_GMTOFF"
-fi
-
-dnl Checks for library functions.
-AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(strstr gethostname gethostbyname connect htons shutdown)
-
-
-dnl The following is taken from fetchmail configure.in:
-dnl Find the right directory to put the root-mode PID file in
-for PID_DIR in "/var/run" "/etc"
-do
- if test -d $PID_DIR
- then
- break;
- fi
-done
-AC_MSG_RESULT([==> root-mode pid file will go in $PID_DIR])
-AC_SUBST(PID_DIR)
-
-dnl (A shaky) Test for GNU make
-GM=`( make -v || make --version ) 2>/dev/null | egrep -i gnu`
-if test "$GM" = ""
-then
- AC_MSG_WARN([==>You will need GNU Make to compile monit])
-fi
-
-AC_SUBST(EXTRA_DEFINES)
-
-AC_OUTPUT(Makefile monitor.h)
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/daemonize.c monit/daemonize.c
--- monit.orig/daemonize.c Thu Aug 8 17:03:11 2002
+++ monit/daemonize.c Sat Aug 24 23:26:50 2002
@@ -17,6 +17,7 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
@@ -24,9 +25,13 @@
#include
#include
#include
-#include
+#if HAVE_SYS_STAT_H
+# include
+#endif
#include
-#include
+#if HAVE_FCNTL_H
+# include
+#endif
#include "monitor.h"
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/env.c monit/env.c
--- monit.orig/env.c Thu Aug 8 17:03:11 2002
+++ monit/env.c Sat Aug 24 23:28:06 2002
@@ -17,6 +17,7 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
@@ -25,9 +26,13 @@
#include
#include
#include
-#include
+#if HAVE_SYS_STAT_H
+# include
+#endif
#include
-#include
+#if HAVE_FCNTL_H
+# include
+#endif
#include "net.h"
#include "monitor.h"
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/files.c monit/files.c
--- monit.orig/files.c Thu Aug 8 17:03:11 2002
+++ monit/files.c Sat Aug 24 23:48:22 2002
@@ -17,16 +17,19 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
-#ifdef SOLARIS
-#include
+#if HAVE_STRINGS_H
+# include
#endif
#include
#include
#include
#include
-#include
+#if HAVE_SYS_STAT_H
+# include
+#endif
#include
#include "monitor.h"
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/http/cervlet.c monit/http/cervlet.c
--- monit.orig/http/cervlet.c Thu Aug 8 17:03:12 2002
+++ monit/http/cervlet.c Sat Aug 24 23:29:05 2002
@@ -17,6 +17,7 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
@@ -24,7 +25,9 @@
#include
#include
#include
-#include
+#if HAVE_SYS_STAT_H
+# include
+#endif
#include
#include
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/http/engine.c monit/http/engine.c
--- monit.orig/http/engine.c Thu Aug 8 17:03:12 2002
+++ monit/http/engine.c Sat Aug 24 23:44:35 2002
@@ -17,6 +17,7 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
@@ -26,9 +27,15 @@
#include
#include
#include
-#include
-#include
-#include
+#if HAVE_NETINET_IN_H
+# include
+#endif
+#if HAVE_ARPA_INET_H
+# include
+#endif
+#if HAVE_NETDB_H
+# include
+#endif
#include "http_utils.h"
#include "engine.h"
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/http/processor.c monit/http/processor.c
--- monit.orig/http/processor.c Thu Aug 8 17:03:12 2002
+++ monit/http/processor.c Sat Aug 24 23:39:43 2002
@@ -17,6 +17,7 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
@@ -28,7 +29,9 @@
#include
#include
#include
-#include
+#if HAVE_LIMITS_H
+# include
+#endif
#include "processor.h"
#include "base64.h"
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/l.l monit/l.l
--- monit.orig/l.l Thu Aug 8 17:03:11 2002
+++ monit/l.l Sat Aug 24 23:49:07 2002
@@ -32,9 +32,11 @@
* $Id: l.l,v 1.6 2002/08/09 00:03:11 hauk Exp $
*/
+#include
+
#include
-#ifdef SOLARIS
-#include
+#if HAVE_STRINGS_H
+# include
#endif
#include "monitor.h"
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/log.c monit/log.c
--- monit.orig/log.c Thu Aug 8 17:03:11 2002
+++ monit/log.c Sat Aug 24 23:56:48 2002
@@ -17,19 +17,24 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
-#ifdef SOLARIS
-#include
+#if HAVE_STRINGS_H
+# include
#endif
#include
#include
#include
-#include
+#if HAVE_SYSLOG_H
+# include
+#endif
#include
#include
-#include
+#if HAVE_SYS_STAT_H
+# include
+#endif
#include "monitor.h"
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/md5.h monit/md5.h
--- monit.orig/md5.h Thu Jun 27 10:55:00 2002
+++ monit/md5.h Sat Aug 24 23:26:14 2002
@@ -21,6 +21,8 @@
#ifndef _MD5_H
#define _MD5_H 1
+#include
+
#include
#if defined HAVE_LIMITS_H || _LIBC
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/monit_http.c monit/monit_http.c
--- monit.orig/monit_http.c Thu Aug 8 17:03:11 2002
+++ monit/monit_http.c Sat Aug 24 23:30:28 2002
@@ -17,10 +17,13 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
-#include
+#if HAVE_SYS_WAIT_H
+# include
+#endif
#include
#include
#include
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/monitor.c monit/monitor.c
--- monit.orig/monitor.c Thu Aug 8 17:03:11 2002
+++ monit/monitor.c Sun Aug 25 00:44:10 2002
@@ -17,17 +17,20 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
-#ifdef LINUX
-#include
+#if HAVE_GETOPT_H
+# include
#endif
#include
#include
#include
#include
-#include
+#if HAVE_SYS_STAT_H
+# include
+#endif
#include
#include "monitor.h"
@@ -52,9 +55,9 @@
static void do_init(); /* Initialize this application */
static void do_reinit(); /* Re-initialize the runtime application */
static void do_action(char **); /* Dispatch to the submitted action */
-static void do_destroy(int); /* Finalize this application */
+static RETSIGTYPE do_destroy(int); /* Finalize this application */
static void do_default(); /* Do default action */
-static void do_wakeup(int); /* Signalhandler for a daemon wakeup call */
+static RETSIGTYPE do_wakeup(int); /* Signalhandler for a daemon wakeup call */
static int do_wakeupcall(); /* Wakeup a sleeping monit daemon */
static void do_wait(); /* Wait for 10 seconds */
static void handle_options(int, char **); /* Handle program options */
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/monitor.h monit/monitor.h
--- monit.orig/monitor.h Wed Dec 31 16:00:00 1969
+++ monit/monitor.h Sat Aug 24 22:23:51 2002
@@ -0,0 +1,277 @@
+/*
+ * Copyright (C), 2000-2002 by Contributors to the monit codebase.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef MONITOR_H
+#define MONITOR_H
+
+#include "config.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#define VERSION PACKAGE_VERSION
+#define MONITRC "monitrc"
+#define TIMEFORMAT "%Z %b %e %T"
+#define STRERROR strerror(errno)
+#define STRLEN 256
+#define ARGMAX 10
+/** Set log file mode: "-rw-rw-r--" */
+#define LOGMASK 0112
+/** Set pid file mode: "-rw-r--r--" */
+#define PIDMASK 0122
+#define MYPIDDIR PIDDIR
+#define MYPIDFILE "monit.pid"
+
+#define LOCALHOST "localhost"
+#define SMTP_PORT 25
+
+#define SMTP_TIMEOUT 30
+#define CHECK_TIMEOUT 30
+
+#define START_HTTP 1
+#define STOP_HTTP 2
+
+#define TRUE 1
+#define FALSE 0
+
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#define is(a,b) ((a&&b)?!strcasecmp(a, b):0)
+
+/** Replace the standard signal function with a more reliable using sigaction.*/
+typedef void Sigfunc(int);
+Sigfunc *signal(int signo, Sigfunc * func);
+#if defined(SIG_IGN) && !defined(SIG_ERR)
+#define SIG_ERR ((Sigfunc *)-1)
+#endif
+
+/** ------------------------------------------------- Synchronization macros */
+
+#define LOCK(mutex) do { pthread_mutex_t *_yymutex = &(mutex); \
+ pthread_mutex_lock(_yymutex);
+#define END_LOCK pthread_mutex_unlock(_yymutex); } while (0)
+
+
+/** ----------------------------------------------- Object Constructor macro */
+
+#define NEW(p) (xcalloc(1, (long)sizeof *(p)))
+
+
+/** Defines data for application runtime */
+struct myrun {
+ char *controlfile; /**< The file to read configuration from */
+ char *logfile; /**< The file to write logdata into */
+ char *localhostname; /**< The host name for localhost */
+ char *mailserver; /**< Mailserver used for alert notification */
+ char *pidfile; /**< This programs pidfile */
+ int debug; /**< Write debug information - TRUE or FALSE */
+ int use_syslog; /**< If TRUE write log to syslog */
+ int dolog; /**< TRUE if program should log actions, otherwise FALSE */
+ int isdaemon; /**< TRUE if program should run as a daemon */
+ int polltime; /**< In deamon mode, the sleeptime (sec) between run */
+ int dohttpd; /**< TRUE if monit HTTP server should run */
+ int httpdport; /**< The monit http server's portnumber */
+ int validate; /** TRUE - use validate behaviour on startup */
+ int Init; /** TRUE - don't background to run from init */
+ char *bind_addr; /**< The address monit http will bind to */
+ mode_t umask; /**< The initial umask monit was started with */
+
+ /** An object holding program relevant "environment" data, see; env.c */
+ struct myenvironment {
+ char *user; /**< The the effective user running this program */
+ char *home; /**< Users home directory */
+ char *cwd; /**< Current working directory */
+ } Env;
+ /** An object holding Basic Authentication information */
+ struct myautentication {
+ int defined; /**< TRUE if basic authentication can be used */
+ char *uname; /**< User allowed to connect to monit httpd */
+ char *passwd; /**< The users password in clear text */
+ } Auth;
+ /** User selected standard mail format */
+ struct myformat {
+ char *from; /**< The standard mail from address */
+ char *subject; /**< The standard mail subject */
+ char *message; /**< The standard mail message */
+ } MailFormat;
+
+ pthread_mutex_t mutex; /**< Mutex used for process data synchronization */
+
+};
+
+/** Defines a port object */
+typedef struct myport {
+ volatile int socket; /**< Socket used for connection */
+ int type; /**< Socket type used for connection (UDP/TCP) */
+ int family; /**< Socket family used for connection (INET/UNIX) */
+ char *hostname; /**< Hostname to check */
+ int port; /**< Portnumber */
+ char *request; /**< Specific protocol request */
+ char *pathname; /**< Pathname, in case of an UNIX socket */
+ char *address; /**< Human readable destination of the socket */
+
+ /**< Object used for testing a port's service */
+ struct myprotocol {
+ const char *name; /**< Protocol name */
+ int(*check)(struct myport *); /**< Service verification function */
+ } *protocol;
+
+ /** For internal use */
+ struct myport *next; /**< next port in chain */
+} *Port_T;
+
+/** Defines a protocol object with protocol functions */
+typedef struct myprotocol *Protocol_T;
+
+/** Defines a checksum object */
+typedef struct mychecksum {
+ char *file; /**< A filename to compute a md5 checksum for */
+ char *md5; /**< A md5 checksum computed for the file */
+
+ /** For internal use */
+ struct mychecksum *next; /**< next checksum in chain */
+} *Checksum_T;
+
+/** Defines a mailinglist object */
+typedef struct mymail {
+ char *to; /**< Mail address for alert notification */
+ char *from; /**< The mail from address */
+ char *subject; /**< The mail subject */
+ char *message; /**< The mail message */
+ int alert_on_timeout; /**< If TRUE, alert user when process timeout */
+ int alert_on_restart; /**< If TRUE, alert user when the process restarts */
+ int alert_on_checksum; /**< If TRUE, alert user when the checksum fail */
+
+ /** For internal use */
+ struct mymail *next; /**< next recipient in chain */
+} *Mail_T;
+
+/** Defines process data */
+typedef struct myprocess {
+ char *name; /**< Process descriptive name */
+ char *pidfile; /**< The pid file of the process */
+ char *group; /**< Process group name */
+ char *start; /**< The program to start the process */
+ char *stop; /**< The program to stop the process */
+ int do_validate; /**< validation flag, if FALSE, no validation is done */
+ int ncycle; /**< The number of the current cycle */
+ int nstart; /**< The number of current starts with this process */
+ int to_start; /**< Timeout start ceiling */
+ int to_cycle; /**< Timeout cycle ceiling */
+ int every; /**< Check this program at given cycles */
+ int nevery; /**< Counter for every. When nevery == every, check */
+ int has_checksum_error; /**< TRUE if the process has a checksum error */
+ int def_every; /**< TRUE if every is defined for the process */
+ int def_timeout; /**< TRUE if timeout is defined for the process */
+ int def_checksum; /**< TRUE if checksum is defined for the process */
+
+ Port_T portlist; /**< Portnumbers the process listens on */
+ Checksum_T checksumlist; /**< A list of file associated checksums */
+ Mail_T maillist; /**< Alert notification mailinglist */
+
+ /** For internal use */
+ struct myprocess *next; /**< next process in chain */
+} *Process_T;
+
+
+/* ------ Global variables ------------------------------------------------- */
+Process_T processlist; /**< The process list (created in p.y) */
+char *prog; /**< The Name of this Program */
+struct myrun Run; /**< Struct holding runtime constants */
+int have_tty; /**< Do we have a valid tty */
+char *mygroup; /**< Group Name of the Process */
+
+
+/* Public prototypes */
+void error(const char *, ...);
+char *trim(char *);
+char *ltrim(char *);
+char *rtrim(char *);
+char *trim_quotes(char *);
+void chomp(char *);
+char *fstr(char *);
+int exist_process(char *);
+Process_T get_process(char *);
+void printrunlist();
+void printprocess(Process_T);
+void printprocesslist();
+pid_t get_pid(char *);
+int is_process_running(Process_T);
+int is_strdefined(char *);
+int isreg_file(char *);
+char *stripfilename(char*);
+int exist_file(char *);
+time_t file_changedtime(char *file);
+char *get_ctime();
+char *get_RFC1123date(long *);
+char *get_uptime(long delta);
+char *get_process_uptime(char *);
+char *get_md5sum(char *);
+int check_md5(char *, char *);
+char *url_encode(char *uri);
+char *get_basic_authentication_header();
+int set_md5sum(char **, char *);
+int parse(char *);
+void start();
+void start_group(char *);
+void start_process(Process_T);
+void dstart_process(char *);
+void stop();
+void stop_group(char *);
+void stop_process(Process_T);
+void dstop_process(char *);
+void spawn(char *);
+void status();
+void status_group(char *);
+int log_init() ;
+void log(const char *format, ...) ;
+void log_close();
+int get_log_fd();
+void validate() ;
+void daemonize() ;
+void gc();
+void gc_process(Process_T);
+void init_files();
+void re_init_files();
+void set_file_timestamp();
+void finalize_files();
+char *find_rcfile();
+int create_pidfile(char *);
+int is_rcfile_changed();
+int kill_daemon();
+int exist_daemon();
+void sendmail(Mail_T);
+int sock_msg(int sock, char *, ...);
+void init_env();
+void *xmalloc (int);
+void *xcalloc(long, long);
+void *xrealloc (void *, int);
+char *xstrdup(const char *);
+void smtp_alert_timeout(Process_T);
+void smtp_alert_restart(Process_T);
+void smtp_alert_checksum(Process_T);
+void set_alarm_handler(void *);
+void monit_http(int);
+int check_httpd();
+int can_http();
+
+#endif
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/monitor.h.in monit/monitor.h.in
--- monit.orig/monitor.h.in Thu Aug 8 17:19:05 2002
+++ monit/monitor.h.in Wed Dec 31 16:00:00 1969
@@ -1,275 +0,0 @@
-/*
- * Copyright (C), 2000-2002 by Contributors to the monit codebase.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-
-#ifndef MONITOR_H
-#define MONITOR_H
-
-#include
-#include
-#include
-#include
-#include
-
-#define VERSION "2.5.1"
-#define MONITRC "monitrc"
-#define TIMEFORMAT "%Z %b %e %T"
-#define STRERROR strerror(errno)
-#define STRLEN 256
-#define ARGMAX 10
-/** Set log file mode: "-rw-rw-r--" */
-#define LOGMASK 0112
-/** Set pid file mode: "-rw-r--r--" */
-#define PIDMASK 0122
-#define MYPIDDIR "@PID_DIR@"
-#define MYPIDFILE "monit.pid"
-
-#define LOCALHOST "localhost"
-#define SMTP_PORT 25
-
-#define SMTP_TIMEOUT 30
-#define CHECK_TIMEOUT 30
-
-#define START_HTTP 1
-#define STOP_HTTP 2
-
-#define TRUE 1
-#define FALSE 0
-
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-#define is(a,b) ((a&&b)?!strcasecmp(a, b):0)
-
-/** Replace the standard signal function with a more reliable using sigaction.*/
-typedef void Sigfunc(int);
-Sigfunc *signal(int signo, Sigfunc * func);
-#if defined(SIG_IGN) && !defined(SIG_ERR)
-#define SIG_ERR ((Sigfunc *)-1)
-#endif
-
-/** ------------------------------------------------- Synchronization macros */
-
-#define LOCK(mutex) do { pthread_mutex_t *_yymutex = &(mutex); \
- pthread_mutex_lock(_yymutex);
-#define END_LOCK pthread_mutex_unlock(_yymutex); } while (0)
-
-
-/** ----------------------------------------------- Object Constructor macro */
-
-#define NEW(p) (xcalloc(1, (long)sizeof *(p)))
-
-
-/** Defines data for application runtime */
-struct myrun {
- char *controlfile; /**< The file to read configuration from */
- char *logfile; /**< The file to write logdata into */
- char *localhostname; /**< The host name for localhost */
- char *mailserver; /**< Mailserver used for alert notification */
- char *pidfile; /**< This programs pidfile */
- int debug; /**< Write debug information - TRUE or FALSE */
- int use_syslog; /**< If TRUE write log to syslog */
- int dolog; /**< TRUE if program should log actions, otherwise FALSE */
- int isdaemon; /**< TRUE if program should run as a daemon */
- int polltime; /**< In deamon mode, the sleeptime (sec) between run */
- int dohttpd; /**< TRUE if monit HTTP server should run */
- int httpdport; /**< The monit http server's portnumber */
- int validate; /** TRUE - use validate behaviour on startup */
- int Init; /** TRUE - don't background to run from init */
- char *bind_addr; /**< The address monit http will bind to */
- mode_t umask; /**< The initial umask monit was started with */
-
- /** An object holding program relevant "environment" data, see; env.c */
- struct myenvironment {
- char *user; /**< The the effective user running this program */
- char *home; /**< Users home directory */
- char *cwd; /**< Current working directory */
- } Env;
- /** An object holding Basic Authentication information */
- struct myautentication {
- int defined; /**< TRUE if basic authentication can be used */
- char *uname; /**< User allowed to connect to monit httpd */
- char *passwd; /**< The users password in clear text */
- } Auth;
- /** User selected standard mail format */
- struct myformat {
- char *from; /**< The standard mail from address */
- char *subject; /**< The standard mail subject */
- char *message; /**< The standard mail message */
- } MailFormat;
-
- pthread_mutex_t mutex; /**< Mutex used for process data synchronization */
-
-};
-
-/** Defines a port object */
-typedef struct myport {
- volatile int socket; /**< Socket used for connection */
- int type; /**< Socket type used for connection (UDP/TCP) */
- int family; /**< Socket family used for connection (INET/UNIX) */
- char *hostname; /**< Hostname to check */
- int port; /**< Portnumber */
- char *request; /**< Specific protocol request */
- char *pathname; /**< Pathname, in case of an UNIX socket */
- char *address; /**< Human readable destination of the socket */
-
- /**< Object used for testing a port's service */
- struct myprotocol {
- const char *name; /**< Protocol name */
- int(*check)(struct myport *); /**< Service verification function */
- } *protocol;
-
- /** For internal use */
- struct myport *next; /**< next port in chain */
-} *Port_T;
-
-/** Defines a protocol object with protocol functions */
-typedef struct myprotocol *Protocol_T;
-
-/** Defines a checksum object */
-typedef struct mychecksum {
- char *file; /**< A filename to compute a md5 checksum for */
- char *md5; /**< A md5 checksum computed for the file */
-
- /** For internal use */
- struct mychecksum *next; /**< next checksum in chain */
-} *Checksum_T;
-
-/** Defines a mailinglist object */
-typedef struct mymail {
- char *to; /**< Mail address for alert notification */
- char *from; /**< The mail from address */
- char *subject; /**< The mail subject */
- char *message; /**< The mail message */
- int alert_on_timeout; /**< If TRUE, alert user when process timeout */
- int alert_on_restart; /**< If TRUE, alert user when the process restarts */
- int alert_on_checksum; /**< If TRUE, alert user when the checksum fail */
-
- /** For internal use */
- struct mymail *next; /**< next recipient in chain */
-} *Mail_T;
-
-/** Defines process data */
-typedef struct myprocess {
- char *name; /**< Process descriptive name */
- char *pidfile; /**< The pid file of the process */
- char *group; /**< Process group name */
- char *start; /**< The program to start the process */
- char *stop; /**< The program to stop the process */
- int do_validate; /**< validation flag, if FALSE, no validation is done */
- int ncycle; /**< The number of the current cycle */
- int nstart; /**< The number of current starts with this process */
- int to_start; /**< Timeout start ceiling */
- int to_cycle; /**< Timeout cycle ceiling */
- int every; /**< Check this program at given cycles */
- int nevery; /**< Counter for every. When nevery == every, check */
- int has_checksum_error; /**< TRUE if the process has a checksum error */
- int def_every; /**< TRUE if every is defined for the process */
- int def_timeout; /**< TRUE if timeout is defined for the process */
- int def_checksum; /**< TRUE if checksum is defined for the process */
-
- Port_T portlist; /**< Portnumbers the process listens on */
- Checksum_T checksumlist; /**< A list of file associated checksums */
- Mail_T maillist; /**< Alert notification mailinglist */
-
- /** For internal use */
- struct myprocess *next; /**< next process in chain */
-} *Process_T;
-
-
-/* ------ Global variables ------------------------------------------------- */
-Process_T processlist; /**< The process list (created in p.y) */
-char *prog; /**< The Name of this Program */
-struct myrun Run; /**< Struct holding runtime constants */
-int have_tty; /**< Do we have a valid tty */
-char *mygroup; /**< Group Name of the Process */
-
-
-/* Public prototypes */
-void error(const char *, ...);
-char *trim(char *);
-char *ltrim(char *);
-char *rtrim(char *);
-char *trim_quotes(char *);
-void chomp(char *);
-char *fstr(char *);
-int exist_process(char *);
-Process_T get_process(char *);
-void printrunlist();
-void printprocess(Process_T);
-void printprocesslist();
-pid_t get_pid(char *);
-int is_process_running(Process_T);
-int is_strdefined(char *);
-int isreg_file(char *);
-char *stripfilename(char*);
-int exist_file(char *);
-time_t file_changedtime(char *file);
-char *get_ctime();
-char *get_RFC1123date(long *);
-char *get_uptime(long delta);
-char *get_process_uptime(char *);
-char *get_md5sum(char *);
-int check_md5(char *, char *);
-char *url_encode(char *uri);
-char *get_basic_authentication_header();
-int set_md5sum(char **, char *);
-int parse(char *);
-void start();
-void start_group(char *);
-void start_process(Process_T);
-void dstart_process(char *);
-void stop();
-void stop_group(char *);
-void stop_process(Process_T);
-void dstop_process(char *);
-void spawn(char *);
-void status();
-void status_group(char *);
-int log_init() ;
-void log(const char *format, ...) ;
-void log_close();
-int get_log_fd();
-void validate() ;
-void daemonize() ;
-void gc();
-void gc_process(Process_T);
-void init_files();
-void re_init_files();
-void set_file_timestamp();
-void finalize_files();
-char *find_rcfile();
-int create_pidfile(char *);
-int is_rcfile_changed();
-int kill_daemon();
-int exist_daemon();
-void sendmail(Mail_T);
-int sock_msg(int sock, char *, ...);
-void init_env();
-void *xmalloc (int);
-void *xcalloc(long, long);
-void *xrealloc (void *, int);
-char *xstrdup(const char *);
-void smtp_alert_timeout(Process_T);
-void smtp_alert_restart(Process_T);
-void smtp_alert_checksum(Process_T);
-void set_alarm_handler(void *);
-void monit_http(int);
-int check_httpd();
-int can_http();
-
-#endif
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/net.c monit/net.c
--- monit.orig/net.c Mon Aug 12 17:41:45 2002
+++ monit/net.c Sun Aug 25 00:42:15 2002
@@ -17,27 +17,40 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
#include
#include
#include
-#ifdef SOLARIS
-#include
-#include
-#endif
-#include
-#include
-#include
-#include
+#if HAVE_SYS_FILIO_H
+# include
+#endif
+#if HAVE_STROPTS_H
+# include
+#endif
+#if HAVE_FCNTL_H
+# include
+#endif
+#if HAVE_SYS_IOCTL_H
+# include
+#endif
+#if HAVE_NETINET_IN_H
+# include
+#endif
+#if HAVE_NETDB_H
+# include
+#endif
#include
#include
#include
#include
#include
#include
-#include
+#if HAVE_ARPA_INET_H
+# include
+#endif
#include
#include "monitor.h"
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/p.y monit/p.y
--- monit.orig/p.y Thu Aug 8 17:03:11 2002
+++ monit/p.y Sat Aug 24 23:50:42 2002
@@ -33,8 +33,8 @@
#include
#include
-#ifdef SOLARIS
-#include
+#if HAVE_STRINGS_H
+# include
#endif
#include
#include
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/protocols/http.c monit/protocols/http.c
--- monit.orig/protocols/http.c Mon Aug 12 17:41:20 2002
+++ monit/protocols/http.c Sat Aug 24 23:46:40 2002
@@ -17,14 +17,19 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
#include
#include
#include
-#include
-#include
+#if HAVE_NETINET_IN_H
+# include
+#endif
+#if HAVE_ARPA_INET_H
+# include
+#endif
#include "protocol.h"
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/spawn.c monit/spawn.c
--- monit.orig/spawn.c Thu Aug 8 17:03:11 2002
+++ monit/spawn.c Sat Aug 24 23:51:01 2002
@@ -17,15 +17,20 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
-#ifdef SOLARIS
-#include
+#if HAVE_STRINGS_H
+# include
#endif
#include
-#include
+#if HAVE_SYS_WAIT_H
+# include
+#endif
#include
-#include
+#if HAVE_SYS_STAT_H
+# include
+#endif
#include
#include
#include
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/status.c monit/status.c
--- monit.orig/status.c Thu Aug 8 17:03:11 2002
+++ monit/status.c Sat Aug 24 23:51:27 2002
@@ -19,8 +19,8 @@
#include
-#ifdef SOLARIS
-#include
+#if HAVE_STRINGS_H
+# include
#endif
#include
#include
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/util.c monit/util.c
--- monit.orig/util.c Fri Aug 16 16:57:49 2002
+++ monit/util.c Sun Aug 25 00:13:58 2002
@@ -17,19 +17,26 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
-#ifdef SOLARIS
-#include
+#if HAVE_STRINGS_H
+# include
#endif
#include
#include
-#include
+#if HAVE_SYS_STAT_H
+# include
+#endif
#include
#include
#include
#include
-#include
+#if TM_IN_SYS_TIME
+# include
+#else
+# include
+#endif
#include
#include
@@ -549,7 +556,7 @@
tzset();
tm_now = localtime(&now);
-#if HAVE_TM_GMTOFF
+#if HAVE_STRUCT_TM_TM_GMTOFF
timezone_h = tm_now->tm_gmtoff/3600;
timezone_m = abs(tm_now->tm_gmtoff/60)%60;
#else
diff -uNrb -X /home/ferlatte/patches/DONTDIFF monit.orig/xmalloc.c monit/xmalloc.c
--- monit.orig/xmalloc.c Fri Jun 28 13:59:03 2002
+++ monit/xmalloc.c Sun Aug 25 00:39:20 2002
@@ -16,6 +16,7 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include
#include
#include
@@ -45,8 +46,15 @@
void *xmalloc(int n) {
void *p;
-
p= (void *)malloc(n);
+/* Some malloc's don't return a valid pointer if you malloc(0), so check
+ for that only if necessary. */
+#if ! HAVE_MALLOC
+ if ( n == 0) {
+ error("%s: passed a broken malloc 0\n", prog);
+ exit(1);
+ }
+#endif
if ( p == NULL ) {
error("%s: malloc failed -- %s\n", prog, STRERROR);