Code

exec plugin: Changed the format in which notifications are passed to the programs. collectd-4.3.0beta1
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 11 Feb 2008 11:47:18 +0000 (12:47 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 11 Feb 2008 11:47:18 +0000 (12:47 +0100)
Using a `Message:' header field restricts us to one-line messages, which is
probably not very farsighted.

src/collectd-exec.pod
src/exec.c

index fe2fd6303d4e3dc34eece8ca3201fedacc289840..e95fac9f8de1a12508f8249558f26f8692313df0 100644 (file)
@@ -200,17 +200,19 @@ The notification executables receive values rather than providing them. In
 fact, after the program is started C<STDOUT> is connected to C</dev/null>.
 
 The data is passed to the executables over C<STDIN> in a format very similar to
-HTTP-headers: There is one line per field. Every line consists of a field name,
-ended by a colon, and the associated value until end-of-line. The input is
-ended by two newlines immediately following another.
+HTTP: At first there is a "header" with one line per field. Every line consists
+of a field name, ended by a colon, and the associated value until end-of-line.
+The "header" is ended by two newlines immediately following another,
+i.E<nbsp>e. an empty line. The rest, basically the "body", is the message of
+the notification.
 
 The following is an example notification passed to a program:
 
   Severity: FAILURE
   Time: 1200928930
   Host: myhost.mydomain.org
-  Message: This is a test notification to demonstrate the format
-  <newline>
+  \n
+  This is a test notification to demonstrate the format
 
 The following header files are currently used. Please note, however, that you
 should ignore unknown header files to be as forward-compatible as possible.
@@ -227,12 +229,17 @@ The time in epoch, i.E<nbsp>e. as seconds since 1970-01-01 00:00:00 UTC.
 
 =item B<Host>
 
-Name of the host concerned.
+=item B<Plugin>
 
-=item B<Message>
+=item B<PluginInstance>
 
-Message of the notification. This message should be made accessible to the
-user somehow.
+=item B<Type>
+
+=item B<TypeInstance>
+
+Identification of the performance data this notification is associated with.
+All of these fields are optional because notifications do not B<need> to be
+associated with a certain value.
 
 =back
 
index ced03f2924a798289456c7d3e0b0c2067d3db4f6..44f03e3387a9236260a6388eb3efbd62596dfac7 100644 (file)
@@ -610,10 +610,10 @@ static void *exec_notification_one (void *arg) /* {{{ */
   else if (n->severity == NOTIF_OKAY)
     severity = "OKAY";
 
-  fprintf (fh, "Severity: %s\n"
-      "Time: %u\n"
-      "Message: %s\n",
-      severity, (unsigned int) n->time, n->message);
+  fprintf (fh,
+      "Severity: %s\n"
+      "Time: %u\n",
+      severity, (unsigned int) n->time);
 
   /* Print the optional fields */
   if (strlen (n->host) > 0)
@@ -627,8 +627,7 @@ static void *exec_notification_one (void *arg) /* {{{ */
   if (strlen (n->type_instance) > 0)
     fprintf (fh, "TypeInstance: %s\n", n->type_instance);
 
-  /* Newline signalling end of data */
-  fprintf (fh, "\n");
+  fprintf (fh, "\n%s\n", n->message);
 
   fflush (fh);
   fclose (fh);