Commit 7703cca0 authored by Sergey B Kirpichev's avatar Sergey B Kirpichev

New upstream version 5.26.0

parent d960322c
......@@ -70,6 +70,7 @@ monit_SOURCES = src/y.tab.c \
src/protocols/lmtp.c \
src/protocols/memcache.c \
src/protocols/mongodb.c \
src/protocols/mqtt.c \
src/protocols/mysql.c \
src/protocols/nntp.c \
src/protocols/ntp3.c \
......
......@@ -137,9 +137,10 @@ am_monit_OBJECTS = src/y.tab.$(OBJEXT) src/lex.yy.$(OBJEXT) \
src/protocols/http.$(OBJEXT) src/protocols/imap.$(OBJEXT) \
src/protocols/ldap2.$(OBJEXT) src/protocols/ldap3.$(OBJEXT) \
src/protocols/lmtp.$(OBJEXT) src/protocols/memcache.$(OBJEXT) \
src/protocols/mongodb.$(OBJEXT) src/protocols/mysql.$(OBJEXT) \
src/protocols/nntp.$(OBJEXT) src/protocols/ntp3.$(OBJEXT) \
src/protocols/pgsql.$(OBJEXT) src/protocols/pop.$(OBJEXT) \
src/protocols/mongodb.$(OBJEXT) src/protocols/mqtt.$(OBJEXT) \
src/protocols/mysql.$(OBJEXT) src/protocols/nntp.$(OBJEXT) \
src/protocols/ntp3.$(OBJEXT) src/protocols/pgsql.$(OBJEXT) \
src/protocols/pop.$(OBJEXT) \
src/protocols/postfix_policy.$(OBJEXT) \
src/protocols/protocol.$(OBJEXT) \
src/protocols/radius.$(OBJEXT) src/protocols/rdate.$(OBJEXT) \
......@@ -500,6 +501,7 @@ monit_SOURCES = src/y.tab.c \
src/protocols/lmtp.c \
src/protocols/memcache.c \
src/protocols/mongodb.c \
src/protocols/mqtt.c \
src/protocols/mysql.c \
src/protocols/nntp.c \
src/protocols/ntp3.c \
......@@ -703,6 +705,7 @@ src/protocols/ldap3.$(OBJEXT): src/protocols/$(am__dirstamp)
src/protocols/lmtp.$(OBJEXT): src/protocols/$(am__dirstamp)
src/protocols/memcache.$(OBJEXT): src/protocols/$(am__dirstamp)
src/protocols/mongodb.$(OBJEXT): src/protocols/$(am__dirstamp)
src/protocols/mqtt.$(OBJEXT): src/protocols/$(am__dirstamp)
src/protocols/mysql.$(OBJEXT): src/protocols/$(am__dirstamp)
src/protocols/nntp.$(OBJEXT): src/protocols/$(am__dirstamp)
src/protocols/ntp3.$(OBJEXT): src/protocols/$(am__dirstamp)
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for monit 5.25.3.
# Generated by GNU Autoconf 2.69 for monit 5.26.0.
#
# Report bugs to <monit-general@nongnu.org>.
#
......@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='monit'
PACKAGE_TARNAME='monit'
PACKAGE_VERSION='5.25.3'
PACKAGE_STRING='monit 5.25.3'
PACKAGE_VERSION='5.26.0'
PACKAGE_STRING='monit 5.26.0'
PACKAGE_BUGREPORT='monit-general@nongnu.org'
PACKAGE_URL=''
......@@ -1347,7 +1347,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures monit 5.25.3 to adapt to many kinds of systems.
\`configure' configures monit 5.26.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1418,7 +1418,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of monit 5.25.3:";;
short | recursive ) echo "Configuration of monit 5.26.0:";;
esac
cat <<\_ACEOF
......@@ -1542,7 +1542,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
monit configure 5.25.3
monit configure 5.26.0
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -2018,11 +2018,57 @@ $as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_member
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
# ---------------------------------------------
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
# accordingly.
ac_fn_c_check_decl ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
as_decl_name=`echo $2|sed 's/ *(.*//'`
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
#ifndef $as_decl_name
#ifdef __cplusplus
(void) $as_decl_use;
#else
(void) $as_decl_name;
#endif
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_decl
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by monit $as_me 5.25.3, which was
It was created by monit $as_me 5.26.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -2886,7 +2932,7 @@ fi
# Define the identity of the package.
PACKAGE='monit'
VERSION='5.25.3'
VERSION='5.26.0'
cat >>confdefs.h <<_ACEOF
......@@ -4210,7 +4256,7 @@ if test "x$POD2MAN" = "xno"; then
as_fn_error $? "pod2man is required to build the monit.1 man file." "$LINENO" 5
fi
else
POD2MANFLAGS="--center 'User Commands' --release 5.25.3 --date='www.mmonit.com' --lax"
POD2MANFLAGS="--center 'User Commands' --release 5.26.0 --date='www.mmonit.com' --lax"
fi
......@@ -15907,89 +15953,30 @@ $as_echo "#define HAVE_SSLV2 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TLSv1.1" >&5
$as_echo_n "checking for TLSv1.1... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <openssl/ssl.h>
int
main ()
{
TLSv1_1_method()
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
tlsv11=yes
else
tlsv11=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tlsv11" >&5
$as_echo "$tlsv11" >&6; }
if test "$tlsv11" = "yes" ; then
ac_fn_c_check_decl "$LINENO" "SSL_OP_NO_TLSv1_1" "ac_cv_have_decl_SSL_OP_NO_TLSv1_1" "#include <openssl/ssl.h>
"
if test "x$ac_cv_have_decl_SSL_OP_NO_TLSv1_1" = xyes; then :
$as_echo "#define HAVE_TLSV1_1 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TLSv1.2" >&5
$as_echo_n "checking for TLSv1.2... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <openssl/ssl.h>
int
main ()
{
TLSv1_2_method()
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
tlsv12=yes
else
tlsv12=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tlsv12" >&5
$as_echo "$tlsv12" >&6; }
if test "$tlsv12" = "yes" ; then
$as_echo "#define HAVE_TLSV1_2 1" >>confdefs.h
ac_fn_c_check_decl "$LINENO" "SSL_OP_NO_TLSv1_2" "ac_cv_have_decl_SSL_OP_NO_TLSv1_2" "#include <openssl/ssl.h>
"
if test "x$ac_cv_have_decl_SSL_OP_NO_TLSv1_2" = xyes; then :
fi
$as_echo "#define HAVE_TLSV1_2 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TLSv1.3" >&5
$as_echo_n "checking for TLSv1.3... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <openssl/ssl.h>
int
main ()
{
TLSv1_3_method()
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
tlsv13=yes
else
tlsv13=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tlsv13" >&5
$as_echo "$tlsv13" >&6; }
if test "$tlsv13" = "yes" ; then
ac_fn_c_check_decl "$LINENO" "SSL_OP_NO_TLSv1_3" "ac_cv_have_decl_SSL_OP_NO_TLSv1_3" "#include <openssl/ssl.h>
"
if test "x$ac_cv_have_decl_SSL_OP_NO_TLSv1_3" = xyes; then :
$as_echo "#define HAVE_TLSV1_3 1" >>confdefs.h
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for EC_KEY support" >&5
$as_echo_n "checking for EC_KEY support... " >&6; }
......@@ -16653,7 +16640,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by monit $as_me 5.25.3, which was
This file was extended by monit $as_me 5.26.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -16719,7 +16706,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
monit config.status 5.25.3
monit config.status 5.26.0
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
......@@ -6,7 +6,7 @@ AC_PREREQ([2.53])
# Note: in case of beta subversion, use underscore "_" rather then dash "-"
# since RPM doesn't allow dash in Version
# Example: 5.0_beta2
AC_INIT([monit], [5.25.3], [monit-general@nongnu.org])
AC_INIT([monit], [5.26.0], [monit-general@nongnu.org])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
......@@ -952,35 +952,9 @@ if test "$use_sslstatic" = "1" -o "$use_ssl" = "1"; then
AC_DEFINE([HAVE_SSLV2], 1, [Define to 1 if you have openssl with SSLv2])
fi
AC_MSG_CHECKING([for TLSv1.1])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <openssl/ssl.h>], [TLSv1_1_method()])],
[tlsv11=yes],
[tlsv11=no])
AC_MSG_RESULT($tlsv11)
if test "$tlsv11" = "yes" ; then
AC_DEFINE([HAVE_TLSV1_1], 1, [Define to 1 if you have openssl with TLSv1.1])
fi
AC_MSG_CHECKING([for TLSv1.2])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <openssl/ssl.h>], [TLSv1_2_method()])],
[tlsv12=yes],
[tlsv12=no])
AC_MSG_RESULT($tlsv12)
if test "$tlsv12" = "yes" ; then
AC_DEFINE([HAVE_TLSV1_2], 1, [Define to 1 if you have openssl with TLSv1.2])
fi
AC_MSG_CHECKING([for TLSv1.3])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <openssl/ssl.h>], [TLSv1_3_method()])],
[tlsv13=yes],
[tlsv13=no])
AC_MSG_RESULT($tlsv13)
if test "$tlsv13" = "yes" ; then
AC_DEFINE([HAVE_TLSV1_3], 1, [Define to 1 if you have openssl with TLSv1.3])
fi
AC_CHECK_DECL([SSL_OP_NO_TLSv1_1], [AC_DEFINE([HAVE_TLSV1_1], 1, [Define to 1 if you have openssl with TLSv1.1])], [], [[#include <openssl/ssl.h>]])
AC_CHECK_DECL([SSL_OP_NO_TLSv1_2], [AC_DEFINE([HAVE_TLSV1_2], 1, [Define to 1 if you have openssl with TLSv1.2])], [], [[#include <openssl/ssl.h>]])
AC_CHECK_DECL([SSL_OP_NO_TLSv1_3], [AC_DEFINE([HAVE_TLSV1_3], 1, [Define to 1 if you have openssl with TLSv1.3])], [], [[#include <openssl/ssl.h>]])
AC_MSG_CHECKING([for EC_KEY support])
AC_LINK_IFELSE(
......
......@@ -518,9 +518,8 @@ immediately. Calling C<monit> with the quit argument will kill a
running Monit daemon process instead of waking it up.
The start delay option can be used to wait (once) before Monit starts
checking services. This can be useful for example when the system
boots. Monit will by default start checking services immediately at
startup.
checking services after system reboot. Monit will by default start
checking services immediately at startup.
=head1 INIT SUPPORT
......@@ -1962,13 +1961,16 @@ I<resource> set depends on the service type:
=head3 System resource tests
I<LOADAVG([1min|5min|15min])> refers to the system's load average.
I<LOADAVG([1min|5min|15min]) [PER CORE]> refers to the system's load average.
The load average is the number of processes in the system run
queue, averaged over the specified time period. Example:
queue per CPU core, averaged over the specified time period. Example:
if loadavg (1min) > 90 for 15 cycles then alert
if loadavg (5min) > 80 for 10 cycles then alert
if loadavg (15min) > 70 for 8 cycles then alert
if loadavg (1min) per core > 2 for 15 cycles then alert
if loadavg (5min) per core > 1.5 for 10 cycles then alert
if loadavg (15min) per core > 1 for 8 cycles then alert
If you'll omit the I<per core> option, the test will check the total load average
regardless of CPU cores count.
I<CPU([user|system|wait])> is the percent of time the system spend
in user or kernel space and I/O. The user/system/wait modifier is
......@@ -3203,6 +3205,7 @@ knows how to speak:
I<LMTP>
I<MEMCACHE>
I<MONGODB>
I<MQTT>
I<MYSQL>
I<NNTP>
I<NTP3>
......@@ -3464,6 +3467,26 @@ Example:
then alert
=head4 MQTT
Syntax:
PROTOCOL MQTT [USERNAME string PASSWORD string]
I<USERNAME> MQTT username
I<PASSWORD> MQTT password
Username and password (credentials) are B<optional>.
Example:
check process mosquitto with pidfile /var/run/mosquitto.pid
start program = "/sbin/start mosquitto"
stop program = "/sbin/stop mosquitto"
if failed port 1883 protocol mqtt then alert
=head4 MYSQL
Syntax:
......
......@@ -129,7 +129,7 @@
.\" ========================================================================
.\"
.IX Title "MONIT 1"
.TH MONIT 1 "www.mmonit.com" "5.25.3" "User Commands"
.TH MONIT 1 "www.mmonit.com" "5.26.0" "User Commands"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
......@@ -643,9 +643,8 @@ immediately. Calling \f(CW\*(C`monit\*(C'\fR with the quit argument will kill a
running Monit daemon process instead of waking it up.
.PP
The start delay option can be used to wait (once) before Monit starts
checking services. This can be useful for example when the system
boots. Monit will by default start checking services immediately at
startup.
checking services after system reboot. Monit will by default start
checking services immediately at startup.
.SH "INIT SUPPORT"
.IX Header "INIT SUPPORT"
The \f(CW\*(C`set init\*(C'\fR statement prevents Monit from transforming itself into
......@@ -2192,16 +2191,19 @@ specified, default is \s-1EQUAL\s0).
\fISystem resource tests\fR
.IX Subsection "System resource tests"
.PP
\&\fI\s-1LOADAVG\s0([1min|5min|15min])\fR refers to the system's load average.
\&\fI\s-1LOADAVG\s0([1min|5min|15min]) [\s-1PER CORE\s0]\fR refers to the system's load average.
The load average is the number of processes in the system run
queue, averaged over the specified time period. Example:
queue per \s-1CPU\s0 core, averaged over the specified time period. Example:
.PP
.Vb 3
\& if loadavg (1min) > 90 for 15 cycles then alert
\& if loadavg (5min) > 80 for 10 cycles then alert
\& if loadavg (15min) > 70 for 8 cycles then alert
\& if loadavg (1min) per core > 2 for 15 cycles then alert
\& if loadavg (5min) per core > 1.5 for 10 cycles then alert
\& if loadavg (15min) per core > 1 for 8 cycles then alert
.Ve
.PP
If you'll omit the \fIper core\fR option, the test will check the total load average
regardless of \s-1CPU\s0 cores count.
.PP
\&\fI\s-1CPU\s0([user|system|wait])\fR is the percent of time the system spend
in user or kernel space and I/O. The user/system/wait modifier is
optional, if not used, the total system cpu usage is tested. Example:
......@@ -3598,6 +3600,7 @@ knows how to speak:
\fI\s-1LMTP\s0\fR
\fI\s-1MEMCACHE\s0\fR
\fI\s-1MONGODB\s0\fR
\fI\s-1MQTT\s0\fR
\fI\s-1MYSQL\s0\fR
\fI\s-1NNTP\s0\fR
\fI\s-1NTP3\s0\fR
......@@ -3887,6 +3890,30 @@ Example:
\& then alert
.Ve
.PP
\s-1MQTT\s0
.IX Subsection "MQTT"
.PP
Syntax:
.PP
.Vb 1
\& PROTOCOL MQTT [USERNAME string PASSWORD string]
.Ve
.PP
\&\fI\s-1USERNAME\s0\fR \s-1MQTT\s0 username
.PP
\&\fI\s-1PASSWORD\s0\fR \s-1MQTT\s0 password
.PP
Username and password (credentials) are \fBoptional\fR.
.PP
Example:
.PP
.Vb 4
\& check process mosquitto with pidfile /var/run/mosquitto.pid
\& start program = "/sbin/start mosquitto"
\& stop program = "/sbin/stop mosquitto"
\& if failed port 1883 protocol mqtt then alert
.Ve
.PP
\s-1MYSQL\s0
.IX Subsection "MYSQL"
.PP
......
......@@ -171,8 +171,8 @@ set httpd port 2812 and
## performed should a test fail.
#
# check system $HOST
# if loadavg (1min) > 4 then alert
# if loadavg (5min) > 2 then alert
# if loadavg (1min) per core > 2 for 5 cycles then alert
# if loadavg (5min) per core > 1.5 for 10 cycles then alert
# if cpu usage > 95% for 10 cycles then alert
# if memory usage > 75% then alert
# if swap usage > 25% then alert
......
......@@ -107,7 +107,7 @@ boolean_t filesystem_usage(Service_T s) {
s->inf.filesystem->mode = sb.st_mode;
s->inf.filesystem->uid = sb.st_uid;
s->inf.filesystem->gid = sb.st_gid;
s->inf.filesystem->f_filesused = s->inf.filesystem->f_files - s->inf.filesystem->f_filesfree;
s->inf.filesystem->f_filesused = s->inf.filesystem->f_filesfree > 0 ? s->inf.filesystem->f_files - s->inf.filesystem->f_filesfree : s->inf.filesystem->f_files;
s->inf.filesystem->f_blocksused = s->inf.filesystem->f_blocks - s->inf.filesystem->f_blocksfreetotal;
s->inf.filesystem->inode_percent = s->inf.filesystem->f_files > 0 ? 100. * (double)s->inf.filesystem->f_filesused / (double)s->inf.filesystem->f_files : 0.;
s->inf.filesystem->space_percent = s->inf.filesystem->f_blocks > 0 ? 100. * (double)s->inf.filesystem->f_blocksused / (double)s->inf.filesystem->f_blocks : 0.;
......
......@@ -297,6 +297,7 @@ static void _gc_service(Service_T *s) {
break;
}
FREE((*s)->name);
FREE((*s)->name_escaped);
FREE((*s)->path);
(*s)->next = NULL;
FREE(*s);
......@@ -396,6 +397,9 @@ static void _gcportlist(Port_T *p) {
} else if ((*p)->protocol->check == check_generic) {
if ((*p)->parameters.generic.sendexpect)
_gcgeneric(&(*p)->parameters.generic.sendexpect);
} else if ((*p)->protocol->check == check_mqtt) {
FREE((*p)->parameters.mqtt.username);
FREE((*p)->parameters.mqtt.password);
} else if ((*p)->protocol->check == check_mysql) {
FREE((*p)->parameters.mysql.username);
FREE((*p)->parameters.mysql.password);
......@@ -631,6 +635,7 @@ static void _gcpdl(Dependant_T *d) {
if ((*d)->next)
_gcpdl(&(*d)->next);
FREE((*d)->dependant);
FREE((*d)->dependant_escaped);
FREE(*d);
}
......
This diff is collapsed.
......@@ -316,6 +316,7 @@ rsync { return RSYNC; }
tns { return TNS; }
pgsql { return PGSQL; }
websocket { return WEBSOCKET; }
mqtt { return MQTT; }
origin { return ORIGIN; }
version { return VERSIONOPT; }
sip { return SIP; }
......@@ -351,6 +352,7 @@ cleanuplimit { return CLEANUPLIMIT; }
mem(ory)? { return MEMORY; }
swap { return SWAP; }
total[ ]?mem(ory)? { return TOTALMEMORY; }
core { return CORE; }
cpu { return CPU; }
total[ ]?cpu { return TOTALCPU; }
child(ren)? { return CHILDREN; }
......@@ -683,21 +685,21 @@ group[ \t]+ {
return SERVICENAME;
}
\"{str}\" {
\"[^\000-\037\"\n]+\" {
yylval.string = handle_quoted_string(yytext);
BEGIN(INITIAL);
save_arg();
return SERVICENAME;
}
\'{str}\' {
\'[^\000-\037\"\n]+\' {
yylval.string = handle_quoted_string(yytext);
BEGIN(INITIAL);
save_arg();
return SERVICENAME;
}
[\"\'] {
[\"]|[\'] {
yyerror("unbalanced quotes");
}
......@@ -717,13 +719,13 @@ group[ \t]+ {
return SERVICENAME;
}
\"{str}\" {
\"[^\000-\037\"\n]+\" {
yylval.string = handle_quoted_string(yytext);
save_arg();
return SERVICENAME;
}
\'{str}\' {
\'[^\000-\037\"\n]+\' {
yylval.string = handle_quoted_string(yytext);
save_arg();
return SERVICENAME;
......
This diff is collapsed.
......@@ -541,9 +541,6 @@ static void do_default() {
LogInfo("Starting Monit %s daemon\n", VERSION);
}
if (Run.startdelay)
LogInfo("Monit start delay set to %ds\n", Run.startdelay);
if (! (Run.flags & Run_Foreground))
daemonize();
......@@ -558,10 +555,12 @@ static void do_default() {
atexit(file_finalize);
if (Run.startdelay) {
if (Run.startdelay && State_reboot()) {
time_t now = Time_now();
time_t delay = now + Run.startdelay;
LogInfo("Monit will delay for %ds on first start after reboot ...\n", Run.startdelay);
/* sleep can be interrupted by signal => make sure we paused long enough */
while (now < delay) {
sleep((unsigned int)(delay - now));
......
......@@ -159,8 +159,6 @@ typedef enum {
#define SSL_TIMEOUT 15000
#define SMTP_TIMEOUT 30000
#define START_DELAY 0
//FIXME: refactor Run_Flags to bit field
typedef enum {
......@@ -335,7 +333,10 @@ typedef enum {
Resource_ReadOperations,
Resource_WriteBytes,
Resource_WriteOperations,
Resource_ServiceTime
Resource_ServiceTime,
Resource_LoadAveragePerCore1m,
Resource_LoadAveragePerCore5m,
Resource_LoadAveragePerCore15m
} __attribute__((__packed__)) Resource_Type;
......@@ -692,6 +693,10 @@ typedef struct Port_T {
char *checksum; /**< Document checksum (optional) */
List_T headers; /**< List of headers to send with request (optional) */
} http;
struct {
char *username;
char *password;
} mqtt;
struct {
char *username;
char *password;
......@@ -741,6 +746,7 @@ typedef struct Icmp_T {
typedef struct Dependant_T {
char *dependant; /**< name of dependant service */
char *dependant_escaped; /**< URL escaped name of dependant service */
/** For internal use */
struct Dependant_T *next; /**< next dependant service in chain */
......@@ -1123,6 +1129,7 @@ typedef struct Service_T {
/** Common parameters */
char *name; /**< Service descriptive name */
char *name_escaped; /**< Service name URL escaped */
State_Type (*check)(struct Service_T *);/**< Service verification function */
boolean_t visited; /**< Service visited flag, set if dependencies are used */
Service_Type type; /**< Monitored service type */
......@@ -1250,7 +1257,7 @@ struct Run_T {
Limits_T limits; /**< Default limits */
struct SslOptions_T ssl; /**< Default SSL options */
int polltime; /**< In deamon mode, the sleeptime (sec) between run */
int startdelay; /**< the sleeptime (sec) after startup */
int startdelay; /**< the sleeptime [s] on first start after machine boot */
int facility; /** The facility to use when running openlog() */
int eventlist_slots; /**< The event queue size - number of slots */
int mailserver_timeout; /**< Connect and read timeout ms for a SMTP server */
......
......@@ -326,7 +326,7 @@ static void addsecurityattribute(char *, Action_Type, Action_Type);
%token HOST HOSTNAME PORT IPV4 IPV6 TYPE UDP TCP TCPSSL PROTOCOL CONNECTION
%token ALERT NOALERT MAILFORMAT UNIXSOCKET SIGNATURE
%token TIMEOUT RETRY RESTART CHECKSUM EVERY NOTEVERY
%token DEFAULT HTTP HTTPS APACHESTATUS FTP SMTP SMTPS POP POPS IMAP IMAPS CLAMAV NNTP NTP3 MYSQL DNS WEBSOCKET
%token DEFAULT HTTP HTTPS APACHESTATUS FTP SMTP SMTPS POP POPS IMAP IMAPS CLAMAV NNTP NTP3 MYSQL DNS WEBSOCKET MQTT
%token SSH DWP LDAP2 LDAP3 RDATE RSYNC TNS PGSQL POSTFIXPOLICY SIP LMTP GPS RADIUS MEMCACHE REDIS MONGODB SIEVE SPAMASSASSIN FAIL2BAN
%token <string> STRING PATH MAILADDR MAILFROM MAILREPLYTO MAILSUBJECT
%token <string> MAILBODY SERVICENAME STRINGNAME
......@@ -337,7 +337,7 @@ static void addsecurityattribute(char *, Action_Type, Action_Type);
%token CHECKPROC CHECKFILESYS CHECKFILE CHECKDIR CHECKHOST CHECKSYSTEM CHECKFIFO CHECKPROGRAM CHECKNET
%token THREADS CHILDREN METHOD GET HEAD STATUS ORIGIN VERSIONOPT READ WRITE OPERATION SERVICETIME DISK
%token RESOURCE MEMORY TOTALMEMORY LOADAVG1 LOADAVG5 LOADAVG15 SWAP
%token MODE ACTIVE PASSIVE MANUAL ONREBOOT NOSTART LASTSTATE CPU TOTALCPU CPUUSER CPUSYSTEM CPUWAIT
%token MODE ACTIVE PASSIVE MANUAL ONREBOOT NOSTART LASTSTATE CORE CPU TOTALCPU CPUUSER CPUSYSTEM CPUWAIT
%token GROUP REQUEST DEPENDS BASEDIR SLOT EVENTQUEUE SECRET HOSTHEADER
%token UID EUID GID MMONIT INSTANCE USERNAME PASSWORD
%token TIME ATIME CTIME MTIME CHANGED MILLISECOND SECOND MINUTE HOUR DAY MONTH
......@@ -619,7 +619,7 @@ setterminal : SET TERMINAL BATCH {
;
startdelay : /* EMPTY */ {
$<number>$ = START_DELAY;
$<number>$ = 0;
}
| START DELAY NUMBER {
$<number>$ = $3;
......@@ -1557,6 +1557,9 @@ protocol : PROTOCOL APACHESTATUS apache_stat_list {
| PROTOCOL MONGODB {
portset.protocol = Protocol_get(Protocol_MONGODB);
}
| PROTOCOL MQTT mqttlist {
portset.protocol = Protocol_get(Protocol_MQTT);
}
| PROTOCOL MYSQL mysqllist {
portset.protocol = Protocol_get(Protocol_MYSQL);
}
......@@ -1678,6 +1681,18 @@ smtp : username {
}
;
mqttlist : /* EMPTY */
| mqttlist mqtt
;
mqtt : username {
portset.parameters.mqtt.username = $<string>1;
}
| password {
portset.parameters.mqtt.password = $<string>1;
}
;
mysqllist : /* EMPTY */
| mysqllist mysql
;
......@@ -2244,10 +2259,23 @@ resourcechild : CHILDREN operator NUMBER {
}
;
resourceload : resourceloadavg operator value {
resourceset.resource_id = $<number>1;
resourceset.operator = $<number>2;
resourceset.limit = $<real>3;
resourceload : resourceloadavg coremultiplier operator value {
switch ($<number>1) {
case Resource_LoadAverage1m:
resourceset.resource_id = $<number>2 > 1 ? Resource_LoadAveragePerCore1m : $<number>1;
break;
case Resource_LoadAverage5m:
resourceset.resource_id = $<number>2 > 1 ? Resource_LoadAveragePerCore5m : $<number>1;
break;
case Resource_LoadAverage15m:
resourceset.resource_id = $<number>2 > 1 ? Resource_LoadAveragePerCore15m : $<number>1;
break;
default:
resourceset.resource_id = $<number>1;
break;
}
resourceset.operator = $<number>3;
resourceset.limit = $<real>4;
}
;
......@@ -2256,6 +2284,11 @@ resourceloadavg : LOADAVG1 { $<number>$ = Resource_LoadAverage1m; }
| LOADAVG15 { $<number>$ = Resource_LoadAverage15m; }
;
coremultiplier : /* EMPTY */ { $<number>$ = 1; }
| CORE { $<number>$ = systeminfo.cpu.count; }
;
resourceread : DISK READ operator value unit currenttime {
resourceset.resource_id = Resource_ReadBytes;
resourceset.operator = $<number>3;
......@@ -2939,8 +2972,6 @@ void yywarning2(const char *s, ...) {
boolean_t parse(char *controlfile) {
ASSERT(controlfile);
servicelist = tail = current = NULL;
if ((yyin = fopen(controlfile,"r")) == (FILE *)NULL) {
LogError("Cannot open the control file '%s' -- %s\n", controlfile, STRERROR);
return false;
......@@ -2984,6 +3015,7 @@ boolean_t parse(char *controlfile) {
* Initialize objects used by the parser.
*/
static void preparse() {
servicelist = tail = current = NULL;
/* Set instance incarnation ID */
time(&Run.incarnation);