[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Another 4.0 problem!
From: |
Jan-Henrik Haukeland |
Subject: |
Re: Another 4.0 problem! |
Date: |
Thu, 18 Sep 2003 17:31:26 +0200 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, linux) |
Christian Hopp <address@hidden> writes:
> Now I have tried a much smaller and simpler monitrc (just 7
> check... compared to 78 in my real-life server monitrc)... and it
> works perfectly fine! Any idea????
it could be that we should try reading smaller chunks from the
socket. This BIGSTRLEN soultion is not good at all, especially when
you have a big monitrc file. Try replacing remote_status() with this
simple one:
/**
* Get the service status for the given service from a monit server
* @param p A Service_T object
* @return TRUE if the monit server could be connected
*/
static int remote_status(Service_T s) {
ASSERT(s);
if(exist_daemon()) {
/* If a monit daemon exist we request status information from the server */
Socket_T sock= socket_new(Run.bind_addr?Run.bind_addr:"localhost",
Run.httpdport, SOCKET_TCP, Run.httpdssl);
if(!sock) {
log("%s: error connecting to the monit daemon\n", prog);
return FALSE;
} else {
int n;
char buf[STRLEN];
char *auth= get_basic_authentication_header();
socket_print(sock, "GET /%s?action=status HTTP/1.0\r\n%s\r\n",
s->name, auth);
free(auth);
while((0 < (n= socket_read(sock, buf, STRLEN)))) {
buf[n]= 0;
fprintf(stdout, "%s", buf);
}
socket_free(&sock);
return TRUE;
}
} else {
/* No monit daemon exist, just print local status information */
local_status(s);
return FALSE;
}
}
PS. I also think that you should revert the changes you did to socket,
where you replaced void *p with char *p and so on. It's probably
nothing, but if void * and char * is not the same size it may be a
problem.
--
Jan-Henrik Haukeland