[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Total-#-of-starts counter
From: |
Michel Marti |
Subject: |
[PATCH] Total-#-of-starts counter |
Date: |
Mon, 31 Jan 2005 14:49:40 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5 |
Hello,
Attached is a patch against monit-CVS that adds a (re)start counter to a
service. It is increased every time that a service is (re)started and reset if
the service unmonitored. The counter is displayed on the html/text/xml status page.
Can you apply this patch?
Cheers,
Michel
PS: I've sent an older version of this patch to the monit-user-mail-list a few
weeks ago but never got a reply...
diff -urN --exclude=CVS monit-cvs-start/event.c monit-cvs-local/event.c
--- monit-cvs-start/event.c 2005-01-06 21:51:49.000000000 +0100
+++ monit-cvs-local/event.c 2005-01-31 14:03:47.000000000 +0100
@@ -422,6 +422,7 @@
E->source->nstart++;
if((E->source->mode != MODE_PASSIVE))
{
+ E->source->total_start++;
control_service(E->source->name, "restart");
}
return FALSE;
@@ -431,6 +432,7 @@
E->source->nstart++;
if((E->source->mode != MODE_PASSIVE))
{
+ E->source->total_start++;
control_service(E->source->name, "start");
}
return FALSE;
@@ -443,6 +445,7 @@
return FALSE;
case ACTION_UNMONITOR:
+ E->source->total_start=0; /* Reset total start count */
control_service(E->source->name, "unmonitor");
return FALSE;
diff -urN --exclude=CVS monit-cvs-start/http/cervlet.c
monit-cvs-local/http/cervlet.c
--- monit-cvs-start/http/cervlet.c 2005-01-31 14:01:16.000000000 +0100
+++ monit-cvs-local/http/cervlet.c 2005-01-31 14:42:55.000000000 +0100
@@ -719,6 +719,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,
@@ -2109,10 +2113,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 (re)starts", s->total_start);
FREE(status);
if(Util_hasServiceStatus(s)) {
if(s->type == TYPE_FILE || s->type == TYPE_DIRECTORY ||
diff -urN --exclude=CVS monit-cvs-start/monitor.h monit-cvs-local/monitor.h
--- monit-cvs-start/monitor.h 2005-01-31 14:01:15.000000000 +0100
+++ monit-cvs-local/monitor.h 2005-01-31 14:07:07.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 (re)starts with this service */
int to_start; /**< Timeout start ceiling */
int to_cycle; /**< Timeout cycle ceiling */
int every; /**< Check this program at given cycles */
diff -urN --exclude=CVS monit-cvs-start/state.c monit-cvs-local/state.c
--- monit-cvs-start/state.c 2005-01-06 21:51:49.000000000 +0100
+++ monit-cvs-local/state.c 2005-01-31 14:09:21.000000000 +0100
@@ -80,6 +80,7 @@
char name[STRLEN];
int mode;
int nstart;
+ int total_start;
int ncycle;
int monitor;
unsigned long long error;
@@ -264,6 +265,7 @@
strncpy(state->name, service->name, STRLEN);
state->mode= service->mode;
state->nstart= service->nstart;
+ state->total_start= service->total_start;
state->ncycle= service->ncycle;
state->monitor= service->monitor;
state->error= service->error;
@@ -275,6 +277,7 @@
service->mode= state->mode;
service->nstart= state->nstart;
+ service->total_start= state->total_start;
service->ncycle= state->ncycle;
service->monitor= state->monitor;
service->error= state->error;
diff -urN --exclude=CVS monit-cvs-start/xml.c monit-cvs-local/xml.c
--- monit-cvs-start/xml.c 2005-01-06 21:51:49.000000000 +0100
+++ monit-cvs-local/xml.c 2005-01-31 14:42:29.000000000 +0100
@@ -206,12 +206,14 @@
"\t\t<name>%s</name>\r\n"
"\t\t<status>%llu</status>\r\n"
"\t\t<monitor>%d</monitor>\r\n"
+ "\t\t<starttotal>%d</starttotal>\r\n"
"\t\t<group>%s</group>\r\n",
S->type,
S->collected,
S->name,
S->error,
S->monitor,
+ S->total_start,
S->group?S->group:"");
if(Util_hasServiceStatus(S)) {
if(S->type == TYPE_FILE ||
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Total-#-of-starts counter,
Michel Marti <=