From: Leonard Göhrs Date: Mon, 9 Jan 2023 13:43:44 +0000 (+0100) Subject: [collectd 6] exec: make PUTMETRIC work X-Git-Tag: 6.0.0-rc0~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fa95845f8ff054adb0c98fac776f0e088a5acda;p=thirdparty%2Fcollectd.git [collectd 6] exec: make PUTMETRIC work 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 --- diff --git a/src/utils/cmds/putmetric.c b/src/utils/cmds/putmetric.c index 9316609a6..f2b1ac5b4 100644 --- a/src/utils/cmds/putmetric.c +++ b/src/utils/cmds/putmetric.c @@ -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);