From c24f7a338b0b7a910d0346254da1e96cb9ce2d27 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 25 May 2007 19:48:56 +0200 Subject: [PATCH] exec plugin: Print a warning when the returned string is incorrect. Also the debug messages have been beautified. --- src/exec.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/exec.c b/src/exec.c index 518efc87..bd96e07b 100644 --- a/src/exec.c +++ b/src/exec.c @@ -273,9 +273,15 @@ static void *exec_read_one (void *arg) char *type_instance; char *value; - DEBUG ("buffer = %s", buffer); - len = strlen (buffer); + + /* Remove newline from end. */ + while ((len > 0) && ((buffer[len - 1] == '\n') + || (buffer[len - 1] == '\r'))) + buffer[--len] = '\0'; + + DEBUG ("exec plugin: exec_read_one: buffer = %s", buffer); + if (len < 5) continue; @@ -299,11 +305,15 @@ static void *exec_read_one (void *arg) value = strchr (type_instance, ','); if (value == NULL) + { + WARNING ("exec plugin: type-instance is missing."); continue; + } *value = '\0'; value++; - DEBUG ("value = %s", value); + DEBUG ("exec plugin: exec_read_one: type = %s; type_instance = %s; " + "value = %s;", type, type_instance, value); if (strcasecmp ("counter", type) == 0) submit_counter (type_instance, atoll (value)); -- 2.11.0