/[monit]/monit/status.c
ViewVC logotype

Diff of /monit/status.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.46 by chopp, Wed Sep 17 15:33:35 2003 UTC revision 1.47 by hauk, Thu Sep 18 15:50:34 2003 UTC
# Line 251  static int remote_status(Service_T s) { Line 251  static int remote_status(Service_T s) {
251                                Run.httpdport, SOCKET_TCP, Run.httpdssl);                                Run.httpdport, SOCKET_TCP, Run.httpdssl);
252      if(!sock) {      if(!sock) {
253                
254        local_status(s);        log("%s: error connecting to the monit daemon\n", prog);
255                
256        return FALSE;        return FALSE;
257                
258      } else {      } else {
259    
260        int n;        int n;
261        char buf[BIGSTRLEN];        char buf[STRLEN];
262        char *auth= get_basic_authentication_header();        char *auth= get_basic_authentication_header();
263    
264        socket_print(sock, "GET /%s?action=status HTTP/1.0\r\n%s\r\n",        socket_print(sock, "GET /%s?action=status HTTP/1.0\r\n%s\r\n",
265                     s->name, auth);                     s->name, auth);
266        free(auth);        free(auth);
267          
268        if(0>(n= socket_read(sock, buf, BIGSTRLEN))) {        while((0 < (n= socket_read(sock, buf, STRLEN)))) {
269                    buf[n]= 0;
270          local_status(s);          fprintf(stdout, "%s", buf);
         socket_free(&sock);  
           
         return TRUE;  
           
271        }        }
272                
273        socket_free(&sock);        socket_free(&sock);
           
   
       /* If everything has gone well the returned string starts with  
          "Process ", "Device ", "File " or "Directory " */  
         
       buf[n]= 0;  
       if(starts_with(buf, "Process ") ||  
          starts_with(buf, "Device ") ||  
          starts_with(buf, "File ") ||  
          starts_with(buf, "Directory") ||  
          starts_with(buf, "Host")) {  
           
         fprintf(stdout, "%s", buf);  
           
       } else {  
   
         fprintf(stdout, "The monit server did not return a process, "  
           "device, file, directory or host record.\n");  
         local_status(s);  
274            
       }  
   
275        return TRUE;        return TRUE;
276    
277      }      }
278            
279    } else {    } else {

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26