- /* Gather memory Utilization */
- ret = MicGetMemoryUtilization(micHandle,&mem_total,&mem_used,&mem_bufs);
- if (ret != MIC_ACCESS_API_SUCCESS) {
- ERROR("Problem getting Memory Utilization: %s",MicGetErrorString(ret));
- error=3;
- break;
- }
- /* API reprots KB's of memory, adjust for this */
- mic_submit_memory_use(i,"total",mem_total*1024);
- mic_submit_memory_use(i,"used",mem_used*1024);
- mic_submit_memory_use(i,"bufs",mem_bufs*1024);
- /*INFO("Memory Read: %u %u %u",mem_total,mem_used,mem_bufs);*/
-
- /* Gather Temperature Information */
- bufferSize = sizeof(U32);
- tempBuffer = malloc(bufferSize);
- for (j=0;j<NUM_THERMS;j++) {
- ret = MicGetTemperature(micHandle,therms[j],tempBuffer,&bufferSize);
- if (ret != MIC_ACCESS_API_SUCCESS) {
- ERROR("Problem getting Temperature(%d) %s",j,MicGetErrorString(ret));
- error=4;
- break;
- }
- /*INFO("Temp Read: %u: %u %s",j,tempBuffer[0],thermNames[j]);*/
- mic_submit_temp(i,thermNames[j],tempBuffer[0]);
- }
- 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));
- error=2;
- break;
+ /* power is in uWatts, current in mA, voltage in uVolts.. convert to
+ * base unit */
+ #define SUB_POWER(name) do { if (ignorelist_match(power_ignore,#name)==0) \
+ mic_submit_power(mic,"power",#name,(gauge_t)power_use.name.prr*0.000001); \
+ } while(0)
+ #define SUB_VOLTS(name) do { if (ignorelist_match(power_ignore,#name)==0) {\
+ mic_submit_power(mic,"power",#name,(gauge_t)(power_use.name.pwr*0.000001)); \
+ mic_submit_power(mic,"current",#name,(gauge_t)(power_use.name.cur*0.001)); \
+ mic_submit_power(mic,"voltage",#name,(gauge_t)(power_use.name.volt*0.000001)); \
+ }} while(0)
+
+ SUB_POWER(total0);
+ SUB_POWER(total1);
+ SUB_POWER(inst);
+ SUB_POWER(imax);
+ SUB_POWER(pcie);
+ SUB_POWER(c2x3);
+ SUB_POWER(c2x4);
+ SUB_VOLTS(vccp);
+ SUB_VOLTS(vddg);
+ SUB_VOLTS(vddq);
+
+ return (0);
+}
+
+static int mic_read (void)
+{
+ int i;
+ U32 ret;
+ int error;
+
+ error=0;
+ for (i=0;i<num_mics;i++) {
+ ret = MicInitAdapter(&mic_handle,&mics[i]);
+ if (ret != MIC_ACCESS_API_SUCCESS) {
+ ERROR("mic plugin: Problem initializing MicAdapter: %s",
+ MicGetErrorString(ret));
+ error=1;
+ }
+
+ if (error == 0 && show_memory)
+ error = mic_read_memory(i);
+
+ if (error == 0 && show_temps)
+ error = mic_read_temps(i);
+
+ if (error == 0 && (show_cpu || show_cpu_cores))
+ error = mic_read_cpu(i);
+
+ if (error == 0 && (show_power))
+ error = mic_read_power(i);
+
+ ret = MicCloseAdapter(mic_handle);
+ if (ret != MIC_ACCESS_API_SUCCESS) {
+ ERROR("mic plugin: Problem closing MicAdapter: %s",
+ MicGetErrorString(ret));
+ error=2;
+ break;
+ }