monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[monit-dev] [monit] r320 committed - If protocol test failed, print requ


From: monit
Subject: [monit-dev] [monit] r320 committed - If protocol test failed, print request path in the event if it is set ...
Date: Sat, 15 Jan 2011 22:06:41 +0000

Revision: 320
Author: address@hidden
Date: Sat Jan 15 14:05:49 2011
Log: If protocol test failed, print request path in the event if it is set in monit configuration file.



http://code.google.com/p/monit/source/detail?r=320

Modified:
 /trunk/CHANGES.txt
 /trunk/gc.c
 /trunk/monitor.h
 /trunk/p.y
 /trunk/util.c
 /trunk/util.h
 /trunk/validate.c

=======================================
--- /trunk/CHANGES.txt  Sat Dec 18 07:17:09 2010
+++ /trunk/CHANGES.txt  Sat Jan 15 14:05:49 2011
@@ -20,6 +20,13 @@
 * Linux OpenVZ 2.6.32+: Fix memory usage monitoring in VPS
   virtual hosts. Thanks to Kelly for report.

+* If protocol test failed, print request path in the event if it is
+  set in monit configuration file. Thanks to Marco for report.
+
+IMPROVEMENTS:
+
+* Reduced memory usage.
+


 Version 5.2.3
=======================================
--- /trunk/gc.c Tue Dec 28 15:09:18 2010
+++ /trunk/gc.c Sat Jan 15 14:05:49 2011
@@ -402,7 +402,6 @@
   if((*p)->url_request)
     _gc_request(&(*p)->url_request);

-  FREE((*p)->address);
   FREE((*p)->request);
   FREE((*p)->hostname);
   FREE((*p)->pathname);
=======================================
--- /trunk/monitor.h    Tue Dec 28 13:00:51 2010
+++ /trunk/monitor.h    Sat Jan 15 14:05:49 2011
@@ -466,7 +466,6 @@
char *request_hostheader; /**< The optional Host: header to use */ int request_hashtype; /**< The optional type of hash for a req. document */ char *pathname; /**< Pathname, in case of an UNIX socket */ - char *address; /**< Human readable destination of the socket */ int maxforward; /**< Optional max forward for protocol checking */ Generic_T generic; /**< Generic test handle */ int timeout; /**< The timeout in seconds to wait for connect or read i/o */
=======================================
--- /trunk/p.y  Tue Dec 28 16:52:22 2010
+++ /trunk/p.y  Sat Jan 15 14:05:49 2011
@@ -2134,7 +2134,6 @@
  */
 static void addport(Port_T port) {
   Port_T p;
-  char address[STRLEN];

   ASSERT(port);

@@ -2166,14 +2165,6 @@
   } else
     p->request_hashtype = 0;

-  if (port->family == AF_INET)
-    snprintf(address, STRLEN, "INET[%s:%d]", port->hostname, port->port);
-  else if (port->family == AF_UNIX)
-    snprintf(address, STRLEN, "UNIX[%s]", port->pathname);
-  else
-    address[0] = 0;
-  p->address = xstrdup(address);
-
   if (port->SSL.use_ssl == TRUE) {
     if (!have_ssl()) {
       yyerror("ssl check cannot be activated. SSL is not supported");
=======================================
--- /trunk/util.c       Tue Dec 28 13:00:51 2010
+++ /trunk/util.c       Sat Jan 15 14:05:49 2011
@@ -2235,6 +2235,17 @@
       return "UNKNOWN";
   }
 }
