[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
support for 'noalert' statement (alert negation)
From: |
Martin Pala |
Subject: |
support for 'noalert' statement (alert negation) |
Date: |
Thu, 23 Nov 2006 18:43:01 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7) Gecko/20060627 |
Hi,
according to feature requests on the mailing list, here is patch which
implements the 'noalert' statement. It allows to:
1.) either disable the alerts per-service for recipients which were set
globaly but don't want alerts for some particular service(s)
2.) or provide shortcut to select all-but-some alerts, such as when the
user wants all alerts except the monit instance related, he can use:
set noalert address@hidden on { instance }
instead of:
set alert address@hidden on { change
checksum
data
exec
gid
icmp
invalid
match
nonexist
permission
size
timeout
timestamp }
If you agree, i can add it to cvs.
Martin
Index: CHANGES.txt
===================================================================
RCS file: /sources/monit/monit/CHANGES.txt,v
retrieving revision 1.319
diff -u -r1.319 CHANGES.txt
--- CHANGES.txt 18 Nov 2006 00:16:26 -0000 1.319
+++ CHANGES.txt 23 Nov 2006 17:32:36 -0000
@@ -1,8 +1,29 @@
- CHANGES version 4.8.3
+ CHANGES version 4.9
This file summarizes changes made since 3.0
-Version 4.8.3
+Version 4.9
+
+NEW FEATURES AND FUNCTIONS:
+* The NOALERT statement added, which allows to disable all
+ or some alerts localy for particular recipient and service.
+ Useful for example when you have alert recipient set globaly
+ but don't want to receive alerts or particular alerts for
+ some part of services. When you specify the optional events
+ list, it will work like the alert statement, but the explicit
+ event list is negated.
+ Syntax:
+ [set] noalert <mail-address> ['{' <event>... '}']
+ Example1:
+ set noalert address@hidden on { restart }
+ Will send all alerts to address@hidden for all services and
+ events except the restart event (global usage).
+ Example2:
+ noalert address@hidden
+ Disables all alerts for address@hidden (local per-service usage).
+ Example3:
+ noalert address@hidden on { restart }
+ Enables all but 'restart' alerts (local per-service usage).
BUGFIXES:
* Fix the possible crash when event queue was used and some
Index: configure.ac
===================================================================
RCS file: /sources/monit/monit/configure.ac,v
retrieving revision 1.148
diff -u -r1.148 configure.ac
--- configure.ac 18 Nov 2006 00:14:41 -0000 1.148
+++ configure.ac 23 Nov 2006 17:32:36 -0000
@@ -7,7 +7,7 @@
AC_PREREQ([2.53])
# Init autoconf and automake
-AC_INIT([monit], [4.8.3-cvs], address@hidden)
+AC_INIT([monit], [4.9-cvs], address@hidden)
# Package info
AC_REVISION([$Revision: 1.148 $])
Index: event.h
===================================================================
RCS file: /sources/monit/monit/event.h,v
retrieving revision 1.25
diff -u -r1.25 event.h
--- event.h 1 Jan 2006 22:44:01 -0000 1.25
+++ event.h 23 Nov 2006 17:32:36 -0000
@@ -40,6 +40,7 @@
#define EVENT_ICMP 0x4000
#define EVENT_MATCH 0x8000
#define EVENT_INSTANCE 0x10000
+#define EVENT_ALL 0xFFFFFFFF
#define IS_EVENT_SET(value, mask) ((value & mask) != 0)
Index: l.l
===================================================================
RCS file: /sources/monit/monit/l.l,v
retrieving revision 1.113
diff -u -r1.113 l.l
--- l.l 25 Aug 2006 16:28:32 -0000 1.113
+++ l.l 23 Nov 2006 17:32:36 -0000
@@ -172,6 +172,7 @@
tcpssl { return TCPSSL; }
udp { return UDP; }
alert { return ALERT; }
+noalert { return NOALERT; }
mail-format { return MAILFORMAT; }
resource { return RESOURCE; }
restart(s)? { return RESTART; }
Index: monit.pod
===================================================================
RCS file: /sources/monit/monit/monit.pod,v
retrieving revision 1.193
diff -u -r1.193 monit.pod
--- monit.pod 25 Aug 2006 16:28:32 -0000 1.193
+++ monit.pod 23 Nov 2006 17:32:36 -0000
@@ -497,7 +497,7 @@
In both cases you can use more than one alert statement. In other
words, you can send many different emails to many different
-addresses. (in case you now got a new business idea; monit is not
+addresses. (in case you now got a new business idea: monit is not
really suitable for sending spam).
Recipients in the global and in the local lists are alerted when
@@ -508,6 +508,9 @@
to only use a global alert list (recommended), a local per
service list or both.
+It is also possible to disable the global alerts localy for
+particular service(s) and recipients.
+
=head2 Setting a global alert statement
If a change occurred on a monitored services, monit will send an
@@ -522,6 +525,15 @@
=back
+or
+
+=over 4
+
+=item SET NOALERT mail-address [{events}] [MAIL-FORMAT
+ {mail-format}] [REMINDER number]
+
+=back
+
Simply using the following in the global section of monitrc:
set alert address@hidden
@@ -536,6 +548,11 @@
For explanations of the I<events, MAIL-FORMAT and REMINDER>
keywords above, please see below.
+When you want to enable global alert recipient which will receive
+all event alerts except some type, you can also use the NOALERT
+statement instead of alert which allows you to set the recipient
+for "all but specified events" (see bellow for more details).
+
=head2 Setting a local alert statement
@@ -548,6 +565,15 @@
=back
+or
+
+=over 4
+
+=item NOALERT mail-address [{events}] [MAIL-FORMAT
+ {mail-format}] [REMINDER number]
+
+=back
+
If you only want an alert message sent for certain events for
certain service(s), for example only for timeout events or only
@@ -582,6 +608,46 @@
changed, timeout, resource, checksum, match, timestamp,
connection, permission>
+You can also disable the alerts localy using the NOALERT statement.
+This is useful for example when you have lot of services monitored,
+used the global alert statement, but don't want to receive alerts
+for some minor subset of services:
+
+ noalert address@hidden
+
+For example when you will place the noalert statement to the
+'check system', the given user won't receive the system related
+alerts (such as monit instance started/stopped/reloaded alert,
+system overloaded alert, etc.) but will receive the alerts for
+all other monitored services.
+
+Optionaly you can use the noalert statement to enable all but
+given alerts, i.e. it works like the alert statement, but the
+explicit event list is negated. For example when you want to
+receive alerts for all events except the monit instance related,
+you can write for example:
+
+ noalert address@hidden on { instance }
+
+instead of:
+
+ alert address@hidden on { change
+ checksum
+ data
+ exec
+ gid
+ icmp
+ invalid
+ match
+ nonexist
+ permission
+ size
+ timeout
+ timestamp }
+
+This will enable all alerts for address@hidden, except the monit instance
+related alerts.
+
The following example will alert address@hidden on all events on all
services by default, except the service mybar which will send an
alert only on timeout. The trick is based on the fact that local
@@ -2925,6 +2991,9 @@
certain events. See the examples above. More
than one alert statement is allowed in an
entry. This statement is also optional.
+ noalert Specifies an email address which don't want
+ to receive all or some alerts. This statement
+ is also optional.
restart, stop These keywords may be used as actions for
unmonitor, various test statements. The exec statement is
start and special in that it requires a following string
@@ -3007,7 +3076,7 @@
I<pemfile>, I<allow>, I<read-only>, I<check>, I<init>, I<count>,
I<pidfile>, I<statefile>, I<group>, I<start>, I<stop>, I<uid>,
I<gid>, I<connection>, I<port(number)>, I<unix(socket)>, I<type>,
-I<proto(col)>, I<tcp>, I<tcpssl>, I<udp>, I<alert>, I<icmp>,
+I<proto(col)>, I<tcp>, I<tcpssl>, I<udp>, I<alert>, I<noalert>,
I<mail-format>, I<restart>, I<timeout>, I<checksum>, I<resource>,
I<expect>, I<send>, I<mailserver>, I<every>, I<mode>, I<active>,
I<passive>, I<manual>, I<depends>, I<host>, I<default>, I<http>,
@@ -3015,7 +3084,7 @@
I<ssh>, I<dwp>, I<ldap2>, I<ldap3>, I<tns>, I<request>, I<cpu>,
I<mem>, I<totalmem>, I<children>, I<loadavg>, I<timestamp>,
I<changed>, I<second(s)>, I<minute(s)>, I<hour(s)>, I<day(s)>,
-I<space>, I<inode>, I<pid>, I<ppid>, I<perm(ission)>,
+I<space>, I<inode>, I<pid>, I<ppid>, I<perm(ission)>, I<icmp>,
I<process>, I<file>, I<directory>, I<device>, I<size>,
I<unmonitor>, I<rdate>, I<rsync>, I<data>, I<invalid>, I<exec>,
I<nonexist>, I<policy>, I<reminder>, I<instance>, I<eventqueue>,
Index: p.y
===================================================================
RCS file: /sources/monit/monit/p.y,v
retrieving revision 1.240
diff -u -r1.240 p.y
--- p.y 25 Aug 2006 16:28:32 -0000 1.240
+++ p.y 23 Nov 2006 17:32:36 -0000
@@ -250,7 +250,7 @@
%token STATEFILE SEND EXPECT CYCLE COUNT REMINDER
%token PIDFILE START STOP PATHTOK
%token HOST PORT TYPE UDP TCP TCPSSL PROTOCOL CONNECTION
-%token ALERT MAILFORMAT UNIXSOCKET SIGNATURE
+%token ALERT NOALERT MAILFORMAT UNIXSOCKET SIGNATURE
%token TIMEOUT RESTART CHECKSUM EVERY
%token DEFAULT HTTP APACHESTATUS FTP SMTP POP IMAP CLAMAV NNTP NTP3 MYSQL DNS
%token SSH DWP LDAP2 LDAP3 RDATE RSYNC TNS PGSQL POSTFIXPOLICY
@@ -434,7 +434,10 @@
addmail($<string>2, &mailset, &Run.maillist, eventset,
$<number>7);
}
| SET alertmail formatlist reminder {
- addmail($<string>2, &mailset, &Run.maillist, eventset,
$<number>4);
+ addmail($<string>2, &mailset, &Run.maillist, EVENT_ALL,
$<number>4);
+ }
+ | SET noalertmail '{' eventoptionlist '}' formatlist reminder {
+ addmail($<string>2, &mailset, &Run.maillist, ~eventset,
$<number>7);
}
;
@@ -1042,13 +1045,22 @@
addmail($<string>1, &mailset, ¤t->maillist, eventset,
$<number>6);
}
| alertmail formatlist reminder {
- addmail($<string>1, &mailset, ¤t->maillist, eventset,
$<number>3);
+ addmail($<string>1, &mailset, ¤t->maillist,
EVENT_ALL, $<number>3);
+ }
+ | noalertmail '{' eventoptionlist '}' formatlist reminder {
+ addmail($<string>1, &mailset, ¤t->maillist,
~eventset, $<number>6);
+ }
+ | noalertmail {
+ addmail($<string>1, &mailset, ¤t->maillist,
EVENT_NULL, 0);
}
;
alertmail : ALERT MAILADDR { $<string>$= $2; }
;
+noalertmail : NOALERT MAILADDR { $<string>$= $2; }
+ ;
+
eventoptionlist : eventoption
| eventoptionlist eventoption
;
@@ -1880,13 +1892,7 @@
ASSERT(mailto);
NEW(m);
- if(events != EVENT_NULL) {
- m->events= events;
- } else {
- /* Turn on all events */
- m->events= ~((unsigned int)0);
- }
-
+ m->events= events;
m->to= mailto;
m->from= f->from;
m->subject= f->subject;
@@ -3010,7 +3016,7 @@
*/
static void reset_mailset() {
memset(&mailset, 0, sizeof(struct mymail));
- eventset= 0;
+ eventset= EVENT_NULL;
}
Index: util.c
===================================================================
RCS file: /sources/monit/monit/util.c,v
retrieving revision 1.186
diff -u -r1.186 util.c
--- util.c 19 Jul 2006 17:33:37 -0000 1.186
+++ util.c 23 Nov 2006 17:32:36 -0000
@@ -1941,7 +1941,9 @@
* Print registered events list
*/
static void printevents(unsigned int events) {
- if(events == (~((unsigned int)0))) {
+ if(events == EVENT_NULL) {
+ printf("No events");
+ } else if(events == EVENT_ALL) {
printf("All events");
} else {
if(IS_EVENT_SET(events, EVENT_CHANGED))
Index: http/cervlet.c
===================================================================
RCS file: /sources/monit/monit/http/cervlet.c,v
retrieving revision 1.210
diff -u -r1.210 cervlet.c
--- http/cervlet.c 19 Jul 2006 19:10:34 -0000 1.210
+++ http/cervlet.c 23 Nov 2006 17:32:36 -0000
@@ -1325,10 +1325,10 @@
"<td>%s</td></tr>", r->to?r->to:"");
out_print(res, "<tr><td>Alert on</td><td>");
- if(r->events == (~((unsigned int)0))) {
-
+ if(r->events == EVENT_NULL) {
+ out_print(res, "No events");
+ } else if(r->events == EVENT_ALL) {
out_print(res, "All events");
-
} else {
if(IS_EVENT_SET(r->events, EVENT_CHANGED))
out_print(res, "Change ");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- support for 'noalert' statement (alert negation),
Martin Pala <=