Add Thermal gathering, and the config properly
authorEvan Felix <e@pnnl.gov>
Thu, 18 Apr 2013 23:46:05 +0000 (16:46 -0700)
committerEvan Felix <e@pnnl.gov>
Thu, 18 Apr 2013 23:46:05 +0000 (16:46 -0700)
configure.in
src/Makefile.am
src/collectd.conf.in
src/mic.c

index a62d608..515c262 100644 (file)
@@ -1600,7 +1600,8 @@ then
        AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
 fi
 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
-# }}}
+#
+ }}}
 
 # --with-libdbi {{{
 with_libdbi_cppflags=""
@@ -1766,6 +1767,7 @@ AC_SUBST(GANGLIA_CPPFLAGS)
 AC_SUBST(GANGLIA_LDFLAGS)
 AC_SUBST(GANGLIA_LIBS)
 AM_CONDITIONAL(BUILD_WITH_LIBGANGLIA, test "x$with_libganglia" = "xyes")
+
 # }}}
 
 # --with-libgcrypt {{{
@@ -4152,6 +4154,63 @@ fi
 AM_CONDITIONAL(BUILD_WITH_LIBYAJL, test "x$with_libyajl" = "xyes")
 # }}}
 
+# --with-mic {{{
+with_mic_cflags="-I/opt/intel/mic/sysmgmt/sdk/include"
+with_mic_ldpath="-L/opt/intel/mic/sysmgmt/sdk/lib/Linux"
+with_mic_libs=""
+AC_ARG_WITH(mic,[AS_HELP_STRING([--with-mic@<:@=PREFIX@:>@], [Path to Intel MIC Access API.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_mic="no"
+       else if test "x$withval" = "xyes"
+       then
+               with_mic="yes"
+       else if test -d "$with_mic/lib"
+       then
+               AC_MSG_NOTICE([Not checking for Intel Mic: Manually configured])
+               with_mic_cflags="-I$withval/include"
+               with_mic_ldpath="-L$withval/lib"
+               with_mic_libs="-lMicAccessSDK -lscif -lpthread"
+               with_mic="yes"
+       fi; fi; fi
+],
+[with_mic="yes"])
+if test "x$with_mic" = "xyes"
+then
+       SAVE_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS $with_mic_cflags"
+       AC_CHECK_HEADERS(MicAccessApi.h,[],[with_mic="no (MicAccessApi not found)"])
+       CFLAGS="$SAVE_CFLAGS"
+fi
+if test "x$with_mic" = "xyes"
+then
+       SAVE_CFLAGS="$CFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+
+       CFLAGS="$CFLAGS $with_mic_cflags"
+       LDFLAGS="$LDFLAGS $with_mic_ldpath"
+
+       AC_CHECK_LIB(MicAccessSDK, MicInitAPI,
+                    [with_mic_ldpath="$with_mic_ldpath"
+                         with_mic_libs="-lMicAccessSDK -lscif -lpthread"],
+                    [with_mic="no (symbol MicInitAPI not found)"],[-lscif -lpthread])
+
+       CFLAGS="$SAVE_CFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_mic" = "xyes"
+then
+       BUILD_WITH_MIC_CFLAGS="$with_mic_cflags"
+       BUILD_WITH_MIC_LIBPATH="$with_mic_ldpath"
+       BUILD_WITH_MIC_LDADD="$with_mic_libs"
+       AC_SUBST(BUILD_WITH_MIC_CFLAGS)
+       AC_SUBST(BUILD_WITH_MIC_LIBPATH)
+       AC_SUBST(BUILD_WITH_MIC_LDADD)
+fi
+#}}}
+
 # --with-libvarnish {{{
 with_libvarnish_cppflags=""
 with_libvarnish_cflags=""
@@ -4936,6 +4995,7 @@ AC_PLUGIN([md],          [$have_linux_raid_md_u_h], [md (Linux software RAID) de
 AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
+AC_PLUGIN([mic],         [$with_mic],          [Intel Many Integrated Core stats])
 AC_PLUGIN([modbus],      [$with_libmodbus],    [Modbus plugin])
 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
@@ -5204,6 +5264,7 @@ Configuration:
     libstatgrab . . . . . $with_libstatgrab
     libtokyotyrant  . . . $with_libtokyotyrant
     libupsclient  . . . . $with_libupsclient
+    mic  . . .  . . . . . $with_mic
     libvarnish  . . . . . $with_libvarnish
     libvirt . . . . . . . $with_libvirt
     libxml2 . . . . . . . $with_libxml2
index 2bebec5..e0c1929 100644 (file)
@@ -1271,6 +1271,16 @@ collectd_LDADD += "-dlopen" uuid.la
 collectd_DEPENDENCIES += uuid.la
 endif
 
+if BUILD_PLUGIN_MIC
+pkglib_LTLIBRARIES += mic.la
+mic_la_SOURCES = mic.c
+mic_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_MIC_LIBPATH)
+mic_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_MIC_CFLAGS)
+mic_la_LIBADD = $(BUILD_WITH_MIC_LDADD)
+collectd_LDADD += "-dlopen" mic.la
+collectd_DEPENDENCIES += mic.la
+endif
+
 if BUILD_PLUGIN_VARNISH
 pkglib_LTLIBRARIES += varnish.la
 varnish_la_SOURCES = varnish.c
index 5af1568..89a1b23 100644 (file)
 #@BUILD_PLUGIN_USERS_TRUE@LoadPlugin users
 #@BUILD_PLUGIN_UUID_TRUE@LoadPlugin uuid
 #@BUILD_PLUGIN_VARNISH_TRUE@LoadPlugin varnish
+#@BUILD_PLUGIN_MIC_TRUE@LoadPlugin mic
 #@BUILD_PLUGIN_VMEM_TRUE@LoadPlugin vmem
 #@BUILD_PLUGIN_VSERVER_TRUE@LoadPlugin vserver
 #@BUILD_PLUGIN_WIRELESS_TRUE@LoadPlugin wireless
 #      UUIDFile "/etc/uuid"
 #</Plugin>
 
+#<Plugin mic>
+#</Plugin>
+
 #<Plugin varnish>
 #   This tag support an argument if you want to
 #   monitor the local instance just use </Instance>
index efd7c1d..f299e94 100644 (file)
--- a/src/mic.c
+++ b/src/mic.c
 #include <MicAccessTypes.h>
 #include <MicAccessErrorTypes.h>
 #include <MicAccessApi.h>
+#include <MicThermalAPI.h>
 
 #define MAX_MICS 32
 
 static MicDeviceOnSystem mics[MAX_MICS];
 static U32 numMics = MAX_MICS;
 static HANDLE micHandle=NULL;
+#define NUM_THERMS 7
+static const int therms[NUM_THERMS] = {eMicThermalDie,eMicThermalDevMem,eMicThermalFin,eMicThermalFout,eMicThermalVccp,eMicThermalVddg,eMicThermalVddq};
+static const char *thermNames[NUM_THERMS] = {"die","devmem","fin","fout","vccp","vddg","vddq"};
+
 
 static int mic_init (void)
 {
@@ -48,7 +53,7 @@ static int mic_init (void)
        return (0);
 }
 
-static void mic_submit_memory_use(int micnumber, char *type, gauge_t val)
+static void mic_submit_memory_use(int micnumber, const char *type, gauge_t val)
 {
   value_t values[1];
   value_list_t vl = VALUE_LIST_INIT;
@@ -67,10 +72,31 @@ static void mic_submit_memory_use(int micnumber, char *type, gauge_t val)
   plugin_dispatch_values (&vl);
 } 
 
+static void mic_submit_temp(int micnumber, const char *type, gauge_t val)
+{
+  value_t values[1];
+  value_list_t vl = VALUE_LIST_INIT;
+
+  values[0].gauge = 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, "temperature", sizeof (vl.type));
+  strncpy (vl.type_instance, type, sizeof (vl.type_instance));
+
+  plugin_dispatch_values (&vl);
+} 
+
+
 static int mic_read (void)
 {
-  int i;
-  U32 ret;
+  int i,j;
+  U32 ret,bufferSize;
+  U32 *tempBuffer;
   int error;
   U32 mem_total,mem_used,mem_bufs;
 
@@ -86,15 +112,32 @@ static int mic_read (void)
        /* Gather memory Utilization */
        ret = MicGetMemoryUtilization(micHandle,&mem_total,&mem_used,&mem_bufs);
        if (ret != MIC_ACCESS_API_SUCCESS) {
-         ERROR("Problem initializing MicAdapter: %s",MicGetErrorString(ret));
+         ERROR("Problem getting Memory Utilization: %s",MicGetErrorString(ret));
          error=3;
          break;
        }
-       mic_submit_memory_use(i,"total",mem_total);
-       mic_submit_memory_use(i,"used",mem_used);
-       mic_submit_memory_use(i,"bufs",mem_bufs);
+       /* 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;
+
        ret = MicCloseAdapter(micHandle);
        if (ret != MIC_ACCESS_API_SUCCESS) {
          ERROR("Problem initializing MicAdapter: %s",MicGetErrorString(ret));