[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
monitoring status patch (Oliver's patch from 3.2.2003)
From: |
Martin Pala |
Subject: |
monitoring status patch (Oliver's patch from 3.2.2003) |
Date: |
Tue, 11 Feb 2003 11:33:26 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021226 Debian/1.2.1-9 |
I modified little bit Oliver's patch for monitoring status report.
Cervlet and command line are able with it to report status of
do_validate flag (for example):
Process 'sshd' is running with pid [10560]
Uptime: 47m CPU: 0.0% Memory: 0.3% [1292kB]
Monitoring status: monitored
Process 'slapd' is running with pid [12293]
Uptime: 1m CPU: 0.0% Memory: 0.6% [2176kB]
Monitoring status: monitored
It can be useful for example in the case, where monitoring timed out but
the process
is running => monit reports that the process is running though not
monitored (for example):
Process 'slapd' is running with pid [12689]
Uptime: 0m CPU: 0.0% Memory: 0.0% [0kB]
Monitoring status: not monitored
In such case if you decided to enable monitoring again, you can run:
unicorn:~# monit start slapd
Because the process is already running, monit will enable do_validate
flag only and let
the process as is:
Process 'slapd' is running with pid [12689]
Uptime: 0m CPU: 0.0% Memory: 0.6% [2088kB]
Monitoring status: monitored
What about it? We have funny president ellection in Czech republic now -
lets vote for the patch too :)
+1 for it
Martin
diff -Naur monit/control.c monit-oliver/control.c
--- monit/control.c 2003-02-10 08:40:40.000000000 +0100
+++ monit-oliver/control.c 2003-02-11 10:46:26.000000000 +0100
@@ -206,6 +206,15 @@
if(is(action, "start")) {
if(is_process_running(p)) {
+
+ if(!p->do_validate) {
+
+ LOCK(Run.mutex)
+ p->do_validate= TRUE;
+ END_LOCK;
+
+ }
+
return;
}
diff -Naur monit/http/cervlet.c monit-oliver/http/cervlet.c
--- monit/http/cervlet.c 2003-02-10 20:39:55.000000000 +0100
+++ monit-oliver/http/cervlet.c 2003-02-11 10:36:17.000000000 +0100
@@ -645,6 +645,9 @@
"<tr><td>Monitoring mode</a></td><td>%s</td></tr>",
modenames[p->mode]);
out_print(res,
+ "<tr><td>Monitoring status</a></td><td>%s</td></tr>",
+ statusnames[p->do_validate]);
+ out_print(res,
"<tr><td>Start program</a></td><td>%s</td></tr>",
p->start?p->start->arg[0]:"(not defined)");
out_print(res,
@@ -873,20 +876,18 @@
if( Run.httpdssl ) {
printf_ssl_socket(res->ssl,
- "Process '%s' is running with pid [%d] \n\tUptime: %s "
- "CPU: %.1f%% Memory: %.1f%% [%ldkB]\n",
- p->name, (int)pid, uptime,
- pi->cpu_percent/10.0,
- pi->mem_percent/10.0,pi->mem_kbyte);
+ "Process '%s' is running with pid [%d]\n\tUptime: %s "
+ "CPU: %.1f%% Memory: %.1f%% [%ldkB]\n\tMonitoring status: %s\n",
+ p->name, (int)pid, uptime, pi->cpu_percent/10.0,
+ pi->mem_percent/10.0,pi->mem_kbyte, statusnames[p->do_validate]);
} else {
fprintf(out,
- "Process '%s' is running with pid [%d] \n\tUptime: %s "
- "CPU: %.1f%% Memory: %.1f%% [%ldkB]\n",
- p->name, (int)pid, uptime,
- pi->cpu_percent/10.0,
- pi->mem_percent/10.0,pi->mem_kbyte);
+ "Process '%s' is running with pid [%d]\n\tUptime: %s "
+ "CPU: %.1f%% Memory: %.1f%% [%ldkB]\n\tMonitoring status: %s\n",
+ p->name, (int)pid, uptime, pi->cpu_percent/10.0,
+ pi->mem_percent/10.0,pi->mem_kbyte, statusnames[p->do_validate]);
}
diff -Naur monit/monit_process.c monit-oliver/monit_process.c
--- monit/monit_process.c 2002-12-21 17:01:47.000000000 +0100
+++ monit-oliver/monit_process.c 2003-02-11 10:24:32.000000000 +0100
@@ -75,9 +75,10 @@
char actionnames[][STRLEN]= {"ignore", "alert", "restart", "stop"};
char modenames[][STRLEN]= {"active", "passive", "manual"};
-char operatorshortnames[][3]= {">", "<", "=", "!="};
char operatornames[][STRLEN]= {"greater than", "less than", "equal to",
"not equal to"};
+char operatorshortnames[][3]= {">", "<", "=", "!="};
+char statusnames[][STRLEN]= {"not monitored", "monitored" };
int include_children= TRUE;
int num_cpus=1;
diff -Naur monit/monit_process.h monit-oliver/monit_process.h
--- monit/monit_process.h 2002-11-29 14:28:47.000000000 +0100
+++ monit-oliver/monit_process.h 2003-02-11 09:51:23.000000000 +0100
@@ -33,6 +33,7 @@
extern char modenames[][STRLEN];
extern char operatornames[][STRLEN];
extern char operatorshortnames[][3];
+extern char statusnames[][STRLEN];
extern int num_cpus;
#define RESOURCE_ID_CPU_PERCENT 1
diff -Naur monit/status.c monit-oliver/status.c
--- monit/status.c 2002-12-21 17:01:47.000000000 +0100
+++ monit-oliver/status.c 2003-02-11 10:37:08.000000000 +0100
@@ -164,8 +164,9 @@
char *uptime= get_process_uptime(p->pidfile);
- fprintf(stdout, "Process '%s' is running with pid [%d] Uptime: %s\n",
- p->name, (int)pid, uptime);
+ fprintf(stdout, "Process '%s' is running with pid [%d] Uptime: %s "
+ "Monitoring status: %s\n",
+ p->name, (int)pid, uptime, statusnames[p->do_validate]);
free(uptime);
- monitoring status patch (Oliver's patch from 3.2.2003),
Martin Pala <=