Skip to content

Commit

Permalink
Merge pull request collectd#4179 from octo/6/write_log
Browse files Browse the repository at this point in the history
write_log plugin: Remove empty lines, add example config
  • Loading branch information
octo committed Dec 4, 2023
2 parents 4237e9e + 26e442f commit dc7303c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/collectd.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,10 @@
# </Topic>
#</Plugin>

#<Plugin write_log>
# Format "Graphite"
#</Plugin>

#<Plugin write_mongodb>
# <Node "example">
# Host "localhost"
Expand Down
2 changes: 1 addition & 1 deletion src/collectd.conf.pod
Original file line number Diff line number Diff line change
Expand Up @@ -10936,7 +10936,7 @@ This plugin supports two output formats: I<Graphite> and I<JSON>.
Synopsis:

<Plugin write_log>
Format Graphite
Format "Graphite"
</Plugin>

=over 4
Expand Down
11 changes: 9 additions & 2 deletions src/write_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,17 @@ static int wl_write_graphite(metric_family_t const *fam) {
int status = format_graphite(&buf, m, prefix, suffix, escape_char, flags);
if (status != 0) {
ERROR("write_log plugin: format_graphite failed: %d", status);
} else {
INFO("%s", buf.ptr);
strbuf_reset(&buf);
continue;
}

/* trim newlines emitted by format_graphite() */
while (buf.pos > 0 && isspace(buf.ptr[buf.pos - 1])) {
buf.pos--;
buf.ptr[buf.pos] = 0;
}

INFO("%s", buf.ptr);
strbuf_reset(&buf);
}

Expand Down

0 comments on commit dc7303c

Please sign in to comment.