Skip to content

Commit

Permalink
Adjust behavior to work properly with non-existent graphite prefixes …
Browse files Browse the repository at this point in the history
…(should fix #87, fix #86)
  • Loading branch information
jbuchbinder committed Feb 19, 2013
1 parent f16c978 commit 2eafad1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gmetad/rrd_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ write_data_to_carbon ( const char *source, const char *host, const char *metric,
sprintf(s_process_time, "%u", process_time);

/* Build the path */
strncpy(graphite_msg, gmetad_config.graphite_prefix, PATHSIZE);
if (gmetad_config.graphite_prefix != NULL && strlen(gmetad_config.graphite_prefix) > 1) {
strncpy(graphite_msg, gmetad_config.graphite_prefix, PATHSIZE);
}



Expand All @@ -393,8 +395,12 @@ write_data_to_carbon ( const char *source, const char *host, const char *metric,
}
sourcecp[i+1]=0;

strncat(graphite_msg, ".", PATHSIZE-strlen(graphite_msg));
strncat(graphite_msg, sourcecp, PATHSIZE-strlen(graphite_msg));
if (gmetad_config.graphite_prefix != NULL && strlen(gmetad_config.graphite_prefix) > 1) {
strncat(graphite_msg, ".", PATHSIZE-strlen(graphite_msg));
strncat(graphite_msg, sourcecp, PATHSIZE-strlen(graphite_msg));
} else {
strncpy(graphite_msg, sourcecp, PATHSIZE);
}
}


Expand Down

0 comments on commit 2eafad1

Please sign in to comment.