Skip to content
Browse files

Adjust behavior to work properly with non-existent graphite prefixes …

…(should fix #87, fix #86)
  • Loading branch information...
1 parent f16c978 commit 2eafad1811dd0d9c71a90391c1173a02c031e745 @jbuchbinder jbuchbinder committed
Showing with 9 additions and 3 deletions.
  1. +9 −3 gmetad/rrd_helpers.c
View
12 gmetad/rrd_helpers.c
@@ -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);
+ }
@@ -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);
+ }
}

0 comments on commit 2eafad1

Please sign in to comment.
Something went wrong with that request. Please try again.