[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[monit-dev] [monit] r225 committed - [No log message]
From: |
monit |
Subject: |
[monit-dev] [monit] r225 committed - [No log message] |
Date: |
Thu, 26 Aug 2010 19:32:43 +0000 |
Revision: 225
Author: martin2812
Date: Thu Aug 26 12:31:40 2010
Log: [No log message]
http://code.google.com/p/monit/source/detail?r=225
Modified:
/trunk/collector.c
/trunk/http/cervlet.c
/trunk/monitor.h
/trunk/xml.c
=======================================
--- /trunk/collector.c Sat Feb 13 13:34:29 2010
+++ /trunk/collector.c Thu Aug 26 12:31:40 2010
@@ -99,7 +99,7 @@
}
}
- D = status_xml(E, LEVEL_FULL);
+ D = status_xml(E, LEVEL_FULL, 2);
if(!data_send(socket, C, D)) {
LogError("M/Monit: communication failed\n");
=======================================
--- /trunk/http/cervlet.c Mon Jul 26 07:54:50 2010
+++ /trunk/http/cervlet.c Thu Aug 26 12:31:40 2010
@@ -89,6 +89,7 @@
#define GETID "/_getid"
#define PIXEL "/_pixel"
#define STATUS "/_status"
+#define STATUS2 "/_status2"
#define RUN "/_runtime"
#define VIEWLOG "/_viewlog"
#define DOACTION "/_doaction"
@@ -142,7 +143,7 @@
static void print_service_params_checksum(HttpResponse, Service_T);
static void print_service_params_process(HttpResponse, Service_T);
static void print_service_params_resource(HttpResponse, Service_T);
-static void print_status(HttpRequest, HttpResponse);
+static void print_status(HttpRequest, HttpResponse, int);
static void status_service_txt(Service_T, HttpResponse, short);
static char *get_service_status_html(Service_T);
static char *get_service_status_text(Service_T);
@@ -225,7 +226,9 @@
} else if(ACTION(PIXEL)) {
printPixel(res);
} else if(ACTION(STATUS)) {
- print_status(req, res);
+ print_status(req, res, 1);
+ } else if(ACTION(STATUS2)) {
+ print_status(req, res, 2);
} else if(ACTION(DOACTION)) {
handle_do_action(req, res);
} else {
@@ -2295,7 +2298,7 @@
/* Print status in the given format. Text status is default. */
-static void print_status(HttpRequest req, HttpResponse res)
+static void print_status(HttpRequest req, HttpResponse res, int version)
{
Service_T s;
short level = LEVEL_FULL;
@@ -2309,7 +2312,7 @@
if(stringFormat && Util_startsWith(stringFormat, "xml"))
{
- char *D = status_xml(NULL, level);
+ char *D = status_xml(NULL, level, version);
out_print(res, "%s", D);
FREE(D);
set_content_type(res, "text/xml");
=======================================
--- /trunk/monitor.h Tue Aug 24 01:12:53 2010
+++ /trunk/monitor.h Thu Aug 26 12:31:40 2010
@@ -964,7 +964,7 @@
void reset_procinfo(Service_T);
int check_service_status(Service_T);
void printhash(char *);
-char *status_xml(Event_T, short);
+char *status_xml(Event_T, short, int);
int handle_mmonit(Event_T);
int do_wakeupcall();
=======================================
--- /trunk/xml.c Tue Aug 24 01:12:53 2010
+++ /trunk/xml.c Thu Aug 26 12:31:40 2010
@@ -67,9 +67,9 @@
/* --------------------------------------------------------------
Prototypes */
-static void document_head(Buffer_T *);
+static void document_head(Buffer_T *, int);
static void document_foot(Buffer_T *);
-static void status_service(Service_T, Buffer_T *, short);
+static void status_service(Service_T, Buffer_T *, short, int);
static void status_servicegroup(ServiceGroup_T, Buffer_T *, short);
static void status_event(Event_T, Buffer_T *);
@@ -82,24 +82,25 @@
* of monitored services and resources.
* @param E An event object or NULL for general status
* @param L Status information level
+ * @param V Format version
* @return XML document or NULL in the case of error. The caller must free
* the memory.
*/
-char *status_xml(Event_T E, short L) {
+char *status_xml(Event_T E, short L, int V) {
Buffer_T B;
Service_T S;
ServiceGroup_T SG;
memset(&B, 0, sizeof(Buffer_T));
- document_head(&B);
+ document_head(&B, V);
if (E) {
status_event(E, &B);
} else {
Util_stringbuffer(&B, "<services>");
for (S = servicelist_conf; S; S = S->next_conf)
- status_service(S, &B, L);
+ status_service(S, &B, L, V);
Util_stringbuffer(&B, "</services>");
Util_stringbuffer(&B, "<servicegroups>");
for (SG = servicegrouplist; SG; SG = SG->next)
@@ -120,26 +121,40 @@
/**
* Prints a document header into the given buffer.
* @param B Buffer object
+ * @param V Format version
*/
-static void document_head(Buffer_T *B) {
-
+static void document_head(Buffer_T *B, int V) {
Util_stringbuffer(B,
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
- "<monit id=\"%s\" incarnation=\"%lld\" version=\"%s\">"
- "<server>"
- "<uptime>%ld</uptime>"
- "<poll>%d</poll>"
- "<startdelay>%d</startdelay>"
- "<localhostname>%s</localhostname>"
- "<controlfile>%s</controlfile>",
- Run.id,
- (long long)Run.incarnation,
- VERSION,
- (long)Util_getProcessUptime(Run.pidfile),
- Run.polltime,
- Run.startdelay,
- Run.localhostname ? Run.localhostname : "",
- Run.controlfile ? Run.controlfile : "");
+ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
+ if (V == 2) {
+ Util_stringbuffer(B,
+ "<monit id=\"%s\" incarnation=\"%lld\" version=\"%s\">"
+ "<server>",
+ Run.id,
+ (long long)Run.incarnation,
+ VERSION);
+ } else {
+ Util_stringbuffer(B,
+ "<monit>"
+ "<server>"
+ "<id>%s</id>"
+ "<incarnation>%lld</incarnation>"
+ "<version>%s</version>",
+ Run.id,
+ (long long)Run.incarnation,
+ VERSION);
+ }
+ Util_stringbuffer(B,
+ "<uptime>%ld</uptime>"
+ "<poll>%d</poll>"
+ "<startdelay>%d</startdelay>"
+ "<localhostname>%s</localhostname>"
+ "<controlfile>%s</controlfile>",
+ (long)Util_getProcessUptime(Run.pidfile),
+ Run.polltime,
+ Run.startdelay,
+ Run.localhostname ? Run.localhostname : "",
+ Run.controlfile ? Run.controlfile : "");
if(Run.dohttpd) {
Util_stringbuffer(B,
@@ -200,29 +215,38 @@
* @param S Service object
* @param B Buffer object
* @param L Status information level
+ * @param V Format version
*/
-static void status_service(Service_T S, Buffer_T *B, short L) {
+static void status_service(Service_T S, Buffer_T *B, short L, int V) {
Event_T E = S->eventlist;
+ if (V == 2)
+ Util_stringbuffer(B,
+ "<service name=\"%s\">"
+ "<type>%d</type>",
+ S->name ? S->name : "",
+ S->type);
+ else
+ Util_stringbuffer(B,
+ "<service type=\"%d\">"
+ "<name>%s</name>",
+ S->type,
+ S->name ? S->name : "");
Util_stringbuffer(B,
- "<service name=\"%s\">"
- "<collected_sec>%ld</collected_sec>"
- "<collected_usec>%ld</collected_usec>"
- "<type>%d</type>"
- "<status>%llu</status>"
- "<status_hint>%llu</status_hint>"
- "<monitor>%d</monitor>"
- "<monitormode>%d</monitormode>"
- "<pendingaction>%d</pendingaction>",
- S->name ? S->name : "",
- S->collected.tv_sec,
- S->collected.tv_usec,
- S->type,
- S->error,
- S->error_hint,
- S->monitor,
- S->mode,
- S->doaction);
+ "<collected_sec>%ld</collected_sec>"
+ "<collected_usec>%ld</collected_usec>"
+ "<status>%llu</status>"
+ "<status_hint>%llu</status_hint>"
+ "<monitor>%d</monitor>"
+ "<monitormode>%d</monitormode>"
+ "<pendingaction>%d</pendingaction>",
+ S->collected.tv_sec,
+ S->collected.tv_usec,
+ S->error,
+ S->error_hint,
+ S->monitor,
+ S->mode,
+ S->doaction);
/* if the service is in error state, display first active error message
to provide more details */
while (E) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [monit-dev] [monit] r225 committed - [No log message],
monit <=