monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[monit-dev] [monit] r207 committed - Lower memory foot print ... origina


From: monit
Subject: [monit-dev] [monit] r207 committed - Lower memory foot print ... original idea was to lower cpu usage when ...
Date: Mon, 26 Jul 2010 14:55:37 +0000

Revision: 207
Author: martin2812
Date: Mon Jul 26 07:54:50 2010
Log: Lower memory foot print ... original idea was to lower cpu usage when printing action description - since the action doesn't change, it could be cached on monit start and code could use the description instantly. The description was cached in large fixed size buffer (PATH_MAX bytes) - this requires however relatively lot of memory and ca. 60% of monit's memory usage was allocated for it. Since monit should have low memory footprint and should run on HW platforms with small memory, changing it to memory-saving way.


http://code.google.com/p/monit/source/detail?r=207

Modified:
 /trunk/http/cervlet.c
 /trunk/monitor.h
 /trunk/p.y
 /trunk/util.c
 /trunk/util.h

=======================================
--- /trunk/http/cervlet.c       Mon Jul 12 07:20:26 2010
+++ /trunk/http/cervlet.c       Mon Jul 26 07:54:50 2010
@@ -333,34 +333,34 @@

   HEAD("_runtime", "Runtime", 1000)
   out_print(res,
-           "<center><h3>Monit runtime status</h3><center><br>");
- out_print(res,"<table cellspacing=0 cellpadding=3 border=1 width=\"90%%\" style=\"border:1px solid #ccc;border-collapse:collapse;\">"
-           "<tr><td width=\"40%%\" bgcolor=\"#edf5ff\"><b>Parameter</b></td>"
-           "<td width=\"60%%\" bgcolor=\"#edf5ff\"><b>Value</b></td></tr>");
+            "<center><h3>Monit runtime status</h3><center><br>");
+ out_print(res, "<table cellspacing=0 cellpadding=3 border=1 width=\"90%%\" style=\"border:1px solid #ccc;border-collapse:collapse;\">" + "<tr><td width=\"40%%\" bgcolor=\"#edf5ff\"><b>Parameter</b></td>" + "<td width=\"60%%\" bgcolor=\"#edf5ff\"><b>Value</b></td></tr>");
   out_print(res, "<tr><td>Monit ID</td><td>%s</td></tr>", Run.id);
   out_print(res, "<tr><td>Host</td><td>%s</td></tr>",  Run.localhostname);
   out_print(res,
-           "<tr><td>Process id</td><td>%d</td></tr>", pid);
+            "<tr><td>Process id</td><td>%d</td></tr>", pid);
   out_print(res,
-           "<tr><td>Effective user running Monit</td>"
-           "<td>%s</td></tr>", Run.Env.user);
+            "<tr><td>Effective user running Monit</td>"
+            "<td>%s</td></tr>", Run.Env.user);
   out_print(res,
-           "<tr><td>Controlfile</td><td>%s</td></tr>", Run.controlfile);
+            "<tr><td>Controlfile</td><td>%s</td></tr>", Run.controlfile);
   if(Run.logfile)
     out_print(res,
-           "<tr><td>Logfile</td><td>%s</td></tr>", Run.logfile);
+            "<tr><td>Logfile</td><td>%s</td></tr>", Run.logfile);
   out_print(res,
-           "<tr><td>Pidfile</td><td>%s</td></tr>", Run.pidfile);
+            "<tr><td>Pidfile</td><td>%s</td></tr>", Run.pidfile);
   out_print(res,
-           "<tr><td>State file</td><td>%s</td></tr>", Run.statefile);
+            "<tr><td>State file</td><td>%s</td></tr>", Run.statefile);
   out_print(res,
-           "<tr><td>Debug</td><td>%s</td></tr>",
-           Run.debug?"True":"False");
+            "<tr><td>Debug</td><td>%s</td></tr>",
+            Run.debug?"True":"False");
   out_print(res,
-           "<tr><td>Log</td><td>%s</td></tr>", Run.dolog?"True":"False");
+            "<tr><td>Log</td><td>%s</td></tr>", Run.dolog?"True":"False");
   out_print(res,
-           "<tr><td>Use syslog</td><td>%s</td></tr>",
-           Run.use_syslog?"True":"False");
+            "<tr><td>Use syslog</td><td>%s</td></tr>",
+            Run.use_syslog?"True":"False");

   if(Run.eventlist_dir) {
     char slots[STRLEN];
@@ -396,71 +396,71 @@
     MailServer_T mta= Run.mailservers;
     out_print(res, "<tr><td>Mail server(s)</td><td>");
     for(mta= Run.mailservers; mta; mta= mta->next)
-       out_print(res, "%s:%d%s&nbsp;",
+        out_print(res, "%s:%d%s&nbsp;",
           mta->host, mta->port, mta->ssl.use_ssl?"(ssl)":"");
     out_print(res, "</td></tr>");
   }

   if(Run.MailFormat.from)
     out_print(res,
-           "<tr><td>Default mail from</td><td>%s</td></tr>",
-           Run.MailFormat.from);
+            "<tr><td>Default mail from</td><td>%s</td></tr>",
+            Run.MailFormat.from);
   if(Run.MailFormat.subject)
     out_print(res,
-           "<tr><td>Default mail subject</td><td>%s</td></tr>",
-           Run.MailFormat.subject);
+            "<tr><td>Default mail subject</td><td>%s</td></tr>",
+            Run.MailFormat.subject);
   if(Run.MailFormat.message)
     out_print(res,
-           "<tr><td>Default mail message</td><td>%s</td></tr>",
+            "<tr><td>Default mail message</td><td>%s</td></tr>",
             Run.MailFormat.message);

   out_print(res,
- "<tr><td>Poll time</td><td>%d seconds with start delay %d seconds</td></tr>",
-           Run.polltime, Run.startdelay);
+ "<tr><td>Poll time</td><td>%d seconds with start delay %d seconds</td></tr>",
+            Run.polltime, Run.startdelay);
   out_print(res,
-           "<tr><td>httpd bind address</td><td>%s</td></tr>",
-           Run.bind_addr?Run.bind_addr:"Any/All");
+            "<tr><td>httpd bind address</td><td>%s</td></tr>",
+            Run.bind_addr?Run.bind_addr:"Any/All");
   out_print(res,
-           "<tr><td>httpd portnumber</td><td>%d</td></tr>", Run.httpdport);
+ "<tr><td>httpd portnumber</td><td>%d</td></tr>", Run.httpdport);
   out_print(res,
-           "<tr><td>httpd signature</td><td>%s</td></tr>",
-           Run.httpdsig?"True":"False");
+            "<tr><td>httpd signature</td><td>%s</td></tr>",
+            Run.httpdsig?"True":"False");
   out_print(res,
-           "<tr><td>Use ssl encryption</td><td>%s</td></tr>",
-           Run.httpdssl?"True":"False");
+            "<tr><td>Use ssl encryption</td><td>%s</td></tr>",
+            Run.httpdssl?"True":"False");
   if (Run.httpdssl) {
     out_print(res,
-             "<tr><td>PEM key/certificate file</td><td>%s</td></tr>",
-             Run.httpsslpem);
+              "<tr><td>PEM key/certificate file</td><td>%s</td></tr>",
+              Run.httpsslpem);

     if (Run.httpsslclientpem!=NULL) {
       out_print(res,
-               "<tr><td>Client PEM key/certification"
-               "</td><td>%s</td></tr>", "Enabled");
+                "<tr><td>Client PEM key/certification"
+                "</td><td>%s</td></tr>", "Enabled");
       out_print(res,
-               "<tr><td>Client PEM key/certificate file"
-               "</td><td>%s</td></tr>", Run.httpsslclientpem);
+                "<tr><td>Client PEM key/certificate file"
+                "</td><td>%s</td></tr>", Run.httpsslclientpem);
     } else {
       out_print(res,
-               "<tr><td>Client PEM key/certification"
-               "</td><td>%s</td></tr>", "Disabled");
+                "<tr><td>Client PEM key/certification"
+                "</td><td>%s</td></tr>", "Disabled");
     }
     out_print(res,
-             "<tr><td>Allow self certified certificates "
-             "</td><td>%s</td></tr>", Run.allowselfcert?"True":"False");
+              "<tr><td>Allow self certified certificates "
+              "</td><td>%s</td></tr>", Run.allowselfcert?"True":"False");
   }

   out_print(res,
-           "<tr><td>httpd auth. style</td><td>%s</td></tr>",
-           (Run.credentials!=NULL)&&(has_hosts_allow())?
-           "Basic Authentication and Host/Net allow list":
-           (Run.credentials!=NULL)?"Basic Authentication":
-           (has_hosts_allow())?"Host/Net allow list":
-           "No authentication");
+            "<tr><td>httpd auth. style</td><td>%s</td></tr>",
+            (Run.credentials!=NULL)&&(has_hosts_allow())?
+            "Basic Authentication and Host/Net allow list":
+            (Run.credentials!=NULL)?"Basic Authentication":
+            (has_hosts_allow())?"Host/Net allow list":
+            "No authentication");

   print_alerts(res, Run.maillist);

