in_cpu: fix missing PID CPU load on initialization
@@ -549,12 +549,18 @@ static int cb_cpu_init(struct flb_input_instance *in,
}
/* Get CPU load, ready to be updated once fired the calc callback */
+ if (ctx->pid > 0) {
+ ret = proc_cpu_pid_load(ctx, ctx->pid, &ctx->cstats);
+ }
+ else {
ret = proc_cpu_load(ctx->n_processors, &ctx->cstats);
+ }
if (ret != 0) {
flb_error("[cpu] Could not obtain CPU data");
flb_free(ctx);
return -1;
}
+
ctx->cstats.snap_active = CPU_SNAP_ACTIVE_B;
/* Set the context */
