From: Florian Forster Date: Fri, 25 May 2007 17:48:56 +0000 (+0200) Subject: exec plugin: Print a warning when the returned string is incorrect. X-Git-Tag: collectd-4.0.0~9 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c24f7a338b0b7a910d0346254da1e96cb9ce2d27;p=collectd.git exec plugin: Print a warning when the returned string is incorrect. Also the debug messages have been beautified. --- 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));