]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
[collectd 6] exec: make PUTMETRIC work
authorLeonard Göhrs <l.goehrs@pengutronix.de>
Mon, 9 Jan 2023 13:43:44 +0000 (14:43 +0100)
committerMatthias Runge <mrunge@matthias-runge.de>
Sun, 23 Apr 2023 13:00:45 +0000 (15:00 +0200)
The cmd_handle_putmetric function checks if the command actually is
a PUTMETRIC command, at least that is what is supposed to check.
Prior to this fix it actually checked for PUTVAL and always prints a

    -1 Unexpected command: `PUTMETRIC'.

error. While at it also remove the development printf that results in

    set_option("type", "GAUGE")
    set_option("type", "Counter")
    …

being printed during normal operation.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
src/utils/cmds/putmetric.c

index 9316609a626ab1a797af56a0fd1d680818d2e8f3..f2b1ac5b43d76c7a45f1ce44a4b5f277665b7c87 100644 (file)
@@ -41,8 +41,6 @@ static int set_option(metric_t *m, char const *key, char const *value,
   if ((m == NULL) || (key == NULL) || (value == NULL))
     return -1;
 
-  printf("set_option(\"%s\", \"%s\")\n", key, value);
-
   if (strcasecmp("type", key) == 0) {
     if (strcasecmp("GAUGE", value) == 0) {
       m->family->type = METRIC_TYPE_GAUGE;
@@ -201,7 +199,7 @@ cmd_status_t cmd_handle_putmetric(FILE *fh, char *buffer) {
   int status;
   if ((status = cmd_parse(buffer, &cmd, NULL, &err)) != CMD_OK)
     return status;
-  if (cmd.type != CMD_PUTVAL) {
+  if (cmd.type != CMD_PUTMETRIC) {
     cmd_error(CMD_UNKNOWN_COMMAND, &err, "Unexpected command: `%s'.",
               CMD_TO_STRING(cmd.type));
     cmd_destroy(&cmd);