@cryptotaxi247 / netdata-1 / commits / 5ad1c48f6

added command line option without-files to disable files, pipes, sockets processing; fixes #744

Costa Tsaousis committed Aug 14, 2016 at 18:48 UTC 5ad1c48f63bd8b9ce4c4374127170d69651822b0
1 file changed +55 -32
src/apps_plugin.c
+55 -32
@@ -32,6 +32,7 @@ int show_guest_time = 0;
32 int show_guest_time_old = 0;
33
34 int enable_guest_charts = 0;
35 +int enable_file_charts = 1;
36
37 // ----------------------------------------------------------------------------
38
@@ -1705,7 +1706,8 @@ void collect_data_for_pid(pid_t pid) {
1706 // --------------------------------------------------------------------
1707 // /proc/<pid>/fd
1708
1708 - managed_log(p, PID_LOG_FDS, read_pid_file_descriptors(p));
1709 + if(enable_file_charts)
1710 + managed_log(p, PID_LOG_FDS, read_pid_file_descriptors(p));
1711
1712 // --------------------------------------------------------------------
1713 // done!
@@ -2534,26 +2536,28 @@ void send_collected_data_to_netdata(struct target *root, const char *type, unsig
2536 }
2537 send_END();
2538
2537 - send_BEGIN(type, "files", usec);
2538 - for (w = root; w ; w = w->next) {
2539 - if(unlikely(w->exposed))
2540 - send_SET(w->name, w->openfiles);
2541 - }
2542 - send_END();
2539 + if(enable_file_charts) {
2540 + send_BEGIN(type, "files", usec);
2541 + for (w = root; w; w = w->next) {
2542 + if (unlikely(w->exposed))
2543 + send_SET(w->name, w->openfiles);
2544 + }
2545 + send_END();
2546
2544 - send_BEGIN(type, "sockets", usec);
2545 - for (w = root; w ; w = w->next) {
2546 - if(unlikely(w->exposed))
2547 - send_SET(w->name, w->opensockets);
2548 - }
2549 - send_END();
2547 + send_BEGIN(type, "sockets", usec);
2548 + for (w = root; w; w = w->next) {
2549 + if (unlikely(w->exposed))
2550 + send_SET(w->name, w->opensockets);
2551 + }
2552 + send_END();
2553
2551 - send_BEGIN(type, "pipes", usec);
2552 - for (w = root; w ; w = w->next) {
2553 - if(unlikely(w->exposed))
2554 - send_SET(w->name, w->openpipes);
2554 + send_BEGIN(type, "pipes", usec);
2555 + for (w = root; w; w = w->next) {
2556 + if (unlikely(w->exposed))
2557 + send_SET(w->name, w->openpipes);
2558 + }
2559 + send_END();
2560 }
2556 - send_END();
2561 }
2562
2563
@@ -2660,22 +2664,27 @@ void send_charts_updates_to_netdata(struct target *root, const char *type, const
2664 buffer_sprintf(output, "DIMENSION %s '' absolute 1 %llu\n", w->name, 1024LLU * RATES_DETAIL);
2665 }
2666
2663 - buffer_sprintf(output, "CHART %s.files '' '%s Open Files' 'open files' disk %s.files stacked 20050 %d\n", type, title, type, update_every);
2664 - for (w = root; w ; w = w->next) {
2665 - if(unlikely(w->exposed))
2666 - buffer_sprintf(output, "DIMENSION %s '' absolute 1 1\n", w->name);
2667 - }
2667 + if(enable_file_charts) {
2668 + buffer_sprintf(output, "CHART %s.files '' '%s Open Files' 'open files' disk %s.files stacked 20050 %d\n", type,
2669 + title, type, update_every);
2670 + for (w = root; w; w = w->next) {
2671 + if (unlikely(w->exposed))
2672 + buffer_sprintf(output, "DIMENSION %s '' absolute 1 1\n", w->name);
2673 + }
2674
2669 - buffer_sprintf(output, "CHART %s.sockets '' '%s Open Sockets' 'open sockets' net %s.sockets stacked 20051 %d\n", type, title, type, update_every);
2670 - for (w = root; w ; w = w->next) {
2671 - if(unlikely(w->exposed))
2672 - buffer_sprintf(output, "DIMENSION %s '' absolute 1 1\n", w->name);
2673 - }
2675 + buffer_sprintf(output, "CHART %s.sockets '' '%s Open Sockets' 'open sockets' net %s.sockets stacked 20051 %d\n",
2676 + type, title, type, update_every);
2677 + for (w = root; w; w = w->next) {
2678 + if (unlikely(w->exposed))
2679 + buffer_sprintf(output, "DIMENSION %s '' absolute 1 1\n", w->name);
2680 + }
2681
2675 - buffer_sprintf(output, "CHART %s.pipes '' '%s Pipes' 'open pipes' processes %s.pipes stacked 20053 %d\n", type, title, type, update_every);
2676 - for (w = root; w ; w = w->next) {
2677 - if(unlikely(w->exposed))
2678 - buffer_sprintf(output, "DIMENSION %s '' absolute 1 1\n", w->name);
2682 + buffer_sprintf(output, "CHART %s.pipes '' '%s Pipes' 'open pipes' processes %s.pipes stacked 20053 %d\n", type,
2683 + title, type, update_every);
2684 + for (w = root; w; w = w->next) {
2685 + if (unlikely(w->exposed))
2686 + buffer_sprintf(output, "DIMENSION %s '' absolute 1 1\n", w->name);
2687 + }
2688 }
2689 }
2690
@@ -2723,6 +2732,16 @@ void parse_args(int argc, char **argv)
2732 continue;
2733 }
2734
2735 + if(strcmp("with-files", argv[i]) == 0) {
2736 + enable_file_charts = 1;
2737 + continue;
2738 + }
2739 +
2740 + if(strcmp("no-files", argv[i]) == 0 || strcmp("without-files", argv[i]) == 0) {
2741 + enable_file_charts = 0;
2742 + continue;
2743 + }
2744 +
2745 if(strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
2746 fprintf(stderr,
2747 "apps.plugin\n"
@@ -2745,6 +2764,10 @@ void parse_args(int argc, char **argv)
2764 "without-guest enable / disable reporting guest charts\n"
2765 " (default is disabled)\n"
2766 "\n"
2767 + "with-files\n"
2768 + "without-files enable / disable reporting files, sockets, pipes\n"
2769 + " (default is enabled)\n"
2770 + "\n"
2771 "NAME read apps_NAME.conf instead of\n"
2772 " apps_groups.conf\n"
2773 " (default NAME=groups)\n"