Add apps grouping debug messages (#6375)
Vladimir Kobal committed
Jul 10, 2019 at 10:31 UTC
a83b39285a36eaba8fc316b852c9c0f8070ffe1c
1 file changed
+39
-1
collectors/apps.plugin/apps_plugin.c
+39
-1
@@ -191,6 +191,12 @@ double utime_fix_ratio = 1.0,
191
cminflt_fix_ratio = 1.0,
192
cmajflt_fix_ratio = 1.0;
193
194
+
195
+struct pid_on_target {
196
+ int32_t pid;
197
+ struct pid_on_target *next;
198
+};
199
+
200
// ----------------------------------------------------------------------------
201
// target
202
//
@@ -262,6 +268,8 @@ struct target {
268
int starts_with; // if set, the compare string matches only the
269
// beginning of the command
270
271
+ struct pid_on_target *root_pid; // list of aggregated pids for target debugging
272
+
273
struct target *target; // the one that will be reported to netdata
274
struct target *next;
275
};
@@ -2657,6 +2665,18 @@ static size_t zero_all_targets(struct target *root) {
2665
w->openeventpolls = 0;
2666
w->openother = 0;
2667
}
2668
+
2669
+ if(unlikely(w->root_pid)) {
2670
+ struct pid_on_target *pid_on_target_to_free, *pid_on_target = w->root_pid;
2671
+
2672
+ while(pid_on_target) {
2673
+ pid_on_target_to_free = pid_on_target;
2674
+ pid_on_target = pid_on_target->next;
2675
+ free(pid_on_target_to_free);
2676
+ }
2677
+
2678
+ w->root_pid = NULL;
2679
+ }
2680
}
2681
2682
return count;
@@ -2799,8 +2819,14 @@ static inline void aggregate_pid_on_target(struct target *w, struct pid_stat *p,
2819
w->processes++;
2820
w->num_threads += p->num_threads;
2821
2802
- if(unlikely(debug_enabled || w->debug_enabled))
2822
+ if(unlikely(debug_enabled || w->debug_enabled)) {
2823
debug_log_int("aggregating '%s' pid %d on target '%s' utime=" KERNEL_UINT_FORMAT ", stime=" KERNEL_UINT_FORMAT ", gtime=" KERNEL_UINT_FORMAT ", cutime=" KERNEL_UINT_FORMAT ", cstime=" KERNEL_UINT_FORMAT ", cgtime=" KERNEL_UINT_FORMAT ", minflt=" KERNEL_UINT_FORMAT ", majflt=" KERNEL_UINT_FORMAT ", cminflt=" KERNEL_UINT_FORMAT ", cmajflt=" KERNEL_UINT_FORMAT "", p->comm, p->pid, w->name, p->utime, p->stime, p->gtime, p->cutime, p->cstime, p->cgtime, p->minflt, p->majflt, p->cminflt, p->cmajflt);
2824
+
2825
+ struct pid_on_target *pid_on_target = mallocz(sizeof(struct pid_on_target));
2826
+ pid_on_target->pid = p->pid;
2827
+ pid_on_target->next = w->root_pid;
2828
+ w->root_pid = pid_on_target;
2829
+ }
2830
}
2831
2832
static void calculate_netdata_statistics(void) {
@@ -3321,6 +3347,18 @@ static void send_charts_updates_to_netdata(struct target *root, const char *type
3347
for(w = root ; w ; w = w->next) {
3348
if (w->target) continue;
3349
3350
+ if(unlikely(w->processes && (debug_enabled || w->debug_enabled))) {
3351
+ struct pid_on_target *pid_on_target;
3352
+
3353
+ fprintf(stderr, "apps.plugin: target '%s' has aggregated %u process%s:", w->name, w->processes, (w->processes == 1)?"":"es");
3354
+
3355
+ for(pid_on_target = w->root_pid; pid_on_target; pid_on_target = pid_on_target->next) {
3356
+ fprintf(stderr, " %d", pid_on_target->pid);
3357
+ }
3358
+
3359
+ fputc('\n', stderr);
3360
+ }
3361
+
3362
if (!w->exposed && w->processes) {
3363
newly_added++;
3364
w->exposed = 1;