summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1c4fe43)
raw | patch | inline | side by side (parent: 1c4fe43)
author | Fabien Wernli <faxmodem@collectd.org> | |
Tue, 20 Jan 2015 14:21:06 +0000 (15:21 +0100) | ||
committer | Fᴀʙɪᴇɴ Wᴇʀɴʟɪ <faxmodem@collectd.org> | |
Thu, 11 Aug 2016 13:00:44 +0000 (15:00 +0200) |
Change-Id: Ia305b74139352f16f71b1f747875d6c7a0c376a4
src/collectd.conf.pod | patch | blob | history | |
src/cpu.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index f3ff4bb9f3fc757d3887e83f200a23729dbf417c..6562158f8562dd1e53854fdfbf8f0976ebb0a6bc 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
Jiffies. By setting this option to B<true>, you can request percentage values
in the un-aggregated (per-CPU, per-state) mode as well.
+=item B<ReportNumCpu> B<false>|B<true>
+
+When set to B<true>, reports the number of available CPUs.
+Defaults to B<false>.
+
=back
=head2 Plugin C<cpufreq>
diff --git a/src/cpu.c b/src/cpu.c
index 80029667af80d39950fe06f1d0482455f70ff92c..d194872f0fd42005b64775e65521b9367497edeb 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
static _Bool report_by_cpu = 1;
static _Bool report_by_state = 1;
static _Bool report_percent = 0;
+static _Bool report_num_cpu = 0;
static const char *config_keys[] =
{
"ReportByCpu",
"ReportByState",
+ "ReportNumCpu",
"ValuesPercentage"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
report_percent = IS_TRUE (value) ? 1 : 0;
else if (strcasecmp (key, "ReportByState") == 0)
report_by_state = IS_TRUE (value) ? 1 : 0;
+ else if (strcasecmp (key, "ReportNumCpu") == 0)
+ report_num_cpu = IS_TRUE (value) ? 1 : 0;
else
return (-1);
}
} /* }}} void cpu_commit_one */
+/* Commits the number of cores */
+static void cpu_commit_num_cpu (gauge_t num_cpu) /* {{{ */
+{
+//// static void submit_value (int cpu_num, int cpu_state, const char *type, value_t value)
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ /// memcpy(&values[0], &value, sizeof(value));
+ values[0].gauge = num_cpu;
+
+ vl.values = values;
+ vl.values_len = 1;
+
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "cpu", sizeof (vl.plugin));
+ sstrncpy (vl.type, "gauge", sizeof (vl.type));
+ sstrncpy (vl.type_instance, "ncpu",
+ sizeof (vl.type_instance));
+
+ plugin_dispatch_values (&vl);
+} /* }}} void cpu_commit_num_cpu */
+
/* Resets the internal aggregation. This is called by the read callback after
* each iteration / after each call to cpu_commit(). */
static void cpu_reset (void) /* {{{ */
NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN /* Batman! */
};
+ if (report_num_cpu)
+ {
+ cpu_commit_num_cpu ((gauge_t) global_cpu_num);
+ }
+
if (report_by_state && report_by_cpu && !report_percent)
{
cpu_commit_without_aggregation ();