+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 val) {
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ /* MicAccessAPI reports KB's of memory, adjust for this */
+ DEBUG("mic plugin: Memory Value Report; %u %lf", val,
+ ((gauge_t)val) * 1024.0);
+ values[0].gauge = ((gauge_t)val) * 1024.0;
+
+ 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, "memory", sizeof(vl.type));
+ strncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
+
+ plugin_dispatch_values(&vl);
+}
+
+/* Gather memory Utilization */
+static int mic_read_memory(int mic) {
+ U32 ret;
+ U32 mem_total, mem_free, mem_bufs;
+
+ ret = MicGetMemoryUtilization(mic_handle, &mem_total, &mem_free, &mem_bufs);
+ if (ret != MIC_ACCESS_API_SUCCESS) {
+ ERROR("mic plugin: Problem getting Memory Utilization: %s",
+ MicGetErrorString(ret));
+ return (1);
+ }
+ mic_submit_memory_use(mic, "free", mem_free);
+ mic_submit_memory_use(mic, "used", mem_total - mem_free - mem_bufs);
+ mic_submit_memory_use(mic, "buffered", mem_bufs);
+ DEBUG("mic plugin: Memory Read: %u %u %u", mem_total, mem_free, mem_bufs);
+ return (0);
+}
+
+static void mic_submit_temp(int micnumber, const char *type, gauge_t val) {