+static U32 num_mics = 0;
+static HANDLE mic_handle = NULL;
+
+static int const therm_ids[] = {
+ eMicThermalDie, eMicThermalDevMem, eMicThermalFin, eMicThermalFout,
+ eMicThermalVccp, eMicThermalVddg, eMicThermalVddq};
+static char const *const therm_names[] = {"die", "devmem", "fin", "fout",
+ "vccp", "vddg", "vddq"};
+
+static const char *config_keys[] = {
+ "ShowCPU", "ShowCPUCores", "ShowMemory",
+ "ShowTemperatures", "Temperature", "IgnoreSelectedTemperature",
+ "ShowPower", "Power", "IgnoreSelectedPower"};
+static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
+
+static _Bool show_cpu = 1;
+static _Bool show_cpu_cores = 1;
+static _Bool show_memory = 1;
+static _Bool show_temps = 1;
+static ignorelist_t *temp_ignore = NULL;
+static _Bool show_power = 1;
+static ignorelist_t *power_ignore = NULL;
+
+static int mic_init(void) {
+ U32 ret;
+ U32 mic_count;
+
+ if (mic_handle)
+ return (0);
+
+ mic_count = (U32)STATIC_ARRAY_SIZE(mics);
+ ret = MicInitAPI(&mic_handle, eTARGET_SCIF_DRIVER, mics, &mic_count);
+ if (ret != MIC_ACCESS_API_SUCCESS) {
+ ERROR("mic plugin: Problem initializing MicAccessAPI: %s",
+ MicGetErrorString(ret));
+ }
+ DEBUG("mic plugin: found: %" PRIu32 " MIC(s)", mic_count);
+
+ if (mic_count < 0 || mic_count >= MAX_MICS) {
+ ERROR("mic plugin: No Intel MICs in system");
+ return (1);
+ } else {
+ num_mics = mic_count;
+ return (0);
+ }
+}
+
+static int mic_config(const char *key, const char *value) {
+ if (temp_ignore == NULL)
+ temp_ignore = ignorelist_create(1);
+ if (power_ignore == NULL)
+ power_ignore = ignorelist_create(1);
+ if (temp_ignore == NULL || power_ignore == NULL)
+ return (1);
+
+ if (strcasecmp("ShowCPU", key) == 0) {
+ show_cpu = IS_TRUE(value);
+ } else if (strcasecmp("ShowCPUCores", key) == 0) {
+ show_cpu_cores = IS_TRUE(value);
+ } else if (strcasecmp("ShowTemperatures", key) == 0) {
+ show_temps = IS_TRUE(value);
+ } else if (strcasecmp("ShowMemory", key) == 0) {
+ show_memory = IS_TRUE(value);
+ } else if (strcasecmp("ShowPower", key) == 0) {
+ show_power = IS_TRUE(value);
+ } else if (strcasecmp("Temperature", key) == 0) {
+ ignorelist_add(temp_ignore, value);
+ } else if (strcasecmp("IgnoreSelectedTemperature", key) == 0) {
+ int invert = 1;
+ if (IS_TRUE(value))
+ invert = 0;
+ ignorelist_set_invert(temp_ignore, invert);
+ } else if (strcasecmp("Power", key) == 0) {
+ ignorelist_add(power_ignore, value);
+ } else if (strcasecmp("IgnoreSelectedPower", key) == 0) {
+ int invert = 1;
+ if (IS_TRUE(value))
+ invert = 0;
+ ignorelist_set_invert(power_ignore, invert);
+ } else {
+ return (-1);
+ }
+ return (0);
+}
+
+static void mic_submit_memory_use(int micnumber, const char *type_instance,
+ U32 value) {
+ value_list_t vl = VALUE_LIST_INIT;
+
+ /* MicAccessAPI reports KB's of memory, adjust for this */
+ DEBUG("mic plugin: Memory Value Report; %u %lf", value,
+ ((gauge_t)value) * 1024.0);
+
+ vl.values = &(value_t){.gauge = ((gauge_t)value) * 1024.0};
+ vl.values_len = 1;
+
+ strncpy(vl.plugin, "mic", sizeof(vl.plugin));
+ ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%i", micnumber);
+ strncpy(vl.type, "memory", sizeof(vl.type));
+ strncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));