From: Florian Forster Date: Fri, 6 Aug 2010 12:59:56 +0000 (+0200) Subject: src/utils_cmd_putval.[ch]: Implement "create_putval". X-Git-Tag: collectd-5.0.0-beta0~73 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1a9c26bffc5ae9c7d54c4e2b841b248098010b56;p=collectd.git src/utils_cmd_putval.[ch]: Implement "create_putval". --- diff --git a/src/utils_cmd_putval.c b/src/utils_cmd_putval.c index ec2b5f87..15cd939b 100644 --- a/src/utils_cmd_putval.c +++ b/src/utils_cmd_putval.c @@ -227,3 +227,29 @@ int handle_putval (FILE *fh, char *buffer) return (0); } /* int handle_putval */ +int create_putval (char *ret, size_t ret_len, /* {{{ */ + const data_set_t *ds, const value_list_t *vl) +{ + char buffer_ident[6 * DATA_MAX_NAME_LEN]; + char buffer_values[1024]; + int status; + + status = FORMAT_VL (buffer_ident, sizeof (buffer_ident), vl); + if (status != 0) + return (status); + escape_string (buffer_ident, sizeof (buffer_ident)); + + status = format_values (buffer_values, sizeof (buffer_values), + ds, vl, /* store rates = */ 0); + if (status != 0) + return (status); + escape_string (buffer_values, sizeof (buffer_values)); + + ssnprintf (ret, ret_len, + "PUTVAL %s interval=%i %s", + buffer_ident, + (vl->interval > 0) ? vl->interval : interval_g, + buffer_values); + + return (0); +} /* }}} int create_putval */ diff --git a/src/utils_cmd_putval.h b/src/utils_cmd_putval.h index 8460b133..9c92fd31 100644 --- a/src/utils_cmd_putval.h +++ b/src/utils_cmd_putval.h @@ -24,6 +24,11 @@ #include +#include "plugin.h" + int handle_putval (FILE *fh, char *buffer); +int create_putval (char *ret, size_t ret_len, + const data_set_t *ds, const value_list_t *vl); + #endif /* UTILS_CMD_PUTVAL_H */