summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 573c602)
raw | patch | inline | side by side (parent: 573c602)
author | Evan Felix <e@pnnl.gov> | |
Fri, 19 Apr 2013 01:04:56 +0000 (18:04 -0700) | ||
committer | Evan Felix <e@pnnl.gov> | |
Fri, 19 Apr 2013 01:04:56 +0000 (18:04 -0700) |
src/mic.c | patch | blob | history |
diff --git a/src/mic.c b/src/mic.c
index f299e942d3dc28231c2e940c1f5b57981e767d6a..d9eb8254fa776de1c6b3316c24a289817291f9af 100644 (file)
--- a/src/mic.c
+++ b/src/mic.c
#include <MicThermalAPI.h>
#define MAX_MICS 32
+#define MAX_CORES 256
static MicDeviceOnSystem mics[MAX_MICS];
static U32 numMics = MAX_MICS;
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)
{
U32 *tempBuffer;
int error;
U32 mem_total,mem_used,mem_bufs;
+ MicCoreUtil coreUtil;
+ MicCoreJiff coreJiffs[MAX_CORES];
error=0;
for (i=0;i<numMics;i++) {
if (error)
break;
+ /*Gather CPU Utilization Information */
+ bufferSize=MAX_CORES*sizeof(MicCoreJiff);
+ ret = MicGetCoreUtilization(micHandle,&coreUtil,coreJiffs,&bufferSize);
+ if (ret != MIC_ACCESS_API_SUCCESS) {
+ ERROR("Problem getting CPU utilization: %s",MicGetErrorString(ret));
+ error=5;
+ break;
+ }
+ mic_submit_cpu(i,"user",-1,coreUtil.sum.user);
+ mic_submit_cpu(i,"sys",-1,coreUtil.sum.sys);
+ mic_submit_cpu(i,"nice",-1,coreUtil.sum.nice);
+ mic_submit_cpu(i,"idle",-1,coreUtil.sum.idle);
+ for (j=0;j<coreUtil.core;j++) {
+ mic_submit_cpu(i,"user",j,coreJiffs[j].user);
+ mic_submit_cpu(i,"sys",j,coreJiffs[j].sys);
+ mic_submit_cpu(i,"nice",j,coreJiffs[j].nice);
+ mic_submit_cpu(i,"idle",j,coreJiffs[j].idle);
+ }
+
ret = MicCloseAdapter(micHandle);
if (ret != MIC_ACCESS_API_SUCCESS) {
ERROR("Problem initializing MicAdapter: %s",MicGetErrorString(ret));
static int mic_shutdown (void)
{
if (micHandle)
- MicCloseAPI(micHandle);
+ MicCloseAPI(&micHandle);
return (0);
}