-  out_print(res,"</table>");
+  out_print(res, "</table>");

   if(!is_readonly(req)) {
     out_print(res,
@@ -513,7 +513,7 @@

   if(is_readonly(req)) {
     send_error(res, SC_FORBIDDEN,
-              "You do not have sufficent privileges to access this page");
+               "You do not have sufficent privileges to access this page");
     return;
   }

@@ -527,28 +527,28 @@

       FILE *f= fopen(Run.logfile, "r");
       if(f) {
-
+
         #define BUFSIZE 8192

-       int n;
-       char buf[BUFSIZE+1];
-
-       out_print(res, "<br><p><form><textarea cols=120 rows=30 readonly>");
-
-       while((n= fread(buf, sizeof(char), BUFSIZE, f)) > 0) {
-
-         buf[n]= 0;
-         out_print(res, "%s", buf);
-
-       }
-
+        int n;
+        char buf[BUFSIZE+1];
+
+ out_print(res, "<br><p><form><textarea cols=120 rows=30 readonly>");
+
+        while((n= fread(buf, sizeof(char), BUFSIZE, f)) > 0) {
+
+          buf[n]= 0;
+          out_print(res, "%s", buf);
+
+        }
+
         fclose(f);
-       out_print(res, "</textarea></form>");
-
+        out_print(res, "</textarea></form>");
+
       } else {
-
-       out_print(res, "Error opening logfile: %s", STRERROR);
-
+
+        out_print(res, "Error opening logfile: %s", STRERROR);
+
       }

     } else {
@@ -715,9 +715,7 @@
   ServiceGroupMember_T sgm;
   char *svc;
   char *status;
-  char time[STRLEN];
-  char ratio1[STRLEN];
-  char ratio2[STRLEN];
+  char buf[STRLEN];

   ASSERT(s);

@@ -801,9 +799,10 @@
   }

   if(s->type != TYPE_SYSTEM) {
- out_print(res, "<tr><td>Existence</td><td>If doesn't exist %s then %s else if succeeded %s then %s</td></tr>", - Util_getEventratio(s->action_NONEXIST->failed, ratio1), s->action_NONEXIST->failed->description, - Util_getEventratio(s->action_NONEXIST->succeeded, ratio2), s->action_NONEXIST->succeeded->description); + out_print(res, "<tr><td>Existence</td><td>If doesn't exist %s ", Util_getEventratio(s->action_NONEXIST->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(s->action_NONEXIST->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(s->action_NONEXIST->succeeded, buf, sizeof(buf))); + out_print(res, "then %s</td></tr>", Util_describeAction(s->action_NONEXIST->succeeded, buf, sizeof(buf)));
   }

   out_print(res,
@@ -811,12 +810,12 @@
     s->every?s->every:1);

   for (ar = s->actionratelist; ar; ar = ar->next)
- out_print(res, "<tr><td>Timeout</td><td>If restarted %d times within %d cycle(s) then %s</td></tr>", ar->count, ar->cycle, ar->action->failed->description);
-
-  ctime_r((const time_t *)&s->collected.tv_sec, time);
+ out_print(res, "<tr><td>Timeout</td><td>If restarted %d times within %d cycle(s) then %s</td></tr>", ar->count, ar->cycle, Util_describeAction(ar->action->failed, buf, sizeof(buf)));
+
+  ctime_r((const time_t *)&s->collected.tv_sec, buf);
   out_print(res,
     "<tr><td>Data collected</td><td>%s</td></tr>",
-    time);
+    buf);

   /* Parameters */
   print_service_params_icmp(res, s);
@@ -1001,13 +1000,13 @@

       if(Run.doprocess) {
         out_print(res,
-         "<td align=\"right\"><font%s>%.1f%%</font></td>",
+          "<td align=\"right\"><font%s>%.1f%%</font></td>",
           (s->error & EVENT_RESOURCE)?" color='#ff0000'":"",
-         s->inf->cpu_percent/10.0);
+          s->inf->cpu_percent/10.0);
         out_print(res,
-         "<td align=\"right\"><font%s>%.1f%% [%ld&nbsp;kB]</font></td></tr>",
+ "<td align=\"right\"><font%s>%.1f%% [%ld&nbsp;kB]</font></td></tr>",
           (s->error & EVENT_RESOURCE)?" color='#ff0000'":"",
-         s->inf->mem_percent/10.0, s->inf->mem_kbyte);
+          s->inf->mem_percent/10.0, s->inf->mem_kbyte);
       }

     }
@@ -1038,14 +1037,14 @@
     if(header) {

       out_print(res,
-       "<br><p>&nbsp;</p>"
-       "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
-       "<tr>"
-       "<td width=\"20%%\"><h3><b>Filesystem</b></h3></td>"
-       "<td align=\"left\"><h3><b>Status</b></h3></td>"
-       "<td align=\"right\"><h3><b>Space usage</b></h3></td>"
-       "<td align=\"right\"><h3><b>Inodes usage</b></h3></td>"
-       "</tr>");
+        "<br><p>&nbsp;</p>"
+        "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
+        "<tr>"
+        "<td width=\"20%%\"><h3><b>Filesystem</b></h3></td>"
+        "<td align=\"left\"><h3><b>Status</b></h3></td>"
+        "<td align=\"right\"><h3><b>Space usage</b></h3></td>"
+        "<td align=\"right\"><h3><b>Inodes usage</b></h3></td>"
+        "</tr>");

       header= FALSE;

@@ -1066,27 +1065,27 @@
     if(!Util_hasServiceStatus(s)) {

       out_print(res,
-       "<td align=\"right\">- [-]</td>"
-       "<td align=\"right\">- [-]</td>");
+        "<td align=\"right\">- [-]</td>"
+        "<td align=\"right\">- [-]</td>");

     } else {

       out_print(res,
-       "<td align=\"right\">%.1f%% [%.1f&nbsp;MB]</td>",
+        "<td align=\"right\">%.1f%% [%.1f&nbsp;MB]</td>",
         s->inf->space_percent/10.,
-       (float)s->inf->space_total / (float)1048576 * (float)s->inf->f_bsize);
+ (float)s->inf->space_total / (float)1048576 * (float)s->inf->f_bsize);

       if(s->inf->f_files > 0) {

         out_print(res,
-         "<td align=\"right\">%.1f%% [%ld&nbsp;objects]</td>",
+          "<td align=\"right\">%.1f%% [%ld&nbsp;objects]</td>",
           s->inf->inode_percent/10.,
-         s->inf->inode_total);
+          s->inf->inode_total);

       } else {

         out_print(res,
-         "<td align=\"right\">not supported by filesystem</td>");
+          "<td align=\"right\">not supported by filesystem</td>");

       }

@@ -1119,16 +1118,16 @@
     if(header) {

       out_print(res,
-       "<br><p>&nbsp;</p>"
-       "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
-       "<tr>"
-       "<td width=\"20%%\"><h3><b>File</b></h3></td>"
-       "<td align=\"left\"><h3><b>Status</b></h3></td>"
-       "<td align=\"right\"><h3><b>Size</b></h3></td>"
-       "<td align=\"right\"><h3><b>Permission</b></h3></td>"
-       "<td align=\"right\"><h3><b>UID</b></h3></td>"
-       "<td align=\"right\"><h3><b>GID</b></h3></td>"
-       "</tr>");
+        "<br><p>&nbsp;</p>"
+        "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
+        "<tr>"
+        "<td width=\"20%%\"><h3><b>File</b></h3></td>"
+        "<td align=\"left\"><h3><b>Status</b></h3></td>"
+        "<td align=\"right\"><h3><b>Size</b></h3></td>"
+        "<td align=\"right\"><h3><b>Permission</b></h3></td>"
+        "<td align=\"right\"><h3><b>UID</b></h3></td>"
+        "<td align=\"right\"><h3><b>GID</b></h3></td>"
+        "</tr>");

       header= FALSE;

