monit-general
[Top][All Lists]
Advanced

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

[PATCH] total number of service (re)starts


From: Michel Marti
Subject: [PATCH] total number of service (re)starts
Date: Wed, 22 Dec 2004 13:37:27 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5

Hello all,

I've added a new counter to the Service_T structure that holds the number of
(re)starts of a service. This value is shown in both text/html and text/plain
status pages (xml still missing). How about adding this to monit?

Michel

------------------------------------------------------------------------
diff --exclude=CVS -urwN monit-cvs-ref/event.c monit-cvs/event.c
--- monit-cvs-ref/event.c       2004-12-13 00:45:08.000000000 +0100
+++ monit-cvs/event.c   2004-12-22 11:53:18.000000000 +0100
@@ -420,8 +420,10 @@
   case ACTION_RESTART:
       if(E->source->def_timeout)
         E->source->nstart++;
+
       if((E->source->mode != MODE_PASSIVE))
       {
+        E->source->total_start++;
         control_service(E->source->name, "restart");
       }
       return FALSE;
@@ -431,6 +433,7 @@
         E->source->nstart++;
       if((E->source->mode != MODE_PASSIVE))
       {
+        E->source->total_start++;
         control_service(E->source->name, "start");
       }
       return FALSE;
@@ -443,6 +446,7 @@
       return FALSE;

   case ACTION_UNMONITOR:
+      E->source->total_start=0; /* Reset total start count */
       control_service(E->source->name, "unmonitor");
       return FALSE;

diff --exclude=CVS -urwN monit-cvs-ref/http/cervlet.c monit-cvs/http/cervlet.c
--- monit-cvs-ref/http/cervlet.c        2004-12-21 10:48:48.000000000 +0100
+++ monit-cvs/http/cervlet.c    2004-12-22 12:03:03.000000000 +0100
@@ -712,6 +712,10 @@
       "<tr><td>Check service</td><td>every %d cycle</td></tr>",
       s->every?s->every:1);

+    out_print(res,
+      "<tr><td>Number of (re)starts</td><td>%d</td></tr>",
+      s->total_start);
+
     if(s->def_timeout && s->action_TIMEOUT) {
       EventAction_T a= s->action_TIMEOUT;
       out_print(res,
@@ -2095,10 +2099,12 @@
   out_print(res,
            "%s '%s'\n"
            "  %-33s %s\n"
-           "  %-33s %s\n",
+           "  %-33s %s\n"
+           "  %-33s %d\n",
            servicetypes[s->type], s->name,
            "status", status,
-           "monitoring status", monitornames[s->monitor]);
+           "monitoring status", monitornames[s->monitor],
+           "number of starts", s->total_start);
   FREE(status);
   if(Util_hasServiceStatus(s)) {
     if(s->type == TYPE_FILE || s->type == TYPE_DIRECTORY ||
diff --exclude=CVS -urwN monit-cvs-ref/monitor.h monit-cvs/monitor.h
--- monit-cvs-ref/monitor.h     2004-12-20 06:39:34.000000000 +0100
+++ monit-cvs/monitor.h 2004-12-22 11:51:54.000000000 +0100
@@ -627,6 +627,7 @@
   int  mode;                            /**< Monitoring mode for the service */
   int  ncycle;                          /**< The number of the current cycle */
   int  nstart;           /**< The number of current starts with this service */
+  int  total_start;           /**< The total number of starts for this service 
*/
   int  to_start;                                  /**< Timeout start ceiling */
   int  to_cycle;                                  /**< Timeout cycle ceiling */
   int  every;                        /**< Check this program at given cycles */
diff --exclude=CVS -urwN monit-cvs-ref/state.c monit-cvs/state.c
--- monit-cvs-ref/state.c       2004-12-13 00:45:09.000000000 +0100
+++ monit-cvs/state.c   2004-12-22 11:55:28.000000000 +0100
@@ -83,6 +83,7 @@
   int                ncycle;
   int                monitor;
   unsigned long long error;
+  int                total_start;
 } State_T;


@@ -267,6 +268,7 @@
   state->ncycle= service->ncycle;
   state->monitor= service->monitor;
   state->error= service->error;
+  state->total_start = service->total_start;

 }

@@ -278,5 +280,6 @@
   service->ncycle= state->ncycle;
   service->monitor= state->monitor;
   service->error= state->error;
+  service->total_start = state->total_start;

 }




reply via email to

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