From 82ca30f400df01dac6057d4d974d088347d433cc Mon Sep 17 00:00:00 2001 From: Evan Felix Date: Thu, 18 Apr 2013 18:04:56 -0700 Subject: [PATCH] add cpu stat gathering --- src/mic.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) 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