summaryrefslogtreecommitdiffstats
path: root/collectors/plugins.d
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2020-05-18 21:03:32 -0400
committerGitHub <noreply@github.com>2020-05-19 11:03:32 +1000
commitedeb82fac99246b7d572744fe1d732fd6d9cb34e (patch)
tree244bf54702edd4f96cc03b974a0174761a1436c9 /collectors/plugins.d
parent3cf541f25558ef3b2f43b4bc857e64042a2d09e5 (diff)
install and enable eBPF Plugin by default (#8665)
* netdata_installer_kernels: New kernels This commit brings new kernels for our netdata-installer * RH detection This commit brings the RH detection to netdata-installer, but it cannot be tested yet until we merge a PR on kernel-collector * netdata_installer_kernels: RH kernels This commit brings updates that allows to install and run the collectors on RH * netdata_installer_kernels: Kernel variables This commit brings definitions instead magic number to the isntaller * netdata_installer_kernels: remove echo This commit removes echo to avoid new line * netdata_installer_kernels: Move C code This commit removes the C code that will be inserted in another PR * Update eBPF install to use released version. This updates the install code for the eBPF plugin to properly utilize (and verify) a tagged release of the plugin instead of pulling the upstream master branch. It also adds support for using a local copy of the tarball, and switchs the default behavior to install the eBPF plugin instead of not installing it. * Tidy-up messages relating to eBPF. * Fix typos in error handling functions. * ebpf-release: New kernels This commit brings the kernels necessary to support Debian 10.0 * ebpf-release: Bring support for new package format * ebpf-release: collector as loader This commit brings the necessary changes for the collector loads all the nfiles depending of the kernel it is running * Update eBPF install to use released version. This updates the install code for the eBPF plugin to properly utilize (and verify) a tagged release of the plugin instead of pulling the upstream master branch. It also adds support for using a local copy of the tarball, and switchs the default behavior to install the eBPF plugin instead of not installing it. * netdata_installer_kernels: New kernels This commit brings new kernels for our netdata-installer * RH detection This commit brings the RH detection to netdata-installer, but it cannot be tested yet until we merge a PR on kernel-collector * netdata_installer_kernels: RH kernels This commit brings updates that allows to install and run the collectors on RH * netdata_installer_kernels: Kernel variables This commit brings definitions instead magic number to the isntaller * netdata_installer_kernels: remove echo This commit removes echo to avoid new line * netdata_installer_kernels: Move C code This commit removes the C code that will be inserted in another PR * Tidy-up messages relating to eBPF. * Fix typos in error handling functions. * ebpf-release: New kernels This commit brings the kernels necessary to support Debian 10.0 * ebpf-release: Bring support for new package format * ebpf-release: collector as loader This commit brings the necessary changes for the collector loads all the nfiles depending of the kernel it is running * Fix package name handling. * Bump eBPF kernel-collector to v0.1.0 * Update --help to state eBPF is enabled by default and add --disable-ebpf option in --help output * Remove deprecated kernel version compatibility checks * Fix EBPF_TARBALL * Remove libc path detection logic (deprecated0 * Use the new package structure of kernel-collector * Relax the glob on netdata_ebpf as we may develop/distirbute other types of ebpf programs * Fix ownership of ebpf libraries/programs * Make the check-kernel-config.sh local to the installer * Make plugins.ebpf = yes (by default) Co-authored-by: Thiago Marques <thiagoftsm@gmail.com> Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Diffstat (limited to 'collectors/plugins.d')
-rw-r--r--collectors/plugins.d/plugins_d.c603
1 files changed, 320 insertions, 283 deletions
diff --git a/collectors/plugins.d/plugins_d.c b/collectors/plugins.d/plugins_d.c
index c29fac5fa9..b5b9b1b111 100644
--- a/collectors/plugins.d/plugins_d.c
+++ b/collectors/plugins.d/plugins_d.c
@@ -5,22 +5,24 @@
char *plugin_directories[PLUGINSD_MAX_DIRECTORIES] = { NULL };
struct plugind *pluginsd_root = NULL;
-static inline int pluginsd_space(char c) {
- switch(c) {
- case ' ':
- case '\t':
- case '\r':
- case '\n':
- case '=':
- return 1;
-
- default:
- return 0;
+static inline int pluginsd_space(char c)
+{
+ switch (c) {
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n':
+ case '=':
+ return 1;
+
+ default:
+ return 0;
}
}
-inline int config_isspace(char c) {
- switch(c) {
+inline int config_isspace(char c)
+{
+ switch (c) {
case ' ':
case '\t':
case '\r':
@@ -34,15 +36,17 @@ inline int config_isspace(char c) {
}
// split a text into words, respecting quotes
-static inline int quoted_strings_splitter(char *str, char **words, int max_words, int (*custom_isspace)(char)) {
+static inline int quoted_strings_splitter(char *str, char **words, int max_words, int (*custom_isspace)(char))
+{
char *s = str, quote = 0;
int i = 0, j;
// skip all white space
- while(unlikely(custom_isspace(*s))) s++;
+ while (unlikely(custom_isspace(*s)))
+ s++;
// check for quote
- if(unlikely(*s == '\'' || *s == '"')) {
+ if (unlikely(*s == '\'' || *s == '"')) {
quote = *s; // remember the quote
s++; // skip the quote
}
@@ -51,69 +55,76 @@ static inline int quoted_strings_splitter(char *str, char **words, int max_words
words[i++] = s;
// while we have something
- while(likely(*s)) {
+ while (likely(*s)) {
// if it is escape
- if(unlikely(*s == '\\' && s[1])) {
+ if (unlikely(*s == '\\' && s[1])) {
s += 2;
continue;
}
// if it is quote
- else if(unlikely(*s == quote)) {
+ else if (unlikely(*s == quote)) {
quote = 0;
*s = ' ';
continue;
}
// if it is a space
- else if(unlikely(quote == 0 && custom_isspace(*s))) {
-
+ else if (unlikely(quote == 0 && custom_isspace(*s))) {
// terminate the word
*s++ = '\0';
// skip all white space
- while(likely(custom_isspace(*s))) s++;
+ while (likely(custom_isspace(*s)))
+ s++;
// check for quote
- if(unlikely(*s == '\'' || *s == '"')) {
+ if (unlikely(*s == '\'' || *s == '"')) {
quote = *s; // remember the quote
s++; // skip the quote
}
// if we reached the end, stop
- if(unlikely(!*s)) break;
+ if (unlikely(!*s))
+ break;
// store the next word
- if(likely(i < max_words)) words[i++] = s;
- else break;
+ if (likely(i < max_words))
+ words[i++] = s;
+ else
+ break;
}
// anything else
- else s++;
+ else
+ s++;
}
// terminate the words
j = i;
- while(likely(j < max_words)) words[j++] = NULL;
+ while (likely(j < max_words))
+ words[j++] = NULL;
return i;
}
-inline int pluginsd_initialize_plugin_directories() {
+inline int pluginsd_initialize_plugin_directories()
+{
char plugins_dirs[(FILENAME_MAX * 2) + 1];
static char *plugins_dir_list = NULL;
// Get the configuration entry
- if(likely(!plugins_dir_list)) {
+ if (likely(!plugins_dir_list)) {
snprintfz(plugins_dirs, FILENAME_MAX * 2, "\"%s\" \"%s/custom-plugins.d\"", PLUGINS_DIR, CONFIG_DIR);
- plugins_dir_list = strdupz(config_get(CONFIG_SECTION_GLOBAL, "plugins directory", plugins_dirs));
+ plugins_dir_list = strdupz(config_get(CONFIG_SECTION_GLOBAL, "plugins directory", plugins_dirs));
}
// Parse it and store it to plugin directories
return quoted_strings_splitter(plugins_dir_list, plugin_directories, PLUGINSD_MAX_DIRECTORIES, config_isspace);
}
-inline int pluginsd_split_words(char *str, char **words, int max_words) {
+inline int pluginsd_split_words(char *str, char **words, int max_words)
+{
return quoted_strings_splitter(str, words, max_words, pluginsd_space);
}
@@ -128,28 +139,28 @@ inline int pluginsd_split_words(char *str, char **words, int max_words) {
*
* @return it returns the total of bytes read on success and a negative number otherwise
*/
-int pluginsd_update_buffer(char *output, SSL *ssl) {
+int pluginsd_update_buffer(char *output, SSL *ssl)
+{
ERR_clear_error();
int bytesleft = SSL_read(ssl, output, PLUGINSD_LINE_MAX_SSL_READ);
- if(bytesleft <= 0) {
+ if (bytesleft <= 0) {
int sslerrno = SSL_get_error(ssl, bytesleft);
- switch(sslerrno) {
+ switch (sslerrno) {
case SSL_ERROR_WANT_READ:
- case SSL_ERROR_WANT_WRITE:
- {
+ case SSL_ERROR_WANT_WRITE: {
break;
}
- default:
- {
+ default: {
u_long err;
char buf[256];
int counter = 0;
while ((err = ERR_get_error()) != 0) {
ERR_error_string_n(err, buf, sizeof(buf));
- info("%d SSL Handshake error (%s) on socket %d ", counter++, ERR_error_string((long)SSL_get_error(ssl, bytesleft), NULL), SSL_get_fd(ssl));
+ info(
+ "%d SSL Handshake error (%s) on socket %d ", counter++,
+ ERR_error_string((long)SSL_get_error(ssl, bytesleft), NULL), SSL_get_fd(ssl));
}
}
-
}
} else {
output[bytesleft] = '\0';
@@ -171,14 +182,15 @@ int pluginsd_update_buffer(char *output, SSL *ssl) {
*
* @return It returns a pointer for the next iteration on success and NULL otherwise.
*/
-char * pluginsd_get_from_buffer(char *output, int *bytesread, char *input, SSL *ssl, char *src) {
+char *pluginsd_get_from_buffer(char *output, int *bytesread, char *input, SSL *ssl, char *src)
+{
int copying = 1;
char *endbuffer;
size_t length;
- while(copying) {
- if(*bytesread > 0) {
+ while (copying) {
+ if (*bytesread > 0) {
endbuffer = strchr(input, '\n');
- if(endbuffer) {
+ if (endbuffer) {
copying = 0;
endbuffer++; //Advance due the fact I wanna copy '\n'
length = endbuffer - input;
@@ -188,22 +200,22 @@ char * pluginsd_get_from_buffer(char *output, int *bytesread, char *input, SSL *
output += length;
*output = '\0';
input += length;
- }else {
+ } else {
length = strlen(input);
memcpy(output, input, length);
output += length;
input = src;
*bytesread = pluginsd_update_buffer(input, ssl);
- if(*bytesread <= 0) {
+ if (*bytesread <= 0) {
input = NULL;
copying = 0;
}
}
- }else {
+ } else {
//reduce sample of bytes read, print the length
*bytesread = pluginsd_update_buffer(input, ssl);
- if(*bytesread <= 0) {
+ if (*bytesread <= 0) {
input = NULL;
copying = 0;
}
@@ -214,10 +226,11 @@ char * pluginsd_get_from_buffer(char *output, int *bytesread, char *input, SSL *
}
#endif
-inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int trust_durations) {
+inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int trust_durations)
+{
int enabled = cd->enabled;
- if(!fp || !enabled) {
+ if (!fp || !enabled) {
cd->enabled = 0;
return 0;
}
@@ -244,7 +257,7 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
errno = 0;
clearerr(fp);
- if(unlikely(fileno(fp) == -1)) {
+ if (unlikely(fileno(fp) == -1)) {
error("file descriptor given is not a valid stream");
goto cleanup;
}
@@ -255,24 +268,25 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
char *readfrom = NULL;
#endif
char *r = NULL;
- while(!ferror(fp)) {
- if(unlikely(netdata_exit)) break;
+ while (!ferror(fp)) {
+ if (unlikely(netdata_exit))
+ break;
#ifdef ENABLE_HTTPS
int normalread = 1;
- if(netdata_srv_ctx) {
- if(host->stream_ssl.conn && !host->stream_ssl.flags) {
- if(!bytesleft) {
+ if (netdata_srv_ctx) {
+ if (host->stream_ssl.conn && !host->stream_ssl.flags) {
+ if (!bytesleft) {
r = line;
readfrom = tmpbuffer;
bytesleft = pluginsd_update_buffer(readfrom, host->stream_ssl.conn);
- if(bytesleft <= 0) {
+ if (bytesleft <= 0) {
break;
}
}
- readfrom = pluginsd_get_from_buffer(line, &bytesleft, readfrom, host->stream_ssl.conn, tmpbuffer);
- if(!readfrom) {
+ readfrom = pluginsd_get_from_buffer(line, &bytesleft, readfrom, host->stream_ssl.conn, tmpbuffer);
+ if (!readfrom) {
r = NULL;
}
@@ -280,227 +294,225 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
}
}
- if(normalread) {
+ if (normalread) {
r = fgets(line, PLUGINSD_LINE_MAX, fp);
}
#else
r = fgets(line, PLUGINSD_LINE_MAX, fp);
#endif
- if(unlikely(!r)) {
- if(feof(fp))
+ if (unlikely(!r)) {
+ if (feof(fp))
error("read failed: end of file");
- else if(ferror(fp))
+ else if (ferror(fp))
error("read failed: input error");
else
error("read failed: unknown error");
break;
}
- if(unlikely(netdata_exit)) break;
+ if (unlikely(netdata_exit))
+ break;
line[PLUGINSD_LINE_MAX] = '\0';
int w = pluginsd_split_words(line, words, PLUGINSD_MAX_WORDS);
char *s = words[0];
- if(unlikely(!s || !*s || !w)) {
+ if (unlikely(!s || !*s || !w)) {
continue;
}
// debug(D_PLUGINSD, "PLUGINSD: words 0='%s' 1='%s' 2='%s' 3='%s' 4='%s' 5='%s' 6='%s' 7='%s' 8='%s' 9='%s'", words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9]);
- if(likely(!simple_hash_strcmp(s, "SET", &hash))) {
+ if (likely(!simple_hash_strcmp(s, "SET", &hash))) {
char *dimension = words[1];
char *value = words[2];
- if(unlikely(!dimension || !*dimension)) {
- error("requested a SET on chart '%s' of host '%s', without a dimension. Disabling it.", st->id, host->hostname);
+ if (unlikely(!dimension || !*dimension)) {
+ error(
+ "requested a SET on chart '%s' of host '%s', without a dimension. Disabling it.", st->id,
+ host->hostname);
enabled = 0;
break;
}
- if(unlikely(!value || !*value)) value = NULL;
+ if (unlikely(!value || !*value))
+ value = NULL;
- if(unlikely(!st)) {
- error("requested a SET on dimension %s with value %s on host '%s', without a BEGIN. Disabling it.", dimension, value?value:"<nothing>", host->hostname);
+ if (unlikely(!st)) {
+ error(
+ "requested a SET on dimension %s with value %s on host '%s', without a BEGIN. Disabling it.",
+ dimension, value ? value : "<nothing>", host->hostname);
enabled = 0;
break;
}
- if(unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
- debug(D_PLUGINSD, "is setting dimension %s/%s to %s", st->id, dimension, value?value:"<nothing>");
+ if (unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
+ debug(D_PLUGINSD, "is setting dimension %s/%s to %s", st->id, dimension, value ? value : "<nothing>");
- if(value) {
+ if (value) {
RRDDIM *rd = rrddim_find(st, dimension);
- if(unlikely(!rd)) {
- error("requested a SET to dimension with id '%s' on stats '%s' (%s) on host '%s', which does not exist. Disabling it.", dimension, st->name, st->id, st->rrdhost->hostname);
+ if (unlikely(!rd)) {
+ error(
+ "requested a SET to dimension with id '%s' on stats '%s' (%s) on host '%s', which does not exist. Disabling it.",
+ dimension, st->name, st->id, st->rrdhost->hostname);
enabled = 0;
break;
- }
- else
+ } else
rrddim_set_by_pointer(st, rd, strtoll(value, NULL, 0));
}
- }
- else if(likely(hash == BEGIN_HASH && !strcmp(s, PLUGINSD_KEYWORD_BEGIN))) {
+ } else if (likely(hash == BEGIN_HASH && !strcmp(s, PLUGINSD_KEYWORD_BEGIN))) {
char *id = words[1];
char *microseconds_txt = words[2];
- if(unlikely(!id)) {
+ if (unlikely(!id)) {
error("requested a BEGIN without a chart id for host '%s'. Disabling it.", host->hostname);
enabled = 0;
break;
}
st = rrdset_find(host, id);
- if(unlikely(!st)) {
- error("requested a BEGIN on chart '%s', which does not exist on host '%s'. Disabling it.", id, host->hostname);
+ if (unlikely(!st)) {
+ error(
+ "requested a BEGIN on chart '%s', which does not exist on host '%s'. Disabling it.", id,
+ host->hostname);
enabled = 0;
break;
}
- if(likely(st->counter_done)) {
+ if (likely(st->counter_done)) {
usec_t microseconds = 0;
- if(microseconds_txt && *microseconds_txt) microseconds = str2ull(microseconds_txt);
+ if (microseconds_txt && *microseconds_txt)
+ microseconds = str2ull(microseconds_txt);
- if(likely(microseconds)) {
- if(trust_durations)
+ if (likely(microseconds)) {
+ if (trust_durations)
rrdset_next_usec_unfiltered(st, microseconds);
else
rrdset_next_usec(st, microseconds);
- }
- else rrdset_next(st);
+ } else
+ rrdset_next(st);
}
- }
- else if(likely(hash == END_HASH && !strcmp(s, PLUGINSD_KEYWORD_END))) {
- if(unlikely(!st)) {
+ } else if (likely(hash == END_HASH && !strcmp(s, PLUGINSD_KEYWORD_END))) {
+ if (unlikely(!st)) {
error("requested an END, without a BEGIN on host '%s'. Disabling it.", host->hostname);
enabled = 0;
break;
}
- if(unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
+ if (unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
debug(D_PLUGINSD, "requested an END on chart %s", st->id);
rrdset_done(st);
st = NULL;
count++;
- }
- else if(likely(hash == CHART_HASH && !strcmp(s, PLUGINSD_KEYWORD_CHART))) {
+ } else if (likely(hash == CHART_HASH && !strcmp(s, PLUGINSD_KEYWORD_CHART))) {
st = NULL;
- 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 *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 *plugin = words[11];
- char *module = words[12];
+ char *options = words[10];
+ char *plugin = words[11];
+ char *module = words[12];
// parse the id from type
char *id = NULL;
- if(likely(type && (id = strchr(type, '.')))) {
+ if (likely(type && (id = strchr(type, '.')))) {
*id = '\0';
id++;
}
// make sure we have the required variables
- if(unlikely(!type || !*type || !id || !*id)) {
+ if (unlikely(!type || !*type || !id || !*id)) {
error("requested a CHART, without a type.id, on host '%s'. Disabling it.", host->hostname);
enabled = 0;
break;
}
// parse the name, and make sure it does not include 'type.'
- if(unlikely(name && *name)) {
+ 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] == '.')
+ 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))
+ if (unlikely(strcmp(name, id) == 0 || strcasecmp(name, "NULL") == 0 || strcasecmp(name, "(NULL)") == 0))
name = NULL;
}
int priority = 1000;
- if(likely(priority_s && *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_s)) update_every = str2i(update_every_s);
- if(unlikely(!update_every)) update_every = cd->update_every;
+ 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(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";
-
- debug(D_PLUGINSD, "creating chart type='%s', id='%s', name='%s', family='%s', context='%s', chart='%s', priority=%d, update_every=%d"
- , type, id
- , name?name:""
- , family?family:""
- , context?context:""
- , rrdset_type_name(chart_type)
- , priority
- , update_every
- );
+ if (unlikely(chart))
+ chart_type = rrdset_type_id(chart);
+
+ 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";
+
+ debug(
+ D_PLUGINSD,
+ "creating chart type='%s', id='%s', name='%s', family='%s', context='%s', chart='%s', priority=%d, update_every=%d",
+ type, id, name ? name : "", family ? family : "", context ? context : "", rrdset_type_name(chart_type),
+ priority, update_every);
st = rrdset_create(
- host
- , type
- , id
- , name
- , family
- , context
- , title
- , units
- , (plugin && *plugin)?plugin:cd->filename
- , module
- , priority
- , update_every
- , chart_type
- );
-
- if(options && *options) {
- if(strstr(options, "obsolete"))
+ host, type, id, name, family, context, title, units, (plugin && *plugin) ? plugin : cd->filename,
+ module, priority, update_every, chart_type);
+
+ if (options && *options) {
+ if (strstr(options, "obsolete"))
rrdset_is_obsolete(st);
else
rrdset_isnot_obsolete(st);
- if(strstr(options, "detail"))
+ if (strstr(options, "detail"))
rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
else
rrdset_flag_clear(st, RRDSET_FLAG_DETAIL);
- if(strstr(options, "hidden"))
+ if (strstr(options, "hidden"))
rrdset_flag_set(st, RRDSET_FLAG_HIDDEN);
else
rrdset_flag_clear(st, RRDSET_FLAG_HIDDEN);
- if(strstr(options, "store_first"))
+ if (strstr(options, "store_first"))
rrdset_flag_set(st, RRDSET_FLAG_STORE_FIRST);
else
rrdset_flag_clear(st, RRDSET_FLAG_STORE_FIRST);
- }
- else {
+ } else {
rrdset_isnot_obsolete(st);
rrdset_flag_clear(st, RRDSET_FLAG_DETAIL);
rrdset_flag_clear(st, RRDSET_FLAG_STORE_FIRST);
}
- }
- else if(likely(hash == DIMENSION_HASH && !strcmp(s, PLUGINSD_KEYWORD_DIMENSION))) {
+ } else if (likely(hash == DIMENSION_HASH && !strcmp(s, PLUGINSD_KEYWORD_DIMENSION))) {
char *id = words[1];
char *name = words[2];
char *algorithm = words[3];
@@ -508,122 +520,131 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
char *divisor_s = words[5];
char *options = words[6];
- if(unlikely(!id || !*id)) {
- error("requested a DIMENSION, without an id, host '%s' and chart '%s'. Disabling it.", host->hostname, st?st->id:"UNSET");
+ if (unlikely(!id || !*id)) {
+ error(
+ "requested a DIMENSION, without an id, host '%s' and chart '%s'. Disabling it.", host->hostname,
+ st ? st->id : "UNSET");
enabled = 0;
break;
}
- if(unlikely(!st)) {
+ if (unlikely(!st)) {
error("requested a DIMENSION, without a CHART, on host '%s'. Disabling it.", host->hostname);
enabled = 0;
break;
}
long multiplier = 1;
- if(multiplier_s && *multiplier_s) multiplier = strtol(multiplier_s, NULL, 0);
- if(unlikely(!multiplier)) multiplier = 1;
+ if (multiplier_s && *multiplier_s)
+ multiplier = strtol(multiplier_s, NULL, 0);
+ if (unlikely(!multiplier))
+ multiplier = 1;
long divisor = 1;
- if(likely(divisor_s && *divisor_s)) divisor = strtol(divisor_s, NULL, 0);
- if(unlikely(!divisor)) divisor = 1;
-
- if(unlikely(!algorithm || !*algorithm)) algorithm = "absolute";
-
- if(unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
- debug(D_PLUGINSD, "creating dimension in chart %s, id='%s', name='%s', algorithm='%s', multiplier=%ld, divisor=%ld, hidden='%s'"
- , st->id
- , id
- , name?name:""
- , rrd_algorithm_name(rrd_algorithm_id(algorithm))
- , multiplier
- , divisor
- , options?options:""
- );
+ if (likely(divisor_s && *divisor_s))
+ divisor = strtol(divisor_s, NULL, 0);
+ if (unlikely(!divisor))
+ divisor = 1;
+
+ if (unlikely(!algorithm || !*algorithm))
+ algorithm = "absolute";
+
+ if (unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
+ debug(
+ D_PLUGINSD,
+ "creating dimension in chart %s, id='%s', name='%s', algorithm='%s', multiplier=%ld, divisor=%ld, hidden='%s'",
+ st->id, id, name ? name : "", rrd_algorithm_name(rrd_algorithm_id(algorithm)), multiplier, divisor,
+ options ? options : "");
RRDDIM *rd = rrddim_add(st, id, name, multiplier, divisor, rrd_algorithm_id(algorithm));
rrddim_flag_clear(rd, RRDDIM_FLAG_HIDDEN);
rrddim_flag_clear(rd, RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS);
- if(options && *options) {
- if(strstr(options, "obsolete") != NULL)
+ if (options && *options) {
+ if (strstr(options, "obsolete") != NULL)
rrddim_is_obsolete(st, rd);
else
rrddim_isnot_obsolete(st, rd);
- if(strstr(options, "hidden") != NULL) rrddim_flag_set(rd, RRDDIM_FLAG_HIDDEN);
- if(strstr(options, "noreset") != NULL) rrddim_flag_set(rd, RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS);
- if(strstr(options, "nooverflow") != NULL) rrddim_flag_set(rd, RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS);
- }
- else {
+ if (strstr(options, "hidden") != NULL)
+ rrddim_flag_set(rd, RRDDIM_FLAG_HIDDEN);
+ if (strstr(options, "noreset") != NULL)
+ rrddim_flag_set(rd, RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS);
+ if (strstr(options, "nooverflow") != NULL)
+ rrddim_flag_set(rd, RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS);
+ } else {
rrddim_isnot_obsolete(st, rd);
}
- }
- else if(likely(hash == VARIABLE_HASH && !strcmp(s, PLUGINSD_KEYWORD_VARIABLE))) {
+ } else if (likely(hash == VARIABLE_HASH && !strcmp(s, PLUGINSD_KEYWORD_VARIABLE))) {
char *name = words[1];
char *value = words[2];
- int global = (st)?0:1;
+ int global = (st) ? 0 : 1;
- if(name && *name) {
- if((strcmp(name, "GLOBAL") == 0 || strcmp(name, "HOST") == 0)) {
+ if (name && *name) {
+ if ((strcmp(name, "GLOBAL") == 0 || strcmp(name, "HOST") == 0)) {
global = 1;
name = words[2];
- value = words[3];
- }
- else if((strcmp(name, "LOCAL") == 0 || strcmp(name, "CHART") == 0)) {
+ value = words[3];
+ } else if ((strcmp(name, "LOCAL") == 0 || strcmp(name, "CHART") == 0)) {
global = 0;
name = words[2];
- value = words[3];
+ value = words[3];
}
}
- if(unlikely(!name || !*name)) {
+ if (unlikely(!name || !*name)) {
error("requested a VARIABLE on host '%s', without a variable name. Disabling it.", host->hostname);
enabled = 0;
break;
}
- if(unlikely(!value || !*value))
+ if (unlikely(!value || !*value))
value = NULL;
- if(value) {
+ if (value) {
char *endptr = NULL;
calculated_number v = (calculated_number)str2ld(value, &endptr);
- if(unlikely(endptr && *endptr)) {
- if(endptr == value)
- error("the value '%s' of VARIABLE '%s' on host '%s' cannot be parsed as a number", value, name, host->hostname);
+ if (unlikely(endptr && *endptr)) {
+ if (endptr == value)
+ error(
+ "the value '%s' of VARIABLE '%s' on host '%s' cannot be parsed as a number", value, name,
+ host->hostname);
else
- error("the value '%s' of VARIABLE '%s' on host '%s' has leftovers: '%s'", value, name, host->hostname, endptr);
+ error(
+ "the value '%s' of VARIABLE '%s' on host '%s' has leftovers: '%s'", value, name,
+ host->hostname, endptr);
}
- if(global) {
+ if (global) {
RRDVAR *rv = rrdvar_custom_host_variable_create(host, name);
- if (rv) rrdvar_custom_host_variable_set(host, rv, v);
- else error("cannot find/create HOST VARIABLE '%s' on host '%s'", name, host->hostname);
- }
- else if(st) {
+ if (rv)
+ rrdvar_custom_host_variable_set(host, rv, v);
+ else
+ error("cannot find/create HOST VARIABLE '%s' on host '%s'", name, host->hostname);
+ } else if (st) {
RRDSETVAR *rs = rrdsetvar_custom_chart_variable_create(st, name);
- if (rs) rrdsetvar_custom_chart_variable_set(rs, v);
- else error("cannot find/create CHART VARIABLE '%s' on host '%s', chart '%s'", name, host->hostname, st->id);
- }
- else
+ if (rs)
+ rrdsetvar_custom_chart_variable_set(rs, v);
+ else
+ error(
+ "cannot find/create CHART VARIABLE '%s' on host '%s', chart '%s'", name, host->hostname,
+ st->id);
+ } else
error("cannot find/create CHART VARIABLE '%s' on host '%s' without a chart", name, host->hostname);
- }
- else
- error("cannot set %s VARIABLE '%s' on host '%s' to an empty value", (global)?"HOST":"CHART", name, host->hostname);
- }
- else if(likely(hash == FLUSH_HASH && !strcmp(s, PLUGINSD_KEYWORD_FLUSH))) {
+ } else
+ error(
+ "cannot set %s VARIABLE '%s' on host '%s' to an empty value", (global) ? "HOST" : "CHART", name,
+ host->hostname);
+ } else if (likely(hash == FLUSH_HASH && !strcmp(s, PLUGINSD_KEYWORD_FLUSH))) {
debug(D_PLUGINSD, "requested a FLUSH");
st = NULL;
- }
- else if(unlikely(hash == DISABLE_HASH && !strcmp(s, PLUGINSD_KEYWORD_DISABLE))) {
+ } else if (unlikely(hash == DISABLE_HASH && !strcmp(s, PLUGINSD_KEYWORD_DISABLE))) {
info("called DISABLE. Disabling it.");
enabled = 0;
break;
- }
- else if(likely(hash == LABEL_HASH && !strcmp(s, PLUGINSD_KEYWORD_LABEL))) {
+ } else if (likely(hash == LABEL_HASH && !strcmp(s, PLUGINSD_KEYWORD_LABEL))) {
debug(D_PLUGINSD, "requested a LABEL CHANGE");
char *store;
- if(!words[4])
+ if (!words[4])
store = words[3];
else {
store = callocz(PLUGINSD_LINE_MAX + 1, sizeof(char));
@@ -635,13 +656,13 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
if ((length + 1) >= remaining)
break;
- remaining -= (length +1);
+ remaining -= (length + 1);