summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorVladimir Kobal <vlad@prokk.net>2019-05-13 15:12:25 +0300
committerChris Akritidis <43294513+cakrit@users.noreply.github.com>2019-05-13 14:12:25 +0200
commit51decad9896131ed478681d90886d63bbd953b14 (patch)
tree25c0360f1d470619c407df805de74b7f4c44b744 /daemon
parentf3473aa8466d73e0a26b437b8494f45030eec89c (diff)
Add system info streaming (#5996)
* Add system info streaming * Fix segmentation fault in unit testing
Diffstat (limited to 'daemon')
-rw-r--r--daemon/main.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/daemon/main.c b/daemon/main.c
index a6d6a7e7ae..fe9e9963c1 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -650,7 +650,7 @@ static int load_netdata_conf(char *filename, char overwrite_used) {
return ret;
}
-int get_system_info () {
+int get_system_info(struct rrdhost_system_info *system_info) {
char *script;
script = mallocz(sizeof(char) * (strlen(netdata_configured_primary_plugins_dir) + strlen("system-info.sh") + 2));
sprintf(script, "%s/%s", netdata_configured_primary_plugins_dir, "system-info.sh");
@@ -679,10 +679,15 @@ int get_system_info () {
(*newline) = '\0';
}
char n[51], v[101];
- snprintfz(n,50,"%s",name);
- snprintfz(v,101,"%s",value);
- info("%s=%s", n, v);
- setenv(n, v, 1);
+ snprintfz(n, 50,"%s",name);
+ snprintfz(v, 101,"%s",value);
+ if(unlikely(rrdhost_set_system_info_variable(system_info, n, v))) {
+ info("Unexpected environment variable %s=%s", n, v);
+ }
+ else {
+ info("%s=%s", n, v);
+ setenv(n, v, 1);
+ }
}
}
mypclose(fp, command_pid);
@@ -844,7 +849,7 @@ int main(int argc, char **argv) {
default_rrd_update_every = 1;
default_rrd_memory_mode = RRD_MEMORY_MODE_RAM;
default_health_enabled = 0;
- rrd_init("unittest");
+ rrd_init("unittest", NULL);
default_rrdpush_enabled = 0;
if(run_all_mockup_tests()) return 1;
if(unit_test_storage()) return 1;
@@ -1093,8 +1098,10 @@ int main(int argc, char **argv) {
// initialize the log files
open_all_log_files();
+
netdata_anonymous_statistics_enabled=-1;
- if (get_system_info() == 0) send_statistics("START","-", "-");
+ struct rrdhost_system_info *system_info = calloc(1, sizeof(struct rrdhost_system_info));
+ if (get_system_info(system_info) == 0) send_statistics("START","-", "-");
#ifdef NETDATA_INTERNAL_CHECKS
if(debug_flags != 0) {
@@ -1129,14 +1136,14 @@ int main(int argc, char **argv) {
// ------------------------------------------------------------------------
// initialize rrd, registry, health, rrdpush, etc.
- rrd_init(netdata_configured_hostname);
+ rrd_init(netdata_configured_hostname, system_info);
+ rrdhost_system_info_free(system_info);
// ------------------------------------------------------------------------
// enable log flood protection
error_log_limit_reset();
-
// ------------------------------------------------------------------------
// spawn the threads