From: Florian Forster Date: Sat, 11 May 2013 07:55:09 +0000 (+0200) Subject: mic plugin: Use the "core number" as plugin instance. X-Git-Tag: collectd-5.4.0~42^2~9 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=7eb8ea317234ad9c43c8915a2d0d40f4382462fd;p=collectd.git mic plugin: Use the "core number" as plugin instance. Previously, per-core CPU statistics would be dispatched as (e.g.): /mic-0/cpu-1-user This makes graping hard, because it required to parse the type instance to seperate out different graphs. The core number has therefore been moved to the plugin instance, so the "mic" plugin behaves more like the "cpu" plugin, e.g.: /mic-0-cpu-1/cpu-user --- diff --git a/src/mic.c b/src/mic.c index c89f8eb6..a2d4dc33 100644 --- a/src/mic.c +++ b/src/mic.c @@ -214,7 +214,8 @@ static int mic_read_temps(int mic) return (0); } -static void mic_submit_cpu(int micnumber, const char *type_instance, int core, derive_t val) +static void mic_submit_cpu(int micnumber, const char *type_instance, + int core, derive_t val) { value_t values[1]; value_list_t vl = VALUE_LIST_INIT; @@ -226,13 +227,14 @@ static void mic_submit_cpu(int micnumber, const char *type_instance, int core, d strncpy (vl.host, hostname_g, sizeof (vl.host)); strncpy (vl.plugin, "mic", sizeof (vl.plugin)); - ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance), "%i", micnumber); + if (core < 0) /* global aggregation */ + ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance), + "%i", micnumber); + else /* per-core statistics */ + ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance), + "%i-cpu-%i", micnumber, core); strncpy (vl.type, "cpu", sizeof (vl.type)); - if (core < 0) - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - else - ssnprintf (vl.type_instance, sizeof (vl.type_instance), - "%i-%s", core, type_instance); + strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); plugin_dispatch_values (&vl); }