@cryptotaxi247 / netdata-1 / commits / 2cf34e8e2

added command line options with-guest and without-guest to enable or disable the separate guest charts; fixes #729

Costa Tsaousis committed Jul 27, 2016 at 13:37 UTC 2cf34e8e2b11d1b693350ea244bb70107f1220a9
1 file changed +25 -9
src/apps_plugin.c
+25 -9
@@ -71,6 +71,8 @@ pid_t *all_pids_sortlist = NULL;
71 int show_guest_time = 0;
72 int show_guest_time_old = 0;
73
74 +int enable_guest_charts = 0;
75 +
76 // ----------------------------------------------------------------------------
77
78 void netdata_cleanup_and_exit(int ret) {
@@ -788,11 +790,13 @@ int read_proc_pid_stat(struct pid_stat *p) {
790 p->cgtime_raw = strtoull(procfile_lineword(ff, 0, 43), NULL, 10);
791 p->cgtime = (p->cgtime_raw - last) * (1000000ULL * RATES_DETAIL) / (p->stat_collected_usec - p->last_stat_collected_usec);
792
791 - if(show_guest_time || p->gtime || p->cgtime) {
792 - p->utime -= (p->utime >= p->gtime )?p->gtime :p->utime;
793 - p->cutime -= (p->cutime >= p->cgtime)?p->cgtime:p->cutime;
794 - show_guest_time = 1;
795 - }
793 + if(enable_guest_charts) {
794 + if (show_guest_time || p->gtime || p->cgtime) {
795 + p->utime -= (p->utime >= p->gtime) ? p->gtime : p->utime;
796 + p->cutime -= (p->cutime >= p->cgtime) ? p->cgtime : p->cutime;
797 + show_guest_time = 1;
798 + }
799 + }
800
801 if(unlikely(debug || (p->target && p->target->debug)))
802 fprintf(stderr, "apps.plugin: READ PROC/PID/STAT: %s/proc/%d/stat, process: '%s' on target '%s' (dt=%llu) VALUES: utime=%llu, stime=%llu, cutime=%llu, cstime=%llu, minflt=%llu, majflt=%llu, cminflt=%llu, cmajflt=%llu, threads=%d\n", host_prefix, p->pid, p->comm, (p->target)?p->target->name:"UNSET", p->stat_collected_usec - p->last_stat_collected_usec, p->utime, p->stime, p->cutime, p->cstime, p->minflt, p->majflt, p->cminflt, p->cmajflt, p->num_threads);
@@ -989,8 +993,10 @@ int read_proc_stat() {
993 gntime_raw = strtoull(procfile_lineword(ff, 0, 11), NULL, 10);
994 global_gtime += (gntime_raw - last) * (1000000ULL * RATES_DETAIL) / (collected_usec - last_collected_usec);
995
992 - // remove guest time from user time
993 - global_utime -= (global_utime > global_gtime)?global_gtime:global_utime;
996 + if(enable_guest_charts) {
997 + // remove guest time from user time
998 + global_utime -= (global_utime > global_gtime) ? global_gtime : global_utime;
999 + }
1000
1001 if(unlikely(global_iterations_counter == 1)) {
1002 global_utime = 0;
@@ -2725,7 +2731,7 @@ void parse_args(int argc, char **argv)
2731 continue;
2732 }
2733
2728 - if(strcmp("no-childs", argv[i]) == 0) {
2734 + if(strcmp("no-childs", argv[i]) == 0 || strcmp("without-childs", argv[i]) == 0) {
2735 include_exited_childs = 0;
2736 continue;
2737 }
@@ -2735,7 +2741,17 @@ void parse_args(int argc, char **argv)
2741 continue;
2742 }
2743
2738 - if(!name) {
2744 + if(strcmp("with-guest", argv[i]) == 0) {
2745 + enable_guest_charts = 1;
2746 + continue;
2747 + }
2748 +
2749 + if(strcmp("no-guest", argv[i]) == 0 || strcmp("without-guest", argv[i]) == 0) {
2750 + enable_guest_charts = 0;
2751 + continue;
2752 + }
2753 +
2754 + if(!name) {
2755 name = argv[i];
2756 continue;
2757 }