[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: remote host monitoring service syntax patch (proposal) - forgotten f
From: |
Martin Pala |
Subject: |
Re: remote host monitoring service syntax patch (proposal) - forgotten file |
Date: |
Wed, 10 Sep 2003 16:49:11 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030908 Debian/1.4-4 |
Martin wrote:
Hi,
here is patch for implementing syntax of remote host checks as discussed. New
syntax (only changed portion):
CHECK HOST myname WITH ADDRESS [192.168.1.1|www.myhost.com]
IF FAILED [HOST virtual.myhost.com] PORT 80 ...
=> you can use host specification in the port statement (usefull for definition
of virtual hosts in one statement).
Advantages of this patch:
1.) simplifies code
2.) provides consistent syntax for port statement for both process and remote
host checks (support for host option)
3.) supports virtual hosts => you don't need to specify one check for each
virtual host
4.) allows to split tests of remote services running on same physical host to more
checks in monitrc => you can monitor separately for example database and
webservices and define dependency for appropriate dependant local processes (some
may depend on database service only, some on webservices only, etc.)
5.) the basic syntax of remote host check is consistent to other checks by
supporting service tag (shortcut). This can also be usefull in the case of long
hostnames, IPv4 and IPv6 addresses
If you agree, i can checkin this patch plus update related documentation.
Martin
_______________________________________________
monit-dev mailing list
address@hidden
http://mail.nongnu.org/mailman/listinfo/monit-dev
diff -Naur monit-4.0-beta4/CHANGES.txt monit-4.0-beta4-mp/CHANGES.txt
--- monit-4.0-beta4/CHANGES.txt 2003-09-09 23:25:20.000000000 +0200
+++ monit-4.0-beta4-mp/CHANGES.txt 2003-09-10 15:42:00.000000000 +0200
@@ -30,7 +30,7 @@
* A new check service entry was added to allow monitoring of remote
host services. See the manual for the new syntax. Example:
- check host ftp.redhat.com
+ check host redhat with address ftp.redhat.com
if failed port 21 protocol ftp then alert
alert address@hidden
diff -Naur monit-4.0-beta4/l.l monit-4.0-beta4-mp/l.l
--- monit-4.0-beta4/l.l 2003-08-31 22:05:51.000000000 +0200
+++ monit-4.0-beta4-mp/l.l 2003-09-10 13:09:44.000000000 +0200
@@ -237,6 +237,7 @@
}
check[ \t]+host {
+ BEGIN(SERVICE_COND);
return CHECKHOST;
}
diff -Naur monit-4.0-beta4/monitrc monit-4.0-beta4-mp/monitrc
--- monit-4.0-beta4/monitrc 2003-09-06 01:32:47.000000000 +0200
+++ monit-4.0-beta4-mp/monitrc 2003-09-10 15:50:36.000000000 +0200
@@ -326,3 +326,12 @@
# if failed uid 0 then unmonitor
# if failed gid 0 then unmonitor
# alert address@hidden
+#
+#
+# check host myserver with address 192.168.1.1
+# if failed port 3306 then alert
+# if failed port 80 protocol http then alert
+# if failed port 443 type tcpssl protocol http
+# with timeout 15 seconds then alert
+# if failed host virtual.web.org port 80 protocol http
+# and request "/help/info.html" then alert
diff -Naur monit-4.0-beta4/p.y monit-4.0-beta4-mp/p.y
--- monit-4.0-beta4/p.y 2003-09-10 02:32:41.000000000 +0200
+++ monit-4.0-beta4-mp/p.y 2003-09-10 13:53:45.000000000 +0200
@@ -208,7 +208,6 @@
static void addservice(Service_T);
static void addmail(char *, Mail_T, unsigned int);
static void createservice(int, char *, char *);
- static void create_remote_service(char *);
static void adddependant(char *);
static void addport(struct PortSet *);
static void addresource(struct ResourceSet *);
@@ -321,6 +320,7 @@
optproc : start
| stop
| connection
+ | connectionunix
| timeout
| alert
| every
@@ -393,7 +393,7 @@
opthost : start
| stop
- | remoteconnection
+ | connection
| timeout
| alert
| every
@@ -577,10 +577,10 @@
}
;
-checkhost : CHECKHOST STRING {
- check_hostname($2);
+checkhost : CHECKHOST SERVICENAME ADDRESS STRING {
+ check_hostname($4);
check_name($<string>2);
- create_remote_service($2);
+ createservice(TYPE_REMOTE, $<string>2, $4);
}
;
@@ -615,23 +615,21 @@
portset.action= $<number>9;
addport(&portset);
}
- | IF FAILED unixsocket type protocol nettimeout THEN action {
- portset.timeout= $<number>6;
- portset.action= $<number>8;
- addport(&portset);
- }
;
-remoteconnection: IF FAILED port type protocol nettimeout THEN action {
- ASSERT(current && current->name);
- portset.hostname= xstrdup(current->name);
+connectionunix : IF FAILED unixsocket type protocol nettimeout THEN action {
portset.timeout= $<number>6;
portset.action= $<number>8;
- addport(&portset);
+ addport(&portset);
}
;
-host : /* EMPTY */ { portset.hostname= xstrdup(LOCALHOST); }
+host : /* EMPTY */ {
+ if(current->type == TYPE_REMOTE)
+ portset.hostname= xstrdup(current->path);
+ else
+ portset.hostname= xstrdup(LOCALHOST);
+ }
| HOST STRING { check_hostname($2); portset.hostname= $2; }
;
@@ -1156,36 +1154,6 @@
/*
- * Create a new remote service object and add any current objects
- * to the service list.
- */
-static void create_remote_service(char *hostname) {
-
- ASSERT(hostname);
-
- if(current) {
- addservice(current);
- }
- else {
- NEW(current);
- }
-
- /* Reset the current object */
- memset(current, 0, sizeof(*current));
-
- /* Set default values */
- current->do_monitor= TRUE;
- current->mode= MODE_ACTIVE;
-
- current->type= TYPE_REMOTE;
- current->name= hostname; /* The remote host name */
-
- pthread_mutex_init(¤t->mutex, NULL);
-
-}
-
-
-/*
* Add a service object to the servicelist
*/
static void addservice(Service_T s) {
diff -Naur monit-4.0-beta4/socket.c monit-4.0-beta4-mp/socket.c
--- monit-4.0-beta4/socket.c 2003-09-10 02:32:41.000000000 +0200
+++ monit-4.0-beta4-mp/socket.c 2003-09-10 13:51:26.000000000 +0200
@@ -134,7 +134,7 @@
* @return The connected Socket or NULL if an error occurred
*/
Socket_T socket_create(void *port) {
-
+
int s;
Socket_T S;
Port_T p= port;
@@ -153,7 +153,7 @@
} else {
S->host= xstrdup(p->hostname);
}
-
+
if(p->SSL.use_ssl) {
if(! (S->ssl= new_ssl_connection(NULL, p->SSL.version))) {
goto ssl_error;
@@ -171,15 +171,15 @@
S->Port= port;
return S;
-
+
ssl_error:
socket_free(&S);
return NULL;
-
+
}
return NULL;
-
+
}