From 660aebd9a5216d2f143d5f30c4e87bcfa4502ea6 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 11 Feb 2008 12:47:18 +0100 Subject: [PATCH] exec plugin: Changed the format in which notifications are passed to the programs. Using a `Message:' header field restricts us to one-line messages, which is probably not very farsighted. --- src/collectd-exec.pod | 25 ++++++++++++++++--------- src/exec.c | 11 +++++------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/collectd-exec.pod b/src/collectd-exec.pod index fe2fd630..e95fac9f 100644 --- a/src/collectd-exec.pod +++ b/src/collectd-exec.pod @@ -200,17 +200,19 @@ The notification executables receive values rather than providing them. In fact, after the program is started C is connected to C. The data is passed to the executables over C 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.Ee. 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 - + \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.Ee. as seconds since 1970-01-01 00:00:00 UTC. =item B -Name of the host concerned. +=item B -=item B +=item B -Message of the notification. This message should be made accessible to the -user somehow. +=item B + +=item B + +Identification of the performance data this notification is associated with. +All of these fields are optional because notifications do not B to be +associated with a certain value. =back diff --git a/src/exec.c b/src/exec.c index ced03f29..44f03e33 100644 --- a/src/exec.c +++ b/src/exec.c @@ -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); -- 2.11.0