+
+
+char *Util_portDescription(Port_T p, char *buf, int bufsize) {
+  if (p->family == AF_INET)
+ snprintf(buf, STRLEN, "INET[%s:%d%s]%s%s", p->hostname, p->port, p->request ? p->request : "", p->family == AF_INET ? " via " : "", p->family == AF_INET ? Util_portTypeDescription(p) : "");
+  else if (p->family == AF_UNIX)
+    snprintf(buf, STRLEN, "UNIX[%s]", p->pathname);
+  else
+    *buf = 0;
+  return buf;
+}


 void Util_stringbuffer(Buffer_T *b, const char *m, ...) {
=======================================
--- /trunk/util.h       Fri Sep 24 11:47:07 2010
+++ /trunk/util.h       Sat Jan 15 14:05:49 2011
@@ -495,6 +495,16 @@
 char *Util_portTypeDescription(Port_T p);


+/**
+ * Print full port description <INET|UNIX>\[<host>:<port>[request]\][via TCP|TCPSSL|UDP]
+ * @param p A port structure
+ * @param buf Buffer
+ * @param bufsize Buffer size
+ * @return the buffer
+ */
+char *Util_portDescription(Port_T p, char *buf, int bufsize);
+
+
 /**
  * Print to string buffer
  * @param b A Buffer object
=======================================
--- /trunk/validate.c   Tue Dec 28 15:09:18 2010
+++ /trunk/validate.c   Sat Jan 15 14:05:49 2011
@@ -554,7 +554,8 @@
 static void check_connection(Service_T s, Port_T p) {
   Socket_T socket;
   volatile int rv = TRUE;
-  char report[STRLEN]={0};
+  char buf[STRLEN];
+  char report[STRLEN] = {0};
   struct timeval t1;
   struct timeval t2;

@@ -566,29 +567,29 @@
/* Open a socket to the destination INET[hostname:port] or UNIX[pathname] */
   socket = socket_create(p);
   if (!socket) {
- snprintf(report, STRLEN, "failed, cannot open a connection to %s%s%s", p->address, p->family == AF_INET ? " via " : "", p->family == AF_INET ? Util_portTypeDescription(p) : ""); + snprintf(report, STRLEN, "failed, cannot open a connection to %s", Util_portDescription(p, buf, sizeof(buf)));
     rv = FALSE;
     goto error;
   } else
- DEBUG("'%s' succeeded connecting to %s%s%s\n", s->name, p->address, p->family == AF_INET ? " via " : "", p->family == AF_INET ? Util_portTypeDescription(p) : ""); + DEBUG("'%s' succeeded connecting to %s\n", s->name, Util_portDescription(p, buf, sizeof(buf)));

/* Verify that the socket is ready for i|o. TCP sockets are checked anytime, UDP * sockets just when there is no specific protocol test used since the socket_is_ready() * adds 2s delay when used with UDP socket. When there is specific protocol used, we
    * don't need it for UDP, since the protocol test is sufficient */
if ((socket_get_type(socket) != SOCK_DGRAM || p->protocol->check == check_default) && !socket_is_ready(socket)) { - snprintf(report, STRLEN, "connection failed, %s%s%s is not ready for i| o -- %s", p->address, p->family == AF_INET ?" via " : "", p->family == AF_INET ? Util_portTypeDescription(p) : "", STRERROR); + snprintf(report, STRLEN, "connection failed, %s is not ready for i|o -- %s", Util_portDescription(p, buf, sizeof(buf)), STRERROR);
     rv = FALSE;
     goto error;
   }

   /* Run the protocol verification routine through the socket */
   if (! p->protocol->check(socket)) {
- snprintf(report, STRLEN, "failed protocol test [%s] at %s%s%s", p->protocol->name, p->address, p->family == AF_INET ? " via " : "", p->family == AF_INET ? Util_portTypeDescription(p) : ""); + snprintf(report, STRLEN, "failed protocol test [%s] at %s", p->protocol->name, Util_portDescription(p, buf, sizeof(buf)));
     rv = FALSE;
     goto error;
   } else
- DEBUG("'%s' succeeded testing protocol [%s] at %s%s%s\n", s->name, p->protocol->name, p->address, p->family == AF_INET ? " via " : "", p->family == AF_INET ? Util_portTypeDescription(p) : ""); + DEBUG("'%s' succeeded testing protocol [%s] at %s\n", s->name, p->protocol->name, Util_portDescription(p, buf, sizeof(buf)));

   /* Get time of connection attempt finish */
   gettimeofday(&t2, NULL);
@@ -606,7 +607,7 @@
     Event_post(s, Event_Connection, STATE_FAILED, p->action, report);
   } else {
     p->is_available = TRUE;
- Event_post(s, Event_Connection, STATE_SUCCEEDED, p->action, "connection succeeded to %s%s%s", p->address, p->family == AF_INET ? " via " : "", p->family == AF_INET ? Util_portTypeDescription(p) : ""); + Event_post(s, Event_Connection, STATE_SUCCEEDED, p->action, "connection succeeded to %s", Util_portDescription(p, buf, sizeof(buf)));
   }

 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]