X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcpufreq.c;h=35ec07fbc98c3ef798f200972310a1967ca5d08f;hb=6378ec288f34ff250b2971a1452338a2b34c240a;hp=3e3244cc41f38dfd33f118991b24ef3de2183710;hpb=1c6fdbaea6ad42c41cd63006a3c8abbdefa391db;p=collectd.git diff --git a/src/cpufreq.c b/src/cpufreq.c index 3e3244cc..35ec07fb 100644 --- a/src/cpufreq.c +++ b/src/cpufreq.c @@ -22,8 +22,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #define MAX_AVAIL_FREQS 20 @@ -37,7 +37,7 @@ struct cpu_data_t { static bool report_p_stats = false; static void cpufreq_stats_init(void) { - cpu_data = calloc(num_cpu, sizeof(struct cpu_data_t)); + cpu_data = calloc(num_cpu, sizeof(*cpu_data)); if (cpu_data == NULL) return; @@ -172,6 +172,12 @@ static void cpufreq_read_stats(int cpu) { gauge_t g; if (value_to_rate(&g, (value_t){.derive = time}, DS_TYPE_DERIVE, now, &(cpu_data[cpu].time_state[state_index])) == 0) { + /* + * Due to some inaccuracy reported value can be a bit greatrer than 100.1. + * That produces gaps on charts. + */ + if (g > 100.1) + g = 100.1; cpufreq_submit(cpu, "percent", state, &(value_t){.gauge = g}); } state_index++;