From: Evan Felix Date: Fri, 19 Apr 2013 01:04:56 +0000 (-0700) Subject: add cpu stat gathering X-Git-Tag: collectd-5.4.0~42^2~21 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=82ca30f400df01dac6057d4d974d088347d433cc;p=collectd.git add cpu stat gathering --- diff --git a/src/mic.c b/src/mic.c index f299e942..d9eb8254 100644 --- a/src/mic.c +++ b/src/mic.c @@ -29,6 +29,7 @@ #include #define MAX_MICS 32 +#define MAX_CORES 256 static MicDeviceOnSystem mics[MAX_MICS]; static U32 numMics = MAX_MICS; @@ -91,6 +92,29 @@ static void mic_submit_temp(int micnumber, const char *type, gauge_t val) plugin_dispatch_values (&vl); } +static void mic_submit_cpu(int micnumber, const char *type, int core, derive_t val) +{ + value_t values[1]; + value_list_t vl = VALUE_LIST_INIT; + + values[0].derive = val; + + vl.values=values; + vl.values_len=1; + + 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); + strncpy (vl.type, "cpu", sizeof (vl.type)); + if (core < 0) + strncpy (vl.type_instance, type, sizeof (vl.type_instance)); + else + ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%i-%s", core, type); + + plugin_dispatch_values (&vl); +} + + static int mic_read (void) { @@ -99,6 +123,8 @@ static int mic_read (void) U32 *tempBuffer; int error; U32 mem_total,mem_used,mem_bufs; + MicCoreUtil coreUtil; + MicCoreJiff coreJiffs[MAX_CORES]; error=0; for (i=0;i