@@ -1149,22 +1148,22 @@
     if(!Util_hasServiceStatus(s)) {

       out_print(res,
-       "<td align=\"right\">-</td>"
-       "<td align=\"right\">-</td>"
-       "<td align=\"right\">-</td>"
-       "<td align=\"right\">-</td>");
+        "<td align=\"right\">-</td>"
+        "<td align=\"right\">-</td>"
+        "<td align=\"right\">-</td>"
+        "<td align=\"right\">-</td>");

     } else {

       out_print(res,
-       "<td align=\"right\">%llu&nbsp;B</td>"
-       "<td align=\"right\">%04o</td>"
-       "<td align=\"right\">%d</td>"
-       "<td align=\"right\">%d</td>",
-       (unsigned long long)s->inf->st_size,
-       s->inf->st_mode & 07777,
-       s->inf->st_uid,
-       s->inf->st_gid);
+        "<td align=\"right\">%llu&nbsp;B</td>"
+        "<td align=\"right\">%04o</td>"
+        "<td align=\"right\">%d</td>"
+        "<td align=\"right\">%d</td>",
+        (unsigned long long)s->inf->st_size,
+        s->inf->st_mode & 07777,
+        s->inf->st_uid,
+        s->inf->st_gid);

     }

@@ -1195,15 +1194,15 @@
     if(header) {

       out_print(res,
-       "<br><p>&nbsp;</p>"
-       "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
-       "<tr>"
-       "<td width=\"20%%\"><h3><b>Fifo</b></h3></td>"
-       "<td align=\"left\"><h3><b>Status</b></h3></td>"
-       "<td align=\"right\"><h3><b>Permission</b></h3></td>"
-       "<td align=\"right\"><h3><b>UID</b></h3></td>"
-       "<td align=\"right\"><h3><b>GID</b></h3></td>"
-       "</tr>");
+        "<br><p>&nbsp;</p>"
+        "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
+        "<tr>"
+        "<td width=\"20%%\"><h3><b>Fifo</b></h3></td>"
+        "<td align=\"left\"><h3><b>Status</b></h3></td>"
+        "<td align=\"right\"><h3><b>Permission</b></h3></td>"
+        "<td align=\"right\"><h3><b>UID</b></h3></td>"
+        "<td align=\"right\"><h3><b>GID</b></h3></td>"
+        "</tr>");

       header= FALSE;

@@ -1224,19 +1223,19 @@
     if(!Util_hasServiceStatus(s)) {

       out_print(res,
-       "<td align=\"right\">-</td>"
-       "<td align=\"right\">-</td>"
-       "<td align=\"right\">-</td>");
+        "<td align=\"right\">-</td>"
+        "<td align=\"right\">-</td>"
+        "<td align=\"right\">-</td>");

     } else {

       out_print(res,
-       "<td align=\"right\">%o</td>"
-       "<td align=\"right\">%d</td>"
-       "<td align=\"right\">%d</td>",
-       s->inf->st_mode & 07777,
-       s->inf->st_uid,
-       s->inf->st_gid);
+        "<td align=\"right\">%o</td>"
+        "<td align=\"right\">%d</td>"
+        "<td align=\"right\">%d</td>",
+        s->inf->st_mode & 07777,
+        s->inf->st_uid,
+        s->inf->st_gid);

     }

@@ -1267,15 +1266,15 @@
     if(header) {

       out_print(res,
-       "<br><p>&nbsp;</p>"
-       "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
-       "<tr>"
-       "<td width=\"20%%\"><h3><b>Directory</b></h3></td>"
-       "<td align=\"left\"><h3><b>Status</b></h3></td>"
-       "<td align=\"right\"><h3><b>Permission</b></h3></td>"
-       "<td align=\"right\"><h3><b>UID</b></h3></td>"
-       "<td align=\"right\"><h3><b>GID</b></h3></td>"
-       "</tr>");
+        "<br><p>&nbsp;</p>"
+        "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
+        "<tr>"
+        "<td width=\"20%%\"><h3><b>Directory</b></h3></td>"
+        "<td align=\"left\"><h3><b>Status</b></h3></td>"
+        "<td align=\"right\"><h3><b>Permission</b></h3></td>"
+        "<td align=\"right\"><h3><b>UID</b></h3></td>"
+        "<td align=\"right\"><h3><b>GID</b></h3></td>"
+        "</tr>");

       header= FALSE;

@@ -1296,19 +1295,19 @@
     if(!Util_hasServiceStatus(s)) {

       out_print(res,
-       "<td align=\"right\">-</td>"
-       "<td align=\"right\">-</td>"
-       "<td align=\"right\">-</td>");
+        "<td align=\"right\">-</td>"
+        "<td align=\"right\">-</td>"
+        "<td align=\"right\">-</td>");

     } else {

       out_print(res,
-       "<td align=\"right\">%o</td>"
-       "<td align=\"right\">%d</td>"
-       "<td align=\"right\">%d</td>",
-       s->inf->st_mode & 07777,
-       s->inf->st_uid,
-       s->inf->st_gid);
+        "<td align=\"right\">%o</td>"
+        "<td align=\"right\">%d</td>"
+        "<td align=\"right\">%d</td>",
+        s->inf->st_mode & 07777,
+        s->inf->st_uid,
+        s->inf->st_gid);

     }

@@ -1341,13 +1340,13 @@
     if(header) {

       out_print(res,
-       "<br><p>&nbsp;</p>"
-       "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
-       "<tr>"
-       "<td width=\"20%%\"><h3><b>Host</b></h3></td>"
-       "<td align=\"left\"><h3><b>Status</b></h3></td>"
-       "<td align=\"right\"><h3><b>Protocol(s)</b></h3></td>"
-       "</tr>");
+        "<br><p>&nbsp;</p>"
+        "<table cellspacing=0 cellpadding=3 border=0 width=\"90%%\">"
+        "<tr>"
+        "<td width=\"20%%\"><h3><b>Host</b></h3></td>"
+        "<td align=\"left\"><h3><b>Status</b></h3></td>"
+        "<td align=\"right\"><h3><b>Protocol(s)</b></h3></td>"
+        "</tr>");

       header= FALSE;

