diff options
author | Lennart Weller <lhw@ring0.de> | 2017-09-17 22:17:45 +0000 |
---|---|---|
committer | Lennart Weller <lhw@ring0.de> | 2017-09-17 22:17:45 +0000 |
commit | 7ee3962eaca4214264964ae32c86de457a90e382 (patch) | |
tree | 5a784485351593ac6d74fa9fd9bbd8fe7c9c3fe0 /src/plugins_d.c | |
parent | maintscript eludes me (diff) | |
parent | New upstream version 1.8.0+dfsg (diff) | |
download | netdata-7ee3962eaca4214264964ae32c86de457a90e382.tar.xz netdata-7ee3962eaca4214264964ae32c86de457a90e382.zip |
Updated version 1.8.0+dfsg from 'upstream/1.8.0+dfsg'
with Debian dir 412de09d9bca38fe00146ef090f9e53f76493882
Diffstat (limited to '')
-rw-r--r-- | src/plugins_d.c | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/src/plugins_d.c b/src/plugins_d.c index 9eb102770..42433b552 100644 --- a/src/plugins_d.c +++ b/src/plugins_d.c @@ -217,47 +217,63 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int st = NULL; } else if(likely(hash == CHART_HASH && !strcmp(s, PLUGINSD_KEYWORD_CHART))) { - int noname = 0; st = NULL; - if((words[1]) != NULL && (words[2]) != NULL && strcmp(words[1], words[2]) == 0) - noname = 1; + char *type = words[1]; + char *name = words[2]; + char *title = words[3]; + char *units = words[4]; + char *family = words[5]; + char *context = words[6]; + char *chart = words[7]; + char *priority_s = words[8]; + char *update_every_s = words[9]; + char *options = words[10]; - char *type = words[1]; + // parse the id from type char *id = NULL; - if(likely(type)) { - id = strchr(type, '.'); - if(likely(id)) { *id = '\0'; id++; } + if(likely(type && (id = strchr(type, '.')))) { + *id = '\0'; + id++; } - char *name = words[2]; - char *title = words[3]; - char *units = words[4]; - char *family = words[5]; - char *context = words[6]; - char *chart = words[7]; - char *priority_s = words[8]; - char *update_every_s = words[9]; - char *options = words[10]; + // make sure we have the required variables if(unlikely(!type || !*type || !id || !*id)) { error("PLUGINSD: '%s' is requesting a CHART, without a type.id, on host '%s'. Disabling it.", cd->fullfilename, host->hostname); enabled = 0; break; } + // parse the name, and make sure it does not include 'type.' + if(unlikely(name && *name)) { + // when data are coming from slaves + // name will be type.name + // so we have to remove 'type.' from name too + size_t len = strlen(type); + if(strncmp(type, name, len) == 0 && name[len] == '.') + name = &name[len + 1]; + + // if the name is the same with the id, + // or is just 'NULL', clear it. + if(unlikely(strcmp(name, id) == 0 || strcasecmp(name, "NULL") == 0 || strcasecmp(name, "(NULL)") == 0)) + name = NULL; + } + int priority = 1000; - if(likely(priority_s)) priority = str2i(priority_s); + if(likely(priority_s && *priority_s)) priority = str2i(priority_s); int update_every = cd->update_every; - if(likely(update_every_s)) update_every = str2i(update_every_s); + if(likely(update_every_s && *update_every_s)) update_every = str2i(update_every_s); if(unlikely(!update_every)) update_every = cd->update_every; RRDSET_TYPE chart_type = RRDSET_TYPE_LINE; if(unlikely(chart)) chart_type = rrdset_type_id(chart); - if(unlikely(noname || !name || !*name || strcasecmp(name, "NULL") == 0 || strcasecmp(name, "(NULL)") == 0)) name = NULL; - if(unlikely(!family || !*family)) family = NULL; - if(unlikely(!context || !*context)) context = NULL; + if(unlikely(name && !*name)) name = NULL; + if(unlikely(family && !*family)) family = NULL; + if(unlikely(context && !*context)) context = NULL; + if(unlikely(!title)) title = ""; + if(unlikely(!units)) units = "unknown"; st = rrdset_find_bytype(host, type, id); if(unlikely(!st)) { |