diff --git a/src/cpu.c b/src/cpu.c
index bee6f177c11a6f3a3c81535de070e4b0e25b8088..57af2dd7f26b105f5aab16fabbc04b53a6342660 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
DEBUG ("host_processors returned %i %s", (int) cpu_list_len, cpu_list_len == 1 ? "processor" : "processors");
INFO ("cpu plugin: Found %i processor%s.", (int) cpu_list_len, cpu_list_len == 1 ? "" : "s");
DEBUG ("host_processors returned %i %s", (int) cpu_list_len, cpu_list_len == 1 ? "processor" : "processors");
INFO ("cpu plugin: Found %i processor%s.", (int) cpu_list_len, cpu_list_len == 1 ? "" : "s");
-
- cpu_temp_retry_max = 86400 / CDTIME_T_TO_TIME_T (plugin_get_interval ());
/* #endif PROCESSOR_CPU_LOAD_INFO */
#elif defined(HAVE_LIBKSTAT)
/* #endif PROCESSOR_CPU_LOAD_INFO */
#elif defined(HAVE_LIBKSTAT)
RATE_ADD (this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate, this_cpu_states[state].rate);
}
RATE_ADD (this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate, this_cpu_states[state].rate);
}
+ if (!isnan (this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate))
+ this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].has_value = 1;
+
RATE_ADD (sum_by_state[COLLECTD_CPU_STATE_ACTIVE], this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate);
}
} /* }}} void aggregate */
RATE_ADD (sum_by_state[COLLECTD_CPU_STATE_ACTIVE], this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate);
}
} /* }}} void aggregate */
for (state = 0; state < COLLECTD_CPU_STATE_ACTIVE; state++)
{
size_t cpu_num;
for (state = 0; state < COLLECTD_CPU_STATE_ACTIVE; state++)
{
size_t cpu_num;
- if (report_by_cpu) {
- for (cpu_num = 0; cpu_num < global_cpu_num; cpu_num++)
- {
- cpu_state_t *s = get_cpu_state (cpu_num, state);
-
- if (!s->has_value)
- continue;
-
- submit_derive ((int) cpu_num, (int) state, s->conv.last_value.derive);
- }
- } else {
- derive_t derive_total = 0;
- for (cpu_num = 0; cpu_num < global_cpu_num; cpu_num++)
- {
- cpu_state_t *s = get_cpu_state (cpu_num, state);
- if (!s->has_value)
- continue;
+ for (cpu_num = 0; cpu_num < global_cpu_num; cpu_num++)
+ {
+ cpu_state_t *s = get_cpu_state (cpu_num, state);
- derive_total += s->conv.last_value.derive;
+ if (!s->has_value)
+ continue;
- }
- submit_derive (-1, (int) state, derive_total);
+ submit_derive ((int) cpu_num, (int) state, s->conv.last_value.derive);
}
}
} /* }}} void cpu_commit_without_aggregation */
}
}
} /* }}} void cpu_commit_without_aggregation */
static void cpu_commit (void) /* {{{ */
{
gauge_t global_rates[COLLECTD_CPU_STATE_MAX] = {
static void cpu_commit (void) /* {{{ */
{
gauge_t global_rates[COLLECTD_CPU_STATE_MAX] = {
- NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN
+ NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN /* Batman! */
};
size_t cpu_num;
};
size_t cpu_num;
- if (report_by_state && !report_percent)
+ if (report_by_state && report_by_cpu && !report_percent)
{
cpu_commit_without_aggregation ();
return;
{
cpu_commit_without_aggregation ();
return;
};
size_t state;
};
size_t state;
- for (state = 0; state < COLLECTD_CPU_STATE_ACTIVE; state++)
+ for (state = 0; state < COLLECTD_CPU_STATE_MAX; state++)
if (this_cpu_states[state].has_value)
local_rates[state] = this_cpu_states[state].rate;
if (this_cpu_states[state].has_value)
local_rates[state] = this_cpu_states[state].rate;