]> arthur.barton.de Git - netdata.git/blobdiff - src/main.c
do not calculate tc leafs and parents if enabled_all_classes_qdiscs is enabled
[netdata.git] / src / main.c
index fdedb08129ce9e0a3253e0be1390cc7532e07498..18ad78a8dd0bbdf37cc2488f39d1c3591519f6bc 100644 (file)
@@ -46,8 +46,8 @@ struct netdata_static_thread static_threads[] = {
 #else
     {"proc",               "plugins",   "proc",       1, NULL, NULL, proc_main},
     {"diskspace",          "plugins",   "diskspace",  1, NULL, NULL, proc_diskspace_main},
-#endif /* __FreeBSD__, __APPLE__*/
     {"cgroups",            "plugins",   "cgroups",    1, NULL, NULL, cgroups_main},
+#endif /* __FreeBSD__, __APPLE__*/
     {"check",              "plugins",   "checks",     0, NULL, NULL, checks_main},
     {"backends",            NULL,       NULL,         1, NULL, NULL, backends_main},
     {"health",              NULL,       NULL,         1, NULL, NULL, health_main},
@@ -77,15 +77,15 @@ void web_server_threading_selection(void) {
     web_enable_gzip = config_get_boolean("global", "enable web responses gzip compression", web_enable_gzip);
 
     char *s = config_get("global", "web compression strategy", "default");
-    if(!strsame(s, "default"))
+    if(!strcmp(s, "default"))
         web_gzip_strategy = Z_DEFAULT_STRATEGY;
-    else if(!strsame(s, "filtered"))
+    else if(!strcmp(s, "filtered"))
         web_gzip_strategy = Z_FILTERED;
-    else if(!strsame(s, "huffman only"))
+    else if(!strcmp(s, "huffman only"))
         web_gzip_strategy = Z_HUFFMAN_ONLY;
-    else if(!strsame(s, "rle"))
+    else if(!strcmp(s, "rle"))
         web_gzip_strategy = Z_RLE;
-    else if(!strsame(s, "fixed"))
+    else if(!strcmp(s, "fixed"))
         web_gzip_strategy = Z_FIXED;
     else {
         error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.", s);
@@ -161,17 +161,19 @@ void kill_childs()
         pthread_cancel(w->thread);
         // it is detached
         // pthread_join(w->thread, NULL);
+
+        w->obsolete = 1;
     }
 
     int i;
     for (i = 0; static_threads[i].name != NULL ; i++) {
-        if(static_threads[i].enabled && static_threads[i].thread) {
+        if(static_threads[i].enabled) {
             info("Stopping %s thread", static_threads[i].name);
             pthread_cancel(*static_threads[i].thread);
             // it is detached
             // pthread_join(*static_threads[i].thread, NULL);
 
-            static_threads[i].thread = NULL;
+            static_threads[i].enabled = 0;
         }
     }
 
@@ -179,19 +181,15 @@ void kill_childs()
         info("Killing tc-qos-helper process %d", tc_child_pid);
         if(killpid(tc_child_pid, SIGTERM) != -1)
             waitid(P_PID, (id_t) tc_child_pid, &info, WEXITED);
+
+        tc_child_pid = 0;
     }
-    tc_child_pid = 0;
 
     struct plugind *cd;
     for(cd = pluginsd_root ; cd ; cd = cd->next) {
         if(cd->enabled && !cd->obsolete) {
-            if(cd->thread != (pthread_t)NULL) {
-                info("Stopping %s plugin thread", cd->id);
-                pthread_cancel(cd->thread);
-                // they are detached
-                // pthread_join(cd->thread, NULL);
-                cd->thread = (pthread_t)NULL;
-            }
+            info("Stopping %s plugin thread", cd->id);
+            pthread_cancel(cd->thread);
 
             if(cd->pid) {
                 info("killing %s plugin child process pid %d", cd->id, cd->pid);
@@ -257,7 +255,7 @@ void help(int exitcode) {
             " |   '-'   '-'   '-'   '-'   real-time performance monitoring, done right!   \n"
             " +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->\n"
             "\n"
-            " Copyright (C) 2017, Costa Tsaousis <costa@tsaousis.gr>\n"
+            " Copyright (C) 2016-2017, Costa Tsaousis <costa@tsaousis.gr>\n"
             " Released under GNU Public License v3 or later.\n"
             " All rights reserved.\n"
             "\n"
@@ -340,6 +338,7 @@ int main(int argc, char **argv)
     int i, check_config = 0;
     int config_loaded = 0;
     int dont_fork = 0;
+    int oom_score = 1000;
     size_t wanted_stacksize = 0, stacksize = 0;
     pthread_attr_t attr;
 
@@ -351,22 +350,22 @@ int main(int argc, char **argv)
     {
         i = 1;
         while(i < argc) {
-            if(strsame(argv[i], "-pidfile") == 0 && (i+1) < argc) {
+            if(strcmp(argv[i], "-pidfile") == 0 && (i+1) < argc) {
                 strncpyz(pidfile, argv[i+1], FILENAME_MAX);
                 fprintf(stderr, "%s: deprecated option -- %s -- please use -P instead.\n", argv[0], argv[i]);
                 remove_option(i, &argc, argv);
             }
-            else if(strsame(argv[i], "-nodaemon") == 0 || strsame(argv[i], "-nd") == 0) {
+            else if(strcmp(argv[i], "-nodaemon") == 0 || strcmp(argv[i], "-nd") == 0) {
                 dont_fork = 1;
                 fprintf(stderr, "%s: deprecated option -- %s -- please use -D instead.\n ", argv[0], argv[i]);
                 remove_option(i, &argc, argv);
             }
-            else if(strsame(argv[i], "-ch") == 0 && (i+1) < argc) {
+            else if(strcmp(argv[i], "-ch") == 0 && (i+1) < argc) {
                 config_set("global", "host access prefix", argv[i+1]);
                 fprintf(stderr, "%s: deprecated option -- %s -- please use -s instead.\n", argv[0], argv[i]);
                 remove_option(i, &argc, argv);
             }
-            else if(strsame(argv[i], "-l") == 0 && (i+1) < argc) {
+            else if(strcmp(argv[i], "-l") == 0 && (i+1) < argc) {
                 config_set("global", "history", argv[i+1]);
                 fprintf(stderr, "%s: deprecated option -- %s -- This option will be removed with V2.*.\n", argv[0], argv[i]);
                 remove_option(i, &argc, argv);
@@ -443,14 +442,14 @@ int main(int argc, char **argv)
                     {
                         char* stacksize_string = "stacksize=";
                         char* debug_flags_string = "debug_flags=";
-                        if(strsame(optarg, "unittest") == 0) {
+                        if(strcmp(optarg, "unittest") == 0) {
                             rrd_update_every = 1;
                             if(run_all_mockup_tests()) exit(1);
                             if(unit_test_storage()) exit(1);
                             fprintf(stderr, "\n\nALL TESTS PASSED\n\n");
                             exit(0);
                         }
-                        else if(strsame(optarg, "simple-pattern") == 0) {
+                        else if(strcmp(optarg, "simple-pattern") == 0) {
                             if(optind + 2 > argc) {
                                 fprintf(stderr, "%s", "\nUSAGE: -W simple-pattern 'pattern' 'string'\n\n"
                                         " Checks if 'pattern' matches the given 'string'.\n"
@@ -554,6 +553,10 @@ int main(int argc, char **argv)
         if(!p) p = "/bin:/usr/bin";
         snprintfz(path, 1024, "%s:%s", p, "/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
         setenv("PATH", config_get("plugins", "PATH environment variable", path), 1);
+
+        p = getenv("PYTHONPATH");
+        if(!p) p = "";
+        setenv("PYTHONPATH", config_get("plugins", "PYTHONPATH environment variable", p), 1);
     }
 
     char *user = NULL;
@@ -614,6 +617,7 @@ int main(int argc, char **argv)
         // --------------------------------------------------------------------
 
         rrd_memory_mode = rrd_memory_mode_id(config_get("global", "memory mode", rrd_memory_mode_name(rrd_memory_mode)));
+        oom_score = (int)config_get_number("global", "OOM score", oom_score);
 
         // --------------------------------------------------------------------
 
@@ -753,7 +757,7 @@ int main(int argc, char **argv)
 #endif /* NETDATA_INTERNAL_CHECKS */
 
     // fork, switch user, create pid file, set process priority
-    if(become_daemon(dont_fork, user) == -1)
+    if(become_daemon(dont_fork, user, oom_score) == -1)
         fatal("Cannot daemonize myself.");
 
     info("netdata started on pid %d.", getpid());