summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f41b91a)
raw | patch | inline | side by side (parent: f41b91a)
exec plugin: Changed the format in which notifications are passed to the programs. collectd-4.3.0beta1
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 11 Feb 2008 11:47:18 +0000 (12:47 +0100) | ||
committer | Florian 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.
probably not very farsighted.
src/collectd-exec.pod | patch | blob | history | |
src/exec.c | patch | blob | history |
diff --git a/src/collectd-exec.pod b/src/collectd-exec.pod
index fe2fd6303d4e3dc34eece8ca3201fedacc289840..e95fac9f8de1a12508f8249558f26f8692313df0 100644 (file)
--- a/src/collectd-exec.pod
+++ b/src/collectd-exec.pod
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.
=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
diff --git a/src/exec.c b/src/exec.c
index ced03f2924a798289456c7d3e0b0c2067d3db4f6..44f03e3387a9236260a6388eb3efbd62596dfac7 100644 (file)
--- a/src/exec.c
+++ b/src/exec.c
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)
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);