@@ -1377,9 +1376,9 @@

       if(s->icmplist) {
         for(icmp= s->icmplist; icmp; icmp= icmp->next) {
-         if(icmp != s->icmplist)
-           out_print(res, "&nbsp;&nbsp;<b>|</b>&nbsp;&nbsp;");
-         out_print(res, "<font%s>[ICMP %s]</font>",
+          if(icmp != s->icmplist)
+            out_print(res, "&nbsp;&nbsp;<b>|</b>&nbsp;&nbsp;");
+          out_print(res, "<font%s>[ICMP %s]</font>",
             (icmp->is_available)?"":" color='#ff0000'",
             icmpnames[icmp->type]);
         }
@@ -1390,9 +1389,9 @@

       if(s->portlist) {
         for(port= s->portlist; port; port= port->next) {
-         if(port != s->portlist)
-           out_print(res, "&nbsp;&nbsp;<b>|</b>&nbsp;&nbsp;");
-         out_print(res, "<font%s>[%s] at port %d</font>",
+          if(port != s->portlist)
+            out_print(res, "&nbsp;&nbsp;<b>|</b>&nbsp;&nbsp;");
+          out_print(res, "<font%s>[%s] at port %d</font>",
             (port->is_available)?"":" color='#ff0000'",
             port->protocol->name, port->port);
         }
@@ -1423,8 +1422,8 @@

   for(r= s; r; r= r->next) {
     out_print(res,
-             "<tr bgcolor=\"#EFEFEF\"><td>Alert mail to</td>"
-             "<td>%s</td></tr>", r->to?r->to:"");
+              "<tr bgcolor=\"#EFEFEF\"><td>Alert mail to</td>"
+              "<td>%s</td></tr>", r->to?r->to:"");
     out_print(res, "<tr><td>Alert on</td><td>");

     if(r->events == EVENT_NULL) {
@@ -1433,45 +1432,45 @@
       out_print(res, "All events");
     } else {
       if(IS_EVENT_SET(r->events, EVENT_ACTION))
-         out_print(res, "Action ");
+          out_print(res, "Action ");
       if(IS_EVENT_SET(r->events, EVENT_CHECKSUM))
-         out_print(res, "Checksum ");
+          out_print(res, "Checksum ");
       if(IS_EVENT_SET(r->events, EVENT_CONNECTION))
-         out_print(res, "Connection ");
+          out_print(res, "Connection ");
       if(IS_EVENT_SET(r->events, EVENT_CONTENT))
-         out_print(res, "Content ");
+          out_print(res, "Content ");
       if(IS_EVENT_SET(r->events, EVENT_DATA))
-         out_print(res, "Data ");
+          out_print(res, "Data ");
       if(IS_EVENT_SET(r->events, EVENT_EXEC))
-         out_print(res, "Exec ");
+          out_print(res, "Exec ");
       if(IS_EVENT_SET(r->events, EVENT_FSFLAG))
-         out_print(res, "Fsflags ");
+          out_print(res, "Fsflags ");
       if(IS_EVENT_SET(r->events, EVENT_GID))
-         out_print(res, "Gid ");
+          out_print(res, "Gid ");
       if(IS_EVENT_SET(r->events, EVENT_ICMP))
-         out_print(res, "Icmp ");
+          out_print(res, "Icmp ");
       if(IS_EVENT_SET(r->events, EVENT_INSTANCE))
           out_print(res, "Instance ");
       if(IS_EVENT_SET(r->events, EVENT_INVALID))
-         out_print(res, "Invalid ");
+          out_print(res, "Invalid ");
       if(IS_EVENT_SET(r->events, EVENT_NONEXIST))
-         out_print(res, "Nonexist ");
+          out_print(res, "Nonexist ");
       if(IS_EVENT_SET(r->events, EVENT_PERMISSION))
-         out_print(res, "Permission ");
+          out_print(res, "Permission ");
       if(IS_EVENT_SET(r->events, EVENT_PID))
-         out_print(res, "PID ");
+          out_print(res, "PID ");
       if(IS_EVENT_SET(r->events, EVENT_PPID))
-         out_print(res, "PPID ");
+          out_print(res, "PPID ");
       if(IS_EVENT_SET(r->events, EVENT_RESOURCE))
-         out_print(res, "Resource ");
+          out_print(res, "Resource ");
       if(IS_EVENT_SET(r->events, EVENT_SIZE))
-         out_print(res, "Size ");
+          out_print(res, "Size ");
       if(IS_EVENT_SET(r->events, EVENT_TIMEOUT))
-         out_print(res, "Timeout ");
+          out_print(res, "Timeout ");
       if(IS_EVENT_SET(r->events, EVENT_TIMESTAMP))
-         out_print(res, "Timestamp ");
+          out_print(res, "Timestamp ");
       if(IS_EVENT_SET(r->events, EVENT_UID))
-         out_print(res, "Uid ");
+          out_print(res, "Uid ");
     }

     out_print(res, "</td></tr>");
@@ -1503,31 +1502,31 @@
   /* Start program */
   if(s->start)
       out_print(res,
-               "<td><form method=POST action=%s>"
-               "<input type=hidden value='start' name=action>"
-               "<input type=submit value='Start service' style='font-size: "
-               "12pt'></form></td>", svc);
+                "<td><form method=POST action=%s>"
+                "<input type=hidden value='start' name=action>"
+ "<input type=submit value='Start service' style='font-size: "
+                "12pt'></form></td>", svc);
   /* Stop program */
   if(s->stop)
       out_print(res,
-               "<td><form method=POST action=%s>"
-               "<input type=hidden value='stop' name=action>"
-               "<input type=submit value='Stop service' style='font-size: "
-               "12pt'></form></td>", svc);
+                "<td><form method=POST action=%s>"
+                "<input type=hidden value='stop' name=action>"
+ "<input type=submit value='Stop service' style='font-size: "
+                "12pt'></form></td>", svc);
   /* Restart program */
   if(s->start && s->stop)
       out_print(res,
-               "<td><form method=POST action=%s>"
-               "<input type=hidden value='restart' name=action>"
-               "<input type=submit value='Restart service' style='font-size: "
-               "12pt'></form></td>", svc);
+                "<td><form method=POST action=%s>"
+                "<input type=hidden value='restart' name=action>"
+ "<input type=submit value='Restart service' style='font-size: "
+                "12pt'></form></td>", svc);
   /* (un)monitor */
   out_print(res,
-           "<td><form method=POST action=%s>"
-           "<input type=hidden value='%s' name=action>"
-           "<input type=submit value='%s' style='font-size: 12pt'>"
-           "</form></td></tr></table>",
-           svc,
+            "<td><form method=POST action=%s>"
+            "<input type=hidden value='%s' name=action>"
+            "<input type=submit value='%s' style='font-size: 12pt'>"
+            "</form></td></tr></table>",
+            svc,
             s->monitor?"unmonitor":"monitor",
             s->monitor?"Disable monitoring":"Enable monitoring");

@@ -1536,42 +1535,26 @@


 static void print_service_rules_port(HttpResponse res, Service_T s) {
-
   if(s->portlist) {
-
-    char          ratio1[STRLEN];
-    char          ratio2[STRLEN];
+    char buf[STRLEN];
     Port_T        p;
     EventAction_T a;
-
     for(p= s->portlist; p; p= p->next) {
       a= p->action;
-
-      Util_getEventratio(a->failed, ratio1);
-      Util_getEventratio(a->succeeded, ratio2);
-
       if(p->family == AF_INET) {
-        out_print(res,
-          "<tr><td>Port</td><td>"
- "If failed %s:%d%s [%s via %s] with timeout %d seconds %s then %s "
-          "else if succeeded %s then %s</td></tr>",
-          p->hostname, p->port, p->request?p->request:"",
-          p->protocol->name, Util_portTypeDescription(p),
-          p->timeout,
-          ratio1, a->failed->description,
-          ratio2, a->succeeded->description);
+ out_print(res, "<tr><td>Port</td><td>If failed %s:%d%s [%s via %s] with timeout %d seconds %s ", p->hostname, p->port, p->request ? p->request : "", p->protocol->name, Util_portTypeDescription(p), p->timeout, Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s</td></tr>", Util_describeAction(a->succeeded, buf, sizeof(buf)));
         if(p->SSL.certmd5 != NULL)
           out_print(res,
             "<tr><td>Server certificate md5 sum</td><td>%s</td></tr>",
             p->SSL.certmd5);
       } else if(p->family == AF_UNIX) {
-        out_print(res,
-          "<tr><td>Unix Socket</td><td>"
- "If failed %s [%s] with timeout %ds %s then %s else if succeeded %s then %s"
-          "</td></tr>",
-          p->pathname, p->protocol->name, p->timeout,
-          ratio1, a->failed->description,
-          ratio2, a->succeeded->description);
+ out_print(res, "<tr><td>Unix Socket</td><td>If failed %s [%s] with timeout %ds %s ", p->pathname, p->protocol->name, p->timeout, Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s</td></tr>", Util_describeAction(a->succeeded, buf, sizeof(buf)));
       }
     }
   }
@@ -1579,144 +1562,89 @@


 static void print_service_rules_icmp(HttpResponse res, Service_T s) {
-
   if(s->icmplist) {
-
-    char          ratio1[STRLEN];
-    char          ratio2[STRLEN];
+    char buf[STRLEN];
     Icmp_T        i;
     EventAction_T a;
-
     for(i= s->icmplist; i; i= i->next) {
       a= i->action;
-
-      Util_getEventratio(a->failed, ratio1);
-      Util_getEventratio(a->succeeded, ratio2);
-
-      out_print(res,
-        "<tr><td>ICMP</td><td>"
- "If failed %s count %d with timeout %d seconds %s then %s else if succeeded %s then %s"
-        "</td></tr>",
-        icmpnames[i->type], i->count, i->timeout,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
+ out_print(res, "<tr><td>ICMP</td><td>If failed %s count %d with timeout %d seconds %s ", icmpnames[i->type], i->count, i->timeout, Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s</td></tr>", Util_describeAction(a->succeeded, buf, sizeof(buf)));
     }
   }
 }


 static void print_service_rules_perm(HttpResponse res, Service_T s) {
-
   if(s->perm) {
-
-    char          ratio1[STRLEN];
-    char          ratio2[STRLEN];
+    char buf[STRLEN];
     EventAction_T a= s->perm->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
-    out_print(res, "<tr><td>Associated permission</td>"
-      "<td>If failed %o %s then %s else if succeeded %s then %s</td></tr>",
-      s->perm->perm,
-      ratio1, a->failed->description,
-      ratio2, a->succeeded->description);
-
+ out_print(res, "<tr><td>Associated permission</td><td>If failed %o %s ", s->perm->perm, Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s</td></tr>", Util_describeAction(a->succeeded, buf, sizeof(buf)));
   }
 }


 static void print_service_rules_uid(HttpResponse res, Service_T s) {
-
   if(s->uid) {
-
-    char          ratio1[STRLEN];
-    char          ratio2[STRLEN];
+    char buf[STRLEN];
     EventAction_T a= s->uid->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
-    out_print(res, "<tr><td>Associated UID</td>"
-      "<td>If failed %d %s then %s else if succeeded %s then %s</td></tr>",
-      (int)s->uid->uid,
-      ratio1, a->failed->description,
-      ratio2, a->succeeded->description);
+ out_print(res, "<tr><td>Associated UID</td><td>If failed %d %s ", (int)s->uid->uid, Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s</td></tr>", Util_describeAction(a->succeeded, buf, sizeof(buf)));
   }
 }


 static void print_service_rules_gid(HttpResponse res, Service_T s) {
-
   if(s->gid) {
-
-    char          ratio1[STRLEN];
-    char          ratio2[STRLEN];
+    char buf[STRLEN];
     EventAction_T a= s->gid->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
-    out_print(res, "<tr><td>Associated GID</td>"
-      "<td>If failed %d %s then %s else if succeeded %s then %s</td></tr>",
-      (int)s->gid->gid,
-      ratio1, a->failed->description,
-      ratio2, a->succeeded->description);
+ out_print(res, "<tr><td>Associated GID</td><td>If failed %d %s ", (int)s->gid->gid, Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s</td></tr>", Util_describeAction(a->succeeded, buf, sizeof(buf)));
   }
 }


 static void print_service_rules_timestamp(HttpResponse res, Service_T s) {
-
   if(s->timestamplist) {
-
-    char          ratio1[STRLEN];
-    char          ratio2[STRLEN];
+    char buf[STRLEN];
     Timestamp_T   t;
     EventAction_T a;
-
     for(t= s->timestamplist; t; t= t->next) {
-
       a= t->action;
-
-      Util_getEventratio(a->failed, ratio1);
-      Util_getEventratio(a->succeeded, ratio2);
-
+      out_print(res, "<tr><td>Associated timestamp</td><td>");
       if(t->test_changes) {
-
-        out_print(res,
- "<tr><td>Associated timestamp</td><td>If changed %s then %s</td></tr>",
-          ratio1, a->failed->description);
-
+ out_print(res, "If changed %s ", Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s", Util_describeAction(a->failed, buf, sizeof(buf)));
       } else {
-
-        out_print(res,
-          "<tr><td>Associated timestamp</td>"
- "<td>If %s %d second(s) %s then %s else if succeeded %s then %s</td></tr>",
-          operatornames[t->operator], t->time,
-          ratio1, a->failed->description,
-          ratio2, a->succeeded->description);
-      }
+ out_print(res, "If %s %d second(s) %s ", operatornames[t->operator], t->time, Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+      }
+      out_print(res, "</td></tr>");
     }
   }
 }


 static void print_service_rules_filesystem(HttpResponse res, Service_T s) {
+  char buf[STRLEN];

   if(s->type == TYPE_FILESYSTEM) {
-
-    char ratio1[STRLEN];
-
- out_print(res, "<tr><td>Filesystem flags</td><td>If changed %s then %s</td></tr>\n",
-      Util_getEventratio(s->action_FSFLAG->failed, ratio1),
-      s->action_FSFLAG->failed->description);
+ out_print(res, "<tr><td>Filesystem flags</td><td>If changed %s ", Util_getEventratio(s->action_FSFLAG->failed, buf, sizeof(buf))); + out_print(res, "then %s</td></tr>", Util_describeAction(s->action_FSFLAG->failed, buf, sizeof(buf)));
   }

   if(s->filesystemlist) {
-
-    char          ratio1[STRLEN];
-    char          ratio2[STRLEN];
     Filesystem_T  dl;
     EventAction_T a;

@@ -1724,48 +1652,34 @@

       a= dl->action;

-      Util_getEventratio(a->failed, ratio1);
-      Util_getEventratio(a->succeeded, ratio2);
-
       if(dl->resource == RESOURCE_ID_INODE) {
-
+        out_print(res, "<tr><td>Inodes usage limit</td><td>");
         if(dl->limit_absolute > -1) {
-          out_print(res,
-           "<tr><td>Inodes usage limit</td><td>If %s %ld %s "
-           "then %s else if succeeded %s then %s</td></tr>",
-           operatornames[dl->operator],
-           dl->limit_absolute,
-            ratio1, a->failed->description,
-            ratio2, a->succeeded->description);
+ out_print(res, "If %s %ld %s ", operatornames[dl->operator], dl->limit_absolute, Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
         } else {
-          out_print(res,
-           "<tr><td>Inodes usage limit</td><td>If %s %.1f%% %s "
-           "then %s else if succeeded %s then %s</td></tr>",
-           operatornames[dl->operator],
-           dl->limit_percent/10.,
-            ratio1, a->failed->description,
-            ratio2, a->succeeded->description);
-        }
-
+ out_print(res, "If %s %.1f%% %s ", operatornames[dl->operator], dl->limit_percent / 10., Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+        }
+        out_print(res, "</td></tr>");
       } else if(dl->resource == RESOURCE_ID_SPACE) {
-
+        out_print(res, "<tr><td>Space usage limit</td><td>");
         if(dl->limit_absolute > -1) {
-          out_print(res,
-           "<tr><td>Space usage limit</td><td>If %s %ld blocks %s "
-           "then %s else if succeeded %s then %s</td></tr>",
-            operatornames[dl->operator],
-           dl->limit_absolute,
-            ratio1, a->failed->description,
-            ratio2, a->succeeded->description);
+ out_print(res, "If %s %ld blocks %s ", operatornames[dl->operator], dl->limit_absolute, Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
         } else {
-          out_print(res,
-           "<tr><td>Space usage limit</td><td>If %s %.1f%% %s "
-           "then %s else if succeeded %s then %s</td></tr>",
-            operatornames[dl->operator],
-           dl->limit_percent/10.,
-            ratio1, a->failed->description,
-            ratio2, a->succeeded->description);
-        }
+ out_print(res, "If %s %.1f%% %s ", operatornames[dl->operator], dl->limit_percent / 10., Util_getEventratio(a->failed, buf, sizeof(buf))); + out_print(res, "then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + out_print(res, "else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + out_print(res, "then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+        }
+        out_print(res, "</td></tr>");
       }
     }
   }
@@ -1773,296 +1687,185 @@


 static void print_service_rules_size(HttpResponse res, Service_T s) {
-
   if(s->sizelist) {
-
-    char          ratio1[STRLEN];
-    char          ratio2[STRLEN];
+    char buf[STRLEN];
     Size_T        sl;
     EventAction_T a;

     for(sl= s->sizelist; sl; sl= sl->next) {
-
       a= sl->action;
-
-      Util_getEventratio(a->failed, ratio1);
-      Util_getEventratio(a->succeeded, ratio2);
-
+      out_print(res, "<tr><td>Associated size</td><td>");
       if(sl->test_changes) {
-
-        out_print(res,
- "<tr><td>Associated size</td><td>If changed %s then %s</td></tr>",
-          ratio1, a->failed->description);
-
***The diff for this file has been truncated for email.***
=======================================
--- /trunk/monitor.h    Sat Jul 24 04:27:48 2010
+++ /trunk/monitor.h    Mon Jul 26 07:54:50 2010
@@ -306,7 +306,6 @@
Command_T exec; /**< Optional command to be executed */ unsigned count; /**< Event count needed to trigger the action */ unsigned cycles; /**< Cycles during which count limit can be reached */ - char description[PATH_MAX]; /**< Action description buffer */
 } *Action_T;


=======================================
--- /trunk/p.y  Sat Jul 24 04:27:48 2010
+++ /trunk/p.y  Mon Jul 26 07:54:50 2010
@@ -257,7 +257,6 @@
   static int   cleanup_hash_string(char *);
   static void  check_depend();
   static void  setsyslog(char *);
-  static void describeAction(Action_T);
   static Command_T copycommand(Command_T);
   static int verifyMaxForward(int);

@@ -1162,21 +1161,17 @@
                 ;

 exist           : IF NOT EXIST rate1 THEN action1 recovery {
-                    *(current->action_NONEXIST->failed->description) = 0;
- *(current->action_NONEXIST->succeeded->description) = 0; seteventaction(&(current)->action_NONEXIST, $<number>6, $<number>7);
                   }
                 ;


 pid             : IF CHANGED PID rate1 THEN action1 {
-                    *(current->action_PID->failed->description) = 0;
seteventaction(&(current)->action_PID, $<number>6, ACTION_IGNORE);
                   }
                 ;

 ppid            : IF CHANGED PPID rate1 THEN action1 {
-                    *(current->action_PPID->failed->description) = 0;
seteventaction(&(current)->action_PPID, $<number>6, ACTION_IGNORE);
                   }
                 ;
@@ -1595,7 +1590,6 @@
                 ;

 fsflag          : IF CHANGED FSFLAG rate1 THEN action1 {
-                    *(current->action_FSFLAG->failed->description) = 0;
seteventaction(&(current)->action_FSFLAG, $<number>6, ACTION_IGNORE);
                   }
                 ;
@@ -2579,7 +2573,6 @@
     ea->failed->exec = command1;
     command1 = NULL;
   }
-  describeAction(ea->failed);

   ea->succeeded->id     = succeeded;
   ea->succeeded->count  = rate2.count;
@@ -2589,7 +2582,6 @@
     ea->succeeded->exec = command2;
     command2 = NULL;
   }
-  describeAction(ea->succeeded);
   *_ea = ea;
   reset_rateset();
 }
@@ -2613,7 +2605,6 @@
     ea->failed->exec = command1;
     command1 = NULL;
   }
-  describeAction(ea->failed);

   ea->succeeded->id     = succeeded;
   ea->succeeded->count  = rate2.count;
@@ -2623,7 +2614,6 @@
     ea->succeeded->exec = command2;
     command2 = NULL;
   }
-  describeAction(ea->succeeded);
 }


@@ -3483,30 +3473,6 @@
   hashstring[j] = '\0';
   return j;
 }
-
-
-static void describeAction(Action_T A) {
-  #define BUF_CURSOR    (A->description + strlen(A->description))
-  #define BUF_AVAILABLE (sizeof(A->description) - strlen(A->description))
-  snprintf(BUF_CURSOR, BUF_AVAILABLE, "%s", actionnames[A->id]);
-  if (A->id == ACTION_EXEC) {
-    int i = 0;
-    Command_T C = A->exec;
-
-    while (C->arg[i]) {
- snprintf(BUF_CURSOR, BUF_AVAILABLE, "%s%s", i ? " " : " '", C->arg[i]);
-      i++;
-    }
-    snprintf(BUF_CURSOR, BUF_AVAILABLE, "'");
-    if (C->has_uid)
-      snprintf(BUF_CURSOR, BUF_AVAILABLE, " as uid %d", C->uid);
-    if (C->has_gid)
-      snprintf(BUF_CURSOR, BUF_AVAILABLE, " as gid %d", C->gid);
- snprintf(BUF_CURSOR, BUF_AVAILABLE, " timeout %d cycle(s)", C->timeout);
-  }
-  #undef BUF_CURSOR
-  #undef BUF_AVAILABLE
-}


 /* Return deep copy of the command */
=======================================
--- /trunk/util.c       Fri Jul  9 10:22:31 2010
+++ /trunk/util.c       Mon Jul 26 07:54:50 2010
@@ -763,14 +763,12 @@
   Dependant_T d;
   ServiceGroup_T sg;
   ServiceGroupMember_T sgm;
-  char string[STRLEN];
-  char ratio1[STRLEN];
-  char ratio2[STRLEN];
+  char buf[STRLEN];

   ASSERT(s);

-  snprintf(string, STRLEN, "%s Name", servicetypes[s->type]);
-  printf("%-21s = %s\n", string, s->name);
+  snprintf(buf, sizeof(buf), "%s Name", servicetypes[s->type]);
+  printf("%-21s = %s\n", buf, s->name);

   for (sg = servicegrouplist; sg; sg = sg->next) {
     for (sgm = sg->members; sgm; sgm = sgm->next) {
@@ -829,10 +827,12 @@
   }

   if(s->type != TYPE_SYSTEM) {
- printf(" %-20s = if does not exist %s then %s else if succeeded %s then %s\n",
-      "Existence",
- Util_getEventratio(s->action_NONEXIST->failed, ratio1), s->action_NONEXIST->failed->description, - Util_getEventratio(s->action_NONEXIST->succeeded, ratio2), s->action_NONEXIST->succeeded->description);
+    printf(" %-20s = ", "Existence");
+ printf("if does not exist %s ", Util_getEventratio(s->action_NONEXIST->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(s->action_NONEXIST->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(s->action_NONEXIST->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(s->action_NONEXIST->succeeded, buf, sizeof(buf)));
+    printf("\n");
   }

   for(d= s->dependantlist; d; d= d->next)
@@ -840,385 +840,289 @@
       printf(" %-20s = %s\n", "Depends on Service", d->dependant);

   if(s->type == TYPE_PROCESS) {
-    printf(" %-20s = if changed %s then %s\n",
-      "Pid",
-      Util_getEventratio(s->action_PID->failed, ratio1),
-      s->action_PID->failed->description);
-
-    printf(" %-20s = if changed %s then %s\n",
-      "Ppid",
-      Util_getEventratio(s->action_PPID->failed, ratio1),
-      s->action_PPID->failed->description);
+    printf(" %-20s = ", "Pid");
+ printf("if changed %s ", Util_getEventratio(s->action_PID->failed, buf, sizeof(buf))); + printf("then %s", Util_describeAction(s->action_PID->failed, buf, sizeof(buf)));
+    printf("\n");
+
+    printf(" %-20s = ", "Ppid");
+ printf("if changed %s ", Util_getEventratio(s->action_PPID->failed, buf, sizeof(buf))); + printf("then %s", Util_describeAction(s->action_PPID->failed, buf, sizeof(buf)));
+    printf("\n");
   }

   if(s->type == TYPE_FILESYSTEM) {
-    printf(" %-20s = if changed %s then %s\n",
-      "Filesystem flags",
-      Util_getEventratio(s->action_FSFLAG->failed, ratio1),
-      s->action_FSFLAG->failed->description);
+    printf(" %-20s = ", "Filesystem flags");
+ printf("if changed %s ", Util_getEventratio(s->action_FSFLAG->failed, buf, sizeof(buf))); + printf("then %s", Util_describeAction(s->action_FSFLAG->failed, buf, sizeof(buf)));
+    printf("\n");
   }

   if(s->checksum && s->checksum->action) {
     Checksum_T cs= s->checksum;
     EventAction_T a= cs->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
-    if(cs->test_changes)
-      printf(" %-20s = if changed %s %s then %s\n",
-        "Checksum", checksumnames[cs->type],
-        ratio1, a->failed->description);
-    else
- printf(" %-20s = if failed %s(%s) %s then %s else if succeeded %s then %s\n",
-        "Checksum", cs->hash, checksumnames[cs->type],
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
+    printf(" %-20s = ", "Checksum");
+    if(cs->test_changes) {
+ printf("if changed %s %s ", checksumnames[cs->type], Util_getEventratio(a->failed, buf, sizeof(buf)));
+      printf("then %s", Util_describeAction(a->failed, buf, sizeof(buf)));
+    } else {
+ printf("if failed %s(%s) %s ", cs->hash, checksumnames[cs->type], Util_getEventratio(a->failed, buf, sizeof(buf)));
+      printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf)));
+ printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+    }
+    printf("\n");
   }

   if(s->perm && s->perm->action) {
     EventAction_T a= s->perm->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
- printf(" %-20s = if failed %04o %s then %s else if succeeded %s then %s\n",
-      "Permission", s->perm->perm,
-      ratio1, a->failed->description,
-      ratio2, a->succeeded->description);
+    printf(" %-20s = ", "Permission");
+ printf("if failed %04o %s ", s->perm->perm, Util_getEventratio(a->failed, buf, sizeof(buf)));
+    printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf)));
+ printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf)));
+    printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+    printf("\n");
   }

   if(s->uid && s->uid->action) {
     EventAction_T a= s->uid->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
- printf(" %-20s = if failed %d %s then %s else if succeeded %s then %s\n",
-      "UID", (int)s->uid->uid,
-      ratio1, a->failed->description,
-      ratio2, a->succeeded->description);
+    printf(" %-20s = ", "UID");
+ printf("if failed %d %s ", (int)s->uid->uid, Util_getEventratio(a->failed, buf, sizeof(buf)));
+    printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf)));
+ printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf)));
+    printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+    printf("\n");
   }

   if(s->gid && s->gid->action) {
     EventAction_T a= s->gid->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
- printf(" %-20s = if failed %d %s then %s else if succeeded %s then %s\n",
-      "GID", (int)s->gid->gid,
-      ratio1, a->failed->description,
-      ratio2, a->succeeded->description);
+    printf(" %-20s = ", "GID");
+ printf("if failed %d %s ", (int)s->gid->gid, Util_getEventratio(a->failed, buf, sizeof(buf)));
+    printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf)));
+ printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf)));
+    printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+    printf("\n");
   }

   if(s->icmplist)
     for(i= s->icmplist; i; i= i->next) {
       EventAction_T a= i->action;
-
-      Util_getEventratio(a->failed, ratio1);
-      Util_getEventratio(a->succeeded, ratio2);
-
- printf(" %-20s = if failed %s count %d with timeout %d seconds %s then %s "
-        "else if succeeded %s then %s\n",
-        "ICMP", icmpnames[i->type], i->count, i->timeout,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
+      printf(" %-20s = ", "ICMP");
+ printf("if failed %s count %d with timeout %d seconds %s ", icmpnames[i->type], i->count, i->timeout, Util_getEventratio(a->failed, buf, sizeof(buf)));
+      printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf)));
+ printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+      printf("\n");
     }

   if(s->portlist) {
-
     for(n= s->portlist; n; n= n->next) {
       EventAction_T a= n->action;
-
-      Util_getEventratio(a->failed, ratio1);
-      Util_getEventratio(a->succeeded, ratio2);
-
       if(n->family == AF_INET) {
-
-          printf(" %-20s = if failed %s:%d%s [%s via %s] with "
- "timeout %d seconds %s then %s else if succeeded %s then %s\n",
-            "Port", n->hostname, n->port, n->request?n->request:"",
-             n->protocol->name, Util_portTypeDescription(n),
-             n->timeout,
-             ratio1, a->failed->description,
-             ratio2, a->succeeded->description);
-
-          if(n->SSL.certmd5 != NULL)
-            printf(" %-20s = %s\n", "Server cert md5 sum", n->SSL.certmd5);
-
+        printf(" %-20s = ", "Port");
+ printf("if failed %s:%d%s [%s via %s] with timeout %d seconds %s ", n->hostname, n->port, n->request ? n->request : "", n->protocol->name, Util_portTypeDescription(n), n->timeout, Util_getEventratio(a->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+        printf("\n");
+        if(n->SSL.certmd5 != NULL)
+          printf(" %-20s = %s\n", "Server cert md5 sum", n->SSL.certmd5);
       } else if(n->family == AF_UNIX) {
-
- printf(" %-20s = if failed %s [protocol %s] with timeout %d seconds "
-          "%s then %s else if succeeded %s then %s\n",
-          "Unix Socket", n->pathname, n->protocol->name, n->timeout,
-          ratio1, a->failed->description,
-          ratio2, a->succeeded->description);
-
-      }
-
-    }
-
+        printf(" %-20s = ", "Unix Socket");
+ printf("if failed %s [protocol %s] with timeout %d seconds %s ", n->pathname, n->protocol->name, n->timeout, Util_getEventratio(a->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+        printf("\n");
+      }
+    }
   }

   for(t= s->timestamplist; t; t= t->next) {
     EventAction_T a= t->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
-    if(t->test_changes)
-      printf(" %-20s = if changed %s then %s\n",
-        "Timestamp",
-        ratio1, a->failed->description);
-    else
- printf(" %-20s = if %s %d second(s) %s then %s else if succeeded %s then %s\n",
-        "Timestamp", operatornames[t->operator], t->time,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-
+    printf(" %-20s = ", "Timestamp");
+    if(t->test_changes) {
+ printf("if changed %s ", Util_getEventratio(a->failed, buf, sizeof(buf)));
+      printf("then %s", Util_describeAction(a->failed, buf, sizeof(buf)));
+    } else {
+ printf("if %s %d second(s) %s ", operatornames[t->operator], t->time, Util_getEventratio(a->failed, buf, sizeof(buf)));
+      printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf)));
+ printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+    }
+    printf("\n");
   }

   for(sl= s->sizelist; sl; sl= sl->next) {
     EventAction_T a= sl->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
-    if(sl->test_changes)
-      printf(" %-20s = if changed %s then %s\n",
-        "Size",
-        ratio1, a->failed->description);
-    else
- printf(" %-20s = if %s %llu byte(s) %s then %s else if succeeded %s then %s\n",
-        "Size", operatornames[sl->operator], sl->size,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
+    printf(" %-20s = ", "Size");
+    if(sl->test_changes) {
+ printf("if changed %s ", Util_getEventratio(a->failed, buf, sizeof(buf)));
+      printf("then %s", Util_describeAction(a->failed, buf, sizeof(buf)));
+    } else {
+ printf("if %s %llu byte(s) %s ", operatornames[sl->operator], sl->size, Util_getEventratio(a->failed, buf, sizeof(buf)));
+      printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf)));
+ printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+    }
+    printf("\n");

   }

   if (s->type != TYPE_PROCESS) {
     for(ml= s->matchlist; ml; ml= ml->next) {
       EventAction_T a= ml->action;
-
-      Util_getEventratio(a->failed, ratio1);
-      printf(" %-20s = if%s match \"%s\" %s then %s\n",
-        "Regex", ml->not?" not":"", ml->match_string,
-        ratio1, a->failed->description);
+      printf(" %-20s = ", "Regex");
+ printf("if%s match \"%s\" %s ", ml->not ? " not" : "", ml->match_string, Util_getEventratio(a->failed, buf, sizeof(buf)));
+      printf("then %s", Util_describeAction(a->failed, buf, sizeof(buf)));
+      printf("\n");
     }
   }

   for(dl= s->filesystemlist; dl; dl= dl->next) {
     EventAction_T a= dl->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
     if(dl->resource == RESOURCE_ID_INODE) {
-
+      printf(" %-20s = ", "Inodes usage limit");
       if(dl->limit_absolute > -1) {
- printf(" %-20s = if %s %ld %s then %s else if succeeded %s then %s\n",
-          "Inodes usage limit",
-          operatornames[dl->operator],
-          dl->limit_absolute,
-          ratio1, a->failed->description,
-          ratio2, a->succeeded->description);
+ printf("if %s %ld %s ", operatornames[dl->operator], dl->limit_absolute, Util_getEventratio(a->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
       } else {
- printf(" %-20s = if %s %.1f%% %s then %s else if succeeded %s then %s\n",
-          "Inodes usage limit",
-          operatornames[dl->operator],
-          dl->limit_percent/10.,
-          ratio1, a->failed->description,
-          ratio2, a->succeeded->description);
-      }
-
+ printf("if %s %.1f%% %s ", operatornames[dl->operator], dl->limit_percent / 10., Util_getEventratio(a->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+      }
+      printf("\n");
     } else if(dl->resource == RESOURCE_ID_SPACE) {
-
+      printf(" %-20s = ", "Space usage limit");
       if(dl->limit_absolute > -1) {
- printf(" %-20s = if %s %ld blocks %s then %s else if succeeded %s then %s\n",
-          "Space usage limit",
-          operatornames[dl->operator],
-          dl->limit_absolute,
-          ratio1, a->failed->description,
-          ratio2, a->succeeded->description);
+ printf("if %s %ld blocks %s ", operatornames[dl->operator], dl->limit_absolute, Util_getEventratio(a->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
       } else {
- printf(" %-20s = if %s %.1f%% %s then %s else if succeeded %s then %s\n",
-          "Space usage limit",
-          operatornames[dl->operator],
-          dl->limit_percent/10.,
-          ratio1, a->failed->description,
-          ratio2, a->succeeded->description);
-      }
-
-    }
-
+ printf("if %s %.1f%% %s ", operatornames[dl->operator], dl->limit_percent / 10., Util_getEventratio(a->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+      }
+      printf("\n");
+    }
   }

   for(q= s->resourcelist; q; q= q->next) {
     EventAction_T a= q->action;
-
-    Util_getEventratio(a->failed, ratio1);
-    Util_getEventratio(a->succeeded, ratio2);
-
     switch(q->resource_id) {
-
-    case RESOURCE_ID_CPU_PERCENT:
-
-      printf(" %-20s = if %s %.1f%% %s then %s "
-        "else if succeeded %s then %s\n",
-        "CPU usage limit",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_TOTAL_CPU_PERCENT:
-
-      printf(" %-20s = if %s %.1f%% %s then %s "
-        "else if succeeded %s then %s\n",
-        "CPU usage limit (incl. children)",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_CPUUSER:
-
-      printf(" %-20s = if %s %.1f%% %s then %s "
-        "else if succeeded %s then %s\n",
-        "CPU user limit",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_CPUSYSTEM:
-
-      printf(" %-20s = if %s %.1f%% %s then %s "
-        "else if succeeded %s then %s\n",
-        "CPU system limit",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_CPUWAIT:
-
-      printf(" %-20s = if %s %.1f%% %s then %s "
-        "else if succeeded %s then %s\n",
-        "CPU wait limit",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_MEM_PERCENT:
-
-      printf(" %-20s = if %s %.1f%% %s then %s "
-        "else if succeeded %s then %s\n",
-        "Memory usage limit",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_MEM_KBYTE:
-
-      printf(" %-20s = if %s %ldkB %s then %s "
-        "else if succeeded %s then %s\n",
-        "Memory amount limit",
-        operatornames[q->operator], q->limit,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_SWAP_PERCENT:
-
-      printf(" %-20s = if %s %.1f%% %s then %s "
-        "else if succeeded %s then %s\n",
-        "Swap usage limit",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_SWAP_KBYTE:
-
-      printf(" %-20s = if %s %ldkB %s then %s "
-        "else if succeeded %s then %s\n",
-        "Swap amount limit",
-        operatornames[q->operator], q->limit,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_LOAD1:
-
-      printf(" %-20s = if %s %.1f %s then %s "
-        "else if succeeded %s then %s\n",
-        "Load avg. (1min)",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_LOAD5:
-
-      printf(" %-20s = if %s %.1f %s then %s "
-        "else if succeeded %s then %s\n",
-        "Load avg. (5min)",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_LOAD15:
-
-      printf(" %-20s = if %s %.1f %s then %s "
-        "else if succeeded %s then %s\n",
-        "Load avg. (15min)",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_CHILDREN:
-
-      printf(" %-20s = If %s %ld %s then %s "
-        "else if succeeded %s then %s\n",
-        "Children", operatornames[q->operator], q->limit,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_TOTAL_MEM_KBYTE:
-
-      printf(" %-20s = If %s %ld %s then %s "
-        "else if succeeded %s then %s\n",
-        "Memory amount limit (incl. children)",
-        operatornames[q->operator], q->limit,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    case RESOURCE_ID_TOTAL_MEM_PERCENT:
-
-      printf(" %-20s = If %s %.1f%% %s then %s "
-        "else if succeeded %s then %s\n",
-        "Memory usage limit (incl. children)",
-        operatornames[q->operator], q->limit/10.0,
-        ratio1, a->failed->description,
-        ratio2, a->succeeded->description);
-      break;
-
-    }
+      case RESOURCE_ID_CPU_PERCENT:
+        printf(" %-20s = ", "CPU usage limit");
+        break;
+
+      case RESOURCE_ID_TOTAL_CPU_PERCENT:
+        printf(" %-20s = ", "CPU usage limit (incl. children)");
+        break;
+
+      case RESOURCE_ID_CPUUSER:
+        printf(" %-20s = ", "CPU user limit");
+        break;
+
+      case RESOURCE_ID_CPUSYSTEM:
+        printf(" %-20s = ", "CPU system limit");
+        break;
+
+      case RESOURCE_ID_CPUWAIT:
+        printf(" %-20s = ", "CPU wait limit");
+        break;
+
+      case RESOURCE_ID_MEM_PERCENT:
+        printf(" %-20s = ", "Memory usage limit");
+        break;
+
+      case RESOURCE_ID_MEM_KBYTE:
+        printf(" %-20s = ", "Memory amount limit");
+        break;
+
+      case RESOURCE_ID_SWAP_PERCENT:
+        printf(" %-20s = ", "Swap usage limit");
+        break;
+
+      case RESOURCE_ID_SWAP_KBYTE:
+        printf(" %-20s = ", "Swap amount limit");
+        break;
+
+      case RESOURCE_ID_LOAD1:
+        printf(" %-20s = ", "Load avg. (1min)");
+        break;
+
+      case RESOURCE_ID_LOAD5:
+        printf(" %-20s = ", "Load avg. (5min)");
+        break;
+
+      case RESOURCE_ID_LOAD15:
+        printf(" %-20s = ", "Load avg. (15min)");
+        break;
+
+      case RESOURCE_ID_CHILDREN:
+        printf(" %-20s = ", "Children");
+        break;
+
+      case RESOURCE_ID_TOTAL_MEM_KBYTE:
+        printf(" %-20s = ", "Memory amount limit (incl. children)");
+        break;
+
+      case RESOURCE_ID_TOTAL_MEM_PERCENT:
+        printf(" %-20s = ", "Memory usage limit (incl. children)");
+        break;
+    }
+    switch(q->resource_id) {
+      case RESOURCE_ID_CPU_PERCENT:
+      case RESOURCE_ID_TOTAL_CPU_PERCENT:
+      case RESOURCE_ID_TOTAL_MEM_PERCENT:
+      case RESOURCE_ID_CPUUSER:
+      case RESOURCE_ID_CPUSYSTEM:
+      case RESOURCE_ID_CPUWAIT:
+      case RESOURCE_ID_MEM_PERCENT:
+      case RESOURCE_ID_SWAP_PERCENT:
+ printf("if %s %.1f%% %s ", operatornames[q->operator], q->limit / 10.0, Util_getEventratio(a->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+        break;
+
+      case RESOURCE_ID_MEM_KBYTE:
+      case RESOURCE_ID_SWAP_KBYTE:
+ printf("if %s %ldkB %s ", operatornames[q->operator], q->limit, Util_getEventratio(a->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+        break;
+
+      case RESOURCE_ID_LOAD1:
+      case RESOURCE_ID_LOAD5:
+      case RESOURCE_ID_LOAD15:
+ printf("if %s %.1f %s ", operatornames[q->operator], q->limit / 10.0, Util_getEventratio(a->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+        break;
+
+      case RESOURCE_ID_CHILDREN:
+      case RESOURCE_ID_TOTAL_MEM_KBYTE:
+ printf("if %s %ld %s ", operatornames[q->operator], q->limit, Util_getEventratio(a->failed, buf, sizeof(buf))); + printf("then %s ", Util_describeAction(a->failed, buf, sizeof(buf))); + printf("else if succeeded %s ", Util_getEventratio(a->succeeded, buf, sizeof(buf))); + printf("then %s", Util_describeAction(a->succeeded, buf, sizeof(buf)));
+        break;
+    }
+    printf("\n");
   }

   if(s->def_every)
     printf(" %-20s = Check service every %d cycles\n", "Every", s->every);

   for (ar = s->actionratelist; ar; ar = ar->next)
- printf(" %-20s = If restarted %d times within %d cycle(s) then %s\n", "Timeout", ar->count, ar->cycle, ar->action->failed->description); + printf(" %-20s = If restarted %d times within %d cycle(s) then %s\n", "Timeout", ar->count, ar->cycle, Util_describeAction(ar->action->failed, buf, sizeof(buf)));

   for(r= s->maillist; r; r= r->next) {
     printf(" %-20s = %s\n", "Alert mail to", is_str_defined(r->to));
@@ -2206,25 +2110,37 @@
 }


-/**
- * Print event ratio needed to trigger the action to the buffer
- * @param action A action string
- * @return the action id
- */
-char *Util_getEventratio(Action_T action, char *buf) {
-  snprintf(buf, STRLEN,
-    "%d times within %d cycle(s)",
-    action->count, action->cycles);
-
+char *Util_describeAction(Action_T A, char *buf, int bufsize) {
+  #define BUF_CURSOR    (buf + strlen(buf))
+  #define BUF_AVAILABLE (bufsize - strlen(buf) - 1)
+  snprintf(buf, bufsize, "%s", actionnames[A->id]);
+  if (A->id == ACTION_EXEC) {
+    int i = 0;
+    Command_T C = A->exec;
+
+    while (C->arg[i]) {
+ snprintf(BUF_CURSOR, BUF_AVAILABLE, "%s%s", i ? " " : " '", C->arg[i]);
+      i++;
+    }
+    snprintf(BUF_CURSOR, BUF_AVAILABLE, "'");
+    if (C->has_uid)
+      snprintf(BUF_CURSOR, BUF_AVAILABLE, " as uid %d", C->uid);
+    if (C->has_gid)
+      snprintf(BUF_CURSOR, BUF_AVAILABLE, " as gid %d", C->gid);
+ snprintf(BUF_CURSOR, BUF_AVAILABLE, " timeout %d cycle(s)", C->timeout);
+  }
   return buf;
+  #undef BUF_CURSOR
+  #undef BUF_AVAILABLE
 }


-/**
- * Print port type description
- * @param p A port structure
- * @return the socket type description
- */
+char *Util_getEventratio(Action_T action, char *buf, int bufsize) {
+ snprintf(buf, bufsize, "%d times within %d cycle(s)", action->count, action->cycles);
+  return buf;
+}
+
+
 char *Util_portTypeDescription(Port_T p) {
   switch(p->type) {
     case SOCK_STREAM:
=======================================
--- /trunk/util.h       Mon Mar 29 09:24:30 2010
+++ /trunk/util.h       Mon Jul 26 07:54:50 2010
@@ -450,12 +450,24 @@
 int Util_getAction(const char *action);


+/*
+ * Write full action description to given buffer
+ * @param action An action object
+ * @param buf Buffer
+ * @param bufsize Buffer size
+ * @return the buffer
+ */
+char *Util_describeAction(Action_T action, char *buf, int bufsize);
+
+
 /**
- * Print event ratio needed to trigger the action to the buffer
+ * Print event ratio needed to trigger the action to given buffer
  * @param action A action string
- * @return the action id
+ * @param buf Buffer
+ * @param bufsize Buffer size
+ * @return the buffer
  */
-char *Util_getEventratio(Action_T action, char *buf);
+char *Util_getEventratio(Action_T action, char *buf, int bufsize);


 /**



reply via email to

[Prev in Thread] Current Thread [Next in Thread]