/[monit]/monit/http/cervlet.c
ViewVC logotype

Diff of /monit/http/cervlet.c

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

revision 1.197 by martinp, Fri Nov 11 12:50:13 2005 UTC revision 1.198 by martinp, Fri Nov 18 22:52:40 2005 UTC
# Line 114  static void print_service_rules_size(Htt Line 114  static void print_service_rules_size(Htt
114  static void print_service_rules_match(HttpResponse, Service_T);  static void print_service_rules_match(HttpResponse, Service_T);
115  static void print_service_rules_checksum(HttpResponse, Service_T);  static void print_service_rules_checksum(HttpResponse, Service_T);
116  static void print_service_rules_process(HttpResponse, Service_T);  static void print_service_rules_process(HttpResponse, Service_T);
117    static void print_service_rules_resource(HttpResponse, Service_T);
118  static void print_service_params_port(HttpResponse, Service_T);  static void print_service_params_port(HttpResponse, Service_T);
119  static void print_service_params_icmp(HttpResponse, Service_T);  static void print_service_params_icmp(HttpResponse, Service_T);
120  static void print_service_params_perm(HttpResponse, Service_T);  static void print_service_params_perm(HttpResponse, Service_T);
# Line 125  static void print_service_params_size(Ht Line 126  static void print_service_params_size(Ht
126  static void print_service_params_match(HttpResponse, Service_T);  static void print_service_params_match(HttpResponse, Service_T);
127  static void print_service_params_checksum(HttpResponse, Service_T);  static void print_service_params_checksum(HttpResponse, Service_T);
128  static void print_service_params_process(HttpResponse, Service_T);  static void print_service_params_process(HttpResponse, Service_T);
129    static void print_service_params_resource(HttpResponse, Service_T);
130  static void print_status(HttpRequest, HttpResponse);  static void print_status(HttpRequest, HttpResponse);
131  static void status_service_txt(Service_T, HttpResponse, short);  static void status_service_txt(Service_T, HttpResponse, short);
132  static char *get_service_status_html(Service_T);  static char *get_service_status_html(Service_T);
# Line 267  static void do_home(HttpRequest req, Htt Line 269  static void do_home(HttpRequest req, Htt
269    
270    FREE(uptime);    FREE(uptime);
271        
272    if(Run.doprocess) {    do_home_system(req, res);
     do_home_system(req, res);  
   }  
273    do_home_process(req, res);    do_home_process(req, res);
274    do_home_device(req, res);    do_home_device(req, res);
275    do_home_file(req, res);    do_home_file(req, res);
# Line 707  static void do_service(HttpRequest req, Line 707  static void do_service(HttpRequest req,
707        "<tr>"        "<tr>"
708        "<td>Name</td>"        "<td>Name</td>"
709        "<td>%s</td>"        "<td>%s</td>"
       "</tr>"  
       "<tr>"  
       "<td>%s</td>"  
       "<td>%s</td>"  
710        "</tr>",        "</tr>",
711        servicetypes[s->type],        servicetypes[s->type],
712        s->name,        s->name);
713        pathnames[s->type],  
714        s->path);      if(s->path && *s->path)
715          out_print(res,
716            "<tr>"
717            "<td>%s</td>"
718            "<td>%s</td>"
719            "</tr>",
720            pathnames[s->type],
721            s->path);
722    
723      status= get_service_status_html(s);      status= get_service_status_html(s);
724      out_print(res,      out_print(res,
# Line 790  static void do_service(HttpRequest req, Line 793  static void do_service(HttpRequest req,
793      print_service_params_match(res, s);      print_service_params_match(res, s);
794      print_service_params_checksum(res, s);      print_service_params_checksum(res, s);
795      print_service_params_process(res, s);      print_service_params_process(res, s);
796        print_service_params_resource(res, s);
797    
798      /* Rules */      /* Rules */
799      print_service_rules_icmp(res, s);      print_service_rules_icmp(res, s);
# Line 803  static void do_service(HttpRequest req, Line 807  static void do_service(HttpRequest req,
807      print_service_rules_match(res, s);      print_service_rules_match(res, s);
808      print_service_rules_checksum(res, s);      print_service_rules_checksum(res, s);
809      print_service_rules_process(res, s);      print_service_rules_process(res, s);
810        print_service_rules_resource(res, s);
811    
812      print_alerts(res, s->maillist);      print_alerts(res, s->maillist);
813    
# Line 849  static void not_found(HttpRequest req, H Line 854  static void not_found(HttpRequest req, H
854    
855  static void do_home_system(HttpRequest req, HttpResponse res) {  static void do_home_system(HttpRequest req, HttpResponse res) {
856        
857      char      *status;
858      Service_T  s = Run.system;
859    
860      status= get_service_status_html(s);
861    
862    out_print(res,    out_print(res,
863      "<br><p>&nbsp;</p>"      "<br><p>&nbsp;</p>"
864      "<table cellspacing=0 cellpadding=3 border=0 width=\"70%%\">"      "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
865      "<tr>"      "<tr>"
866      "<td width=\"20%%\"><h3><b>System</b></h3></td>"      "<td width=\"20%%\"><h3><b>System</b></h3></td>"
867      "<td align=\"right\"><h3><b>Load</b></h3></td>"      "<td align=\"left\"><h3><b>Status</b></h3></td>");
868      "<td align=\"right\"><h3><b>CPU</b></h3></td>"  
869      "<td align=\"right\"><h3><b>Memory</b></h3></td>"    if(Run.doprocess) {
870        out_print(res,
871          "<td align=\"right\"><h3><b>Load</b></h3></td>"
872          "<td align=\"right\"><h3><b>CPU</b></h3></td>"
873          "<td align=\"right\"><h3><b>Memory</b></h3></td>");
874      }
875    
876      out_print(res,
877      "</tr>"      "</tr>"
878      "<tr bgcolor=\"#EFEFEF\">"      "<tr bgcolor=\"#EFEFEF\">"
879      "<td align=\"left\">%s</td>"      "<td align=\"left\"><a href='/%s'>%s</a></td>"
880      "<td align=\"right\" width=\"20%%\">[%.2f]&nbsp;[%.2f]&nbsp;[%.2f]</td>"      "<td align=\"left\">%s</td>",
881      "<td align=\"right\" width=\"20%%\">"      s->name, s->name,
882        status);
883      FREE(status);
884    
885      if(Run.doprocess) {
886        out_print(res,
887          "<td align=\"right\" width=\"20%%\">[%.2f]&nbsp;[%.2f]&nbsp;[%.2f]</td>"
888          "<td align=\"right\" width=\"20%%\">"
889        "%.1f%%us,&nbsp;%.1f%%sy"        "%.1f%%us,&nbsp;%.1f%%sy"
890    #ifdef HAVE_CPU_WAIT      #ifdef HAVE_CPU_WAIT
891        ",&nbsp;%.1f%%wa"        ",&nbsp;%.1f%%wa"
892    #endif      #endif
893      "</td>"        "</td>"
894      "<td align=\"right\" width=\"20%%\">%.1f%% [%ld&nbsp;kB]</td>"        "<td align=\"right\" width=\"20%%\">%.1f%% [%ld&nbsp;kB]</td>",
895          systeminfo.loadavg[0], systeminfo.loadavg[1], systeminfo.loadavg[2],
896          systeminfo.total_cpu_user_percent/10., systeminfo.total_cpu_syst_percent/10.,
897        #ifdef HAVE_CPU_WAIT
898          systeminfo.total_cpu_wait_percent/10.,
899        #endif
900          systeminfo.total_mem_percent/10., systeminfo.total_mem_kbyte);
901      }
902    
903      out_print(res,
904      "</tr>"      "</tr>"
905      "</table>",      "</table>");
     Run.localhostname,  
     systeminfo.loadavg[0], systeminfo.loadavg[1], systeminfo.loadavg[2],  
     systeminfo.total_cpu_user_percent/10.,  
     systeminfo.total_cpu_syst_percent/10.,  
   #ifdef HAVE_CPU_WAIT  
     systeminfo.total_cpu_wait_percent/10.,  
   #endif  
     systeminfo.total_mem_percent/10.,  
     systeminfo.total_mem_kbyte);  
       
906  }  }
907    
908    
# Line 898  static void do_home_process(HttpRequest Line 921  static void do_home_process(HttpRequest
921                
922        out_print(res,        out_print(res,
923          "<br><p>&nbsp;</p>"          "<br><p>&nbsp;</p>"
924          "<table cellspacing=0 cellpadding=3 border=0 width=\"70%%\">"          "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
925          "<tr>"          "<tr>"
926          "<td width=\"20%%\"><h3><b>Process</b></h3></td>"          "<td width=\"20%%\"><h3><b>Process</b></h3></td>"
927          "<td align=\"left\"><h3><b>Status</b></h3></td>"          "<td align=\"left\"><h3><b>Status</b></h3></td>"
# Line 985  static void do_home_device(HttpRequest r Line 1008  static void do_home_device(HttpRequest r
1008                
1009        out_print(res,        out_print(res,
1010          "<br><p>&nbsp;</p>"          "<br><p>&nbsp;</p>"
1011          "<table cellspacing=0 cellpadding=3 border=0 width=\"70%%\">"          "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
1012          "<tr>"          "<tr>"
1013          "<td width=\"20%%\"><h3><b>Device</b></h3></td>"          "<td width=\"20%%\"><h3><b>Device</b></h3></td>"
1014          "<td align=\"left\"><h3><b>Status</b></h3></td>"          "<td align=\"left\"><h3><b>Status</b></h3></td>"
# Line 1064  static void do_home_file(HttpRequest req Line 1087  static void do_home_file(HttpRequest req
1087                
1088        out_print(res,        out_print(res,
1089          "<br><p>&nbsp;</p>"          "<br><p>&nbsp;</p>"
1090          "<table cellspacing=0 cellpadding=3 border=0 width=\"70%%\">"          "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
1091          "<tr>"          "<tr>"
1092          "<td width=\"20%%\"><h3><b>File</b></h3></td>"          "<td width=\"20%%\"><h3><b>File</b></h3></td>"
1093          "<td align=\"left\"><h3><b>Status</b></h3></td>"          "<td align=\"left\"><h3><b>Status</b></h3></td>"
# Line 1137  static void do_home_directory(HttpReques Line 1160  static void do_home_directory(HttpReques
1160    
1161        out_print(res,        out_print(res,
1162          "<br><p>&nbsp;</p>"          "<br><p>&nbsp;</p>"
1163          "<table cellspacing=0 cellpadding=3 border=0 width=\"70%%\">"          "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
1164          "<tr>"          "<tr>"
1165          "<td width=\"20%%\"><h3><b>Directory</b></h3></td>"          "<td width=\"20%%\"><h3><b>Directory</b></h3></td>"
1166          "<td align=\"left\"><h3><b>Status</b></h3></td>"          "<td align=\"left\"><h3><b>Status</b></h3></td>"
# Line 1208  static void do_home_host(HttpRequest req Line 1231  static void do_home_host(HttpRequest req
1231                
1232        out_print(res,        out_print(res,
1233          "<br><p>&nbsp;</p>"          "<br><p>&nbsp;</p>"
1234          "<table cellspacing=0 cellpadding=3 border=0 width=\"70%%\">"          "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
1235          "<tr>"          "<tr>"
1236          "<td width=\"20%%\"><h3><b>Host</b></h3></td>"          "<td width=\"20%%\"><h3><b>Host</b></h3></td>"
1237          "<td align=\"left\"><h3><b>Status</b></h3></td>"          "<td align=\"left\"><h3><b>Status</b></h3></td>"
# Line 1714  static void print_service_rules_checksum Line 1737  static void print_service_rules_checksum
1737    
1738  static void print_service_rules_process(HttpResponse res, Service_T s) {  static void print_service_rules_process(HttpResponse res, Service_T s) {
1739    
   char ratio1[STRLEN];  
   char ratio2[STRLEN];  
   
1740    if(s->type == TYPE_PROCESS) {    if(s->type == TYPE_PROCESS) {
1741    
1742        char ratio1[STRLEN];
1743    
1744      out_print(res, "<tr><td>Pid</td><td>If changed %s then %s</td></tr>\n",      out_print(res, "<tr><td>Pid</td><td>If changed %s then %s</td></tr>\n",
1745        Util_getEventratio(s->action_PID->failed, ratio1),        Util_getEventratio(s->action_PID->failed, ratio1),
1746        actionnames[s->action_PID->failed->id]);        actionnames[s->action_PID->failed->id]);
# Line 1725  static void print_service_rules_process( Line 1748  static void print_service_rules_process(
1748        Util_getEventratio(s->action_PPID->failed, ratio1),        Util_getEventratio(s->action_PPID->failed, ratio1),
1749        actionnames[s->action_PPID->failed->id]);        actionnames[s->action_PPID->failed->id]);
1750    }    }
1751    }
1752    
1753    
1754    static void print_service_rules_resource(HttpResponse res, Service_T s) {
1755    
1756    if(s->resourcelist) {    if(s->resourcelist) {
1757    
1758        char          ratio1[STRLEN];
1759        char          ratio2[STRLEN];
1760      Resource_T    q;      Resource_T    q;
1761      EventAction_T a;      EventAction_T a;
1762            
# Line 1751  static void print_service_rules_process( Line 1780  static void print_service_rules_process(
1780            ratio2, actionnames[a->passed->id]);            ratio2, actionnames[a->passed->id]);
1781          break;          break;
1782                        
1783          case RESOURCE_ID_CPUUSER:
1784              
1785            out_print(res,"<tr><td>CPU user limit</td>"
1786              "<td>If %s %.1f%% %s then %s "
1787              "else if passed %s then %s</td></tr>",
1788              operatornames[q->operator],
1789              q->limit/10.0,
1790              ratio1, actionnames[a->failed->id],
1791              ratio2, actionnames[a->passed->id]);
1792            break;
1793              
1794          case RESOURCE_ID_CPUSYSTEM:
1795              
1796            out_print(res,"<tr><td>CPU system limit</td>"
1797              "<td>If %s %.1f%% %s then %s "
1798              "else if passed %s then %s</td></tr>",
1799              operatornames[q->operator],
1800              q->limit/10.0,
1801              ratio1, actionnames[a->failed->id],
1802              ratio2, actionnames[a->passed->id]);
1803            break;
1804              
1805          case RESOURCE_ID_CPUWAIT:
1806              
1807            out_print(res,"<tr><td>CPU wait limit</td>"
1808              "<td>If %s %.1f%% %s then %s "
1809              "else if passed %s then %s</td></tr>",
1810              operatornames[q->operator],
1811              q->limit/10.0,
1812              ratio1, actionnames[a->failed->id],
1813              ratio2, actionnames[a->passed->id]);
1814            break;
1815              
1816        case RESOURCE_ID_MEM_PERCENT:        case RESOURCE_ID_MEM_PERCENT:
1817                        
1818          out_print(res,"<tr><td>Memory usage limit</td>"          out_print(res,"<tr><td>Memory usage limit</td>"
# Line 2147  static void print_service_params_process Line 2209  static void print_service_params_process
2209          "<tr><td>Parent process id </td><td>-</td></tr>"          "<tr><td>Parent process id </td><td>-</td></tr>"
2210          "<tr><td>Process uptime</td><td>-</td></tr>");          "<tr><td>Process uptime</td><td>-</td></tr>");
2211    
       if(Run.doprocess) {  
         out_print(res,  
           "<tr><td>CPU usage</td><td>-</td></tr>"  
           "<tr><td>Memory usage</td><td>-</td></tr>"  
           "<tr><td>Children</td><td>-</td></tr>"  
           "<tr><td>Total CPU usage (incl. children)</td><td>-</td></tr>"  
           "<tr><td>Total memory usage (incl. children)</td><td>-</td></tr>");  
       }  
   
2212      } else {      } else {
2213    
2214        char *uptime;        char *uptime;
# Line 2172  static void print_service_params_process Line 2225  static void print_service_params_process
2225          "<tr><td>Process uptime</td><td>%s</td></tr>",          "<tr><td>Process uptime</td><td>%s</td></tr>",
2226          uptime);          uptime);
2227        FREE(uptime);        FREE(uptime);
2228        }
2229      }
2230    }
2231    
2232        if(Run.doprocess) {  
2233    static void print_service_params_resource(HttpResponse res, Service_T s) {
2234    
2235      if(Run.doprocess && (s->type == TYPE_PROCESS || s->type == TYPE_SYSTEM) ) {
2236    
2237        if(!Util_hasServiceStatus(s)) {
2238          if(s->type == TYPE_PROCESS) {
2239            out_print(res,
2240              "<tr><td>CPU usage</td><td>-</td></tr>"
2241              "<tr><td>Memory usage</td><td>-</td></tr>"
2242              "<tr><td>Children</td><td>-</td></tr>"
2243              "<tr><td>Total CPU usage (incl. children)</td><td>-</td></tr>"
2244              "<tr><td>Total memory usage (incl. children)</td><td>-</td></tr>");
2245          } else if(s->type == TYPE_SYSTEM) {
2246            out_print(res,
2247              "<tr><td>Load average</td><td>-</td></tr>"
2248              "<tr><td>CPU usage</td><td>-</td></tr>"
2249              "<tr><td>Memory usage</td><td>-</td></tr>");
2250          }
2251        } else {
2252    
2253          if(s->type == TYPE_PROCESS) {
2254          out_print(res,          out_print(res,
2255            "<tr><td>CPU usage</td><td><font%s>%.1f%%</font></td></tr>",            "<tr><td>CPU usage</td><td><font%s>%.1f%%</font></td></tr>",
2256            (s->error & EVENT_RESOURCE)?" color='#ff0000'":"",            (s->error & EVENT_RESOURCE)?" color='#ff0000'":"",
# Line 2196  static void print_service_params_process Line 2273  static void print_service_params_process
2273            "<td><font%s>%.1f%% [%ldkB]</font></td></tr>",            "<td><font%s>%.1f%% [%ldkB]</font></td></tr>",
2274            (s->error & EVENT_RESOURCE)?" color='#ff0000'":"",            (s->error & EVENT_RESOURCE)?" color='#ff0000'":"",
2275            s->inf->total_mem_percent/10.0, s->inf->total_mem_kbyte);            s->inf->total_mem_percent/10.0, s->inf->total_mem_kbyte);
2276          } else if(s->type == TYPE_SYSTEM) {
2277            out_print(res,
2278              "<tr><td>Load average</td><td><font%s>[%.2f] [%.2f] [%.2f]</font></td></tr>",
2279              (s->error & EVENT_RESOURCE)?" color='#ff0000'":"",
2280              systeminfo.loadavg[0],
2281              systeminfo.loadavg[1],
2282              systeminfo.loadavg[2]);
2283            out_print(res,
2284              "<tr><td>CPU usage</td><td><font%s>%.1f%%us %.1f%%sy"
2285            #ifdef HAVE_CPU_WAIT
2286              " %.1f%%wa"
2287            #endif
2288              "%s",
2289              (s->error & EVENT_RESOURCE)?" color='#ff0000'":"",
2290              systeminfo.total_cpu_user_percent/10.,
2291              systeminfo.total_cpu_syst_percent/10.,
2292            #ifdef HAVE_CPU_WAIT
2293              systeminfo.total_cpu_wait_percent/10.,
2294            #endif
2295              "</font></td></tr>");
2296            out_print(res,
2297              "<tr><td>Memory usage</td><td><font%s>%ld kB [%.1f%%]</font></td></tr>",
2298              (s->error & EVENT_RESOURCE)?" color='#ff0000'":"",
2299              systeminfo.total_mem_kbyte,
2300              systeminfo.total_mem_percent/10.);
2301        }        }
2302      }      }
2303    }    }
# Line 2393  static void status_service_txt(Service_T Line 2495  static void status_service_txt(Service_T
2495          }          }
2496          }          }
2497        }        }
2498        if(s->type == TYPE_SYSTEM) {        if(s->type == TYPE_SYSTEM && Run.doprocess) {
2499          out_print(res,          out_print(res,
2500            "  %-33s [%.2f] [%.2f] [%.2f]\n"            "  %-33s [%.2f] [%.2f] [%.2f]\n"
2501            "  %-33s %.1f%%us %.1f%%sy"            "  %-33s %.1f%%us %.1f%%sy"

Legend:
Removed from v.1.197  
changed lines
  Added in v.1.198

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