intel_pmu: address PR comments
authorPshyk, SerhiyX <serhiyx.pshyk@intel.com>
Fri, 26 May 2017 14:51:54 +0000 (15:51 +0100)
committerPshyk, SerhiyX <serhiyx.pshyk@intel.com>
Tue, 30 May 2017 09:29:57 +0000 (10:29 +0100)
  - cleanup of configure.ac
  - add config option EventList to avoid dependency on environment variables

Change-Id: I987095b6e71bcf05103e773793c0a40c815f729b
Signed-off-by: Serhiy Pshyk <serhiyx.pshyk@intel.com>
configure.ac
contrib/systemd.collectd.service
src/collectd.conf.in
src/collectd.conf.pod
src/intel_pmu.c

index af3bcfe..7b5045f 100644 (file)
@@ -4367,20 +4367,21 @@ fi
 # --with-libjevents {{{
 with_libjevents_cppflags=""
 with_libjevents_ldflags=""
-AC_ARG_WITH(libjevents, [AS_HELP_STRING([--with-libjevents@<:@=PREFIX@:>@], [Path to libjevents.])],
-[
-  if test "x$withval" != "xno" && test "x$withval" != "xyes"
-  then
-    with_libjevents_cppflags="-I$withval/include"
-    with_libjevents_ldflags="-L$withval/lib"
-    with_libjevents="yes"
-  else
-    with_libjevents="$withval"
-  fi
-],
-[
-  with_libjevents="yes"
-])
+AC_ARG_WITH([libjevents],
+  [AS_HELP_STRING([--with-libjevents@<:@=PREFIX@:>@], [Path to libjevents.])],
+  [
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"
+    then
+      with_libjevents_cppflags="-I$withval/include"
+      with_libjevents_ldflags="-L$withval/lib"
+      with_libjevents="yes"
+    else
+      with_libjevents="$withval"
+    fi
+  ],
+  [with_libjevents="yes"]
+)
+
 if test "x$with_libjevents" = "xyes"
 then
   SAVE_CPPFLAGS="$CPPFLAGS"
@@ -4392,47 +4393,22 @@ then
 fi
 if test "x$with_libjevents" = "xyes"
 then
-  SAVE_CPPFLAGS="$CPPFLAGS"
   SAVE_LDFLAGS="$LDFLAGS"
-  CPPFLAGS="$CPPFLAGS $with_libjevents_cppflags"
   LDFLAGS="$LDFLAGS $with_libjevents_ldflags"
 
   AC_CHECK_LIB(jevents, json_events, [with_libjevents="yes"], [with_libjevents="no (Can't find libjevents)"])
 
-  CPPFLAGS="$SAVE_CPPFLAGS"
-  LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_libjevents" = "xyes"
-then
-  SAVE_CPPFLAGS="$CPPFLAGS"
-  SAVE_LDFLAGS="$LDFLAGS"
-  SAVE_LIBS="$LIBS"
-  CPPFLAGS="$CPPFLAGS -fPIC"
-  LDFLAGS="$LDFLAGS -shared"
-  LIBS="-ljevents"
-  AC_LINK_IFELSE([AC_LANG_SOURCE(
-    [[
-      #include <stdio.h>
-      #include "jevents.h"
-      void print_cpu(void){
-        printf("%s", get_cpu_str());
-      }
-    ]]
-  )],
-  [with_libjevents="yes"], [with_libjevents="no (could not link to libjevents. Check jevents is compiled with -fPIC.)"])
-  CPPFLAGS="$SAVE_CPPFLAGS"
   LDFLAGS="$SAVE_LDFLAGS"
-  LIBS="$SAVE_LIBS"
 fi
 if test "x$with_libjevents" = "xyes"
 then
   BUILD_WITH_LIBJEVENTS_CPPFLAGS="$with_libjevents_cppflags"
   BUILD_WITH_LIBJEVENTS_LDFLAGS="$with_libjevents_ldflags"
   BUILD_WITH_LIBJEVENTS_LIBS="-ljevents"
-  AC_SUBST(BUILD_WITH_LIBJEVENTS_CPPFLAGS)
-  AC_SUBST(BUILD_WITH_LIBJEVENTS_LDFLAGS)
-  AC_SUBST(BUILD_WITH_LIBJEVENTS_LIBS)
 fi
+AC_SUBST(BUILD_WITH_LIBJEVENTS_CPPFLAGS)
+AC_SUBST(BUILD_WITH_LIBJEVENTS_LDFLAGS)
+AC_SUBST(BUILD_WITH_LIBJEVENTS_LIBS)
 # }}}
 
 # --with-libprotobuf {{{
index efd922a..5f3e907 100644 (file)
@@ -11,20 +11,6 @@ EnvironmentFile=-/etc/default/collectd
 ProtectSystem=full
 ProtectHome=true
 
-# Some plugins require access to data located in a specified folder, to access
-# this data you'll have to specify the path by using the Environment directive
-# below.
-#
-# Here's a (incomplete) list of the plugins known environment requirements:
-#   intel_pmu       XDG_CACHE_HOME
-#
-# Example, if you use the intel_pmu plugin and cache is located in the /opt
-# directory:
-# Environment=XDG_CACHE_HOME=/opt
-#
-# By default, the HOME directory is chosen:
-Environment=
-
 # A few plugins won't work without some privileges, which you'll have to
 # specify using the CapabilityBoundingSet directive below.
 #
index 1a2823b..1b40bf4 100644 (file)
 #    ReportHardwareCacheEvents true
 #    ReportKernelPMUEvents true
 #    ReportSoftwareEvents true
+#    EventList "/var/cache/pmu/GenuineIntel-6-2D-core.json"
 #    HardwareEvents "L2_RQSTS.CODE_RD_HIT,L2_RQSTS.CODE_RD_MISS" "L2_RQSTS.ALL_CODE_RD"
 #</Plugin>
 
index 36053cd..30544d0 100644 (file)
@@ -3093,6 +3093,7 @@ B<Synopsis:>
     ReportHardwareCacheEvents true
     ReportKernelPMUEvents true
     ReportSoftwareEvents true
+    EventList "/var/cache/pmu/GenuineIntel-6-2D-core.json"
     HardwareEvents "L2_RQSTS.CODE_RD_HIT,L2_RQSTS.CODE_RD_MISS" "L2_RQSTS.ALL_CODE_RD"
   </Plugin>
 
@@ -3154,11 +3155,16 @@ Enable or disable measuring of software events provided by kernel:
   - alignment-faults
   - emulation-faults
 
+=item B<EventList> I<filename>
+
+JSON performance counter event list file name. To be able to monitor all Intel
+CPU specific events JSON event list file should be downloaded. Use the pmu-tools
+event_download.py script to download event list for current CPU.
+
 =item B<HardwareEvents> I<events>
 
 This field is a list of event names or groups of comma separated event names.
-To be able to monitor all Intel CPU specific events JSON event list file should
-be downloaded. Use the pmu-tools event_download.py script for this.
+This option requires B<EventList> option to be configured.
 
 =back
 
index e332c37..87a713b 100644 (file)
@@ -67,6 +67,7 @@ struct intel_pmu_ctx_s {
   _Bool hw_cache_events;
   _Bool kernel_pmu_events;
   _Bool sw_events;
+  char  event_list_fn[PATH_MAX];
   char **hw_events;
   size_t hw_events_count;
   struct eventlist *event_list;
@@ -243,6 +244,9 @@ static int pmu_config(oconfig_item_t *ci) {
       ret = cf_util_get_boolean(child, &g_ctx.hw_cache_events);
     } else if (strcasecmp("ReportKernelPMUEvents", child->key) == 0) {
       ret = cf_util_get_boolean(child, &g_ctx.kernel_pmu_events);
+    } else if (strcasecmp("EventList", child->key) == 0) {
+      ret = cf_util_get_string_buffer(child, g_ctx.event_list_fn,
+                                      sizeof(g_ctx.event_list_fn));
     } else if (strcasecmp("HardwareEvents", child->key) == 0) {
       ret = pmu_config_hw_events(child);
     } else if (strcasecmp("ReportSoftwareEvents", child->key) == 0) {
@@ -493,6 +497,14 @@ static int pmu_init(void) {
 
   /* parse events names if config option is present and is not empty */
   if (g_ctx.hw_events_count) {
+
+    ret = read_events(g_ctx.event_list_fn);
+    if (ret != 0) {
+      ERROR(PMU_PLUGIN ": Failed to read event list file '%s'.",
+            g_ctx.event_list_fn);
+      return ret;
+    }
+
     ret = pmu_add_hw_events(g_ctx.event_list, g_ctx.hw_events,
                             g_ctx.hw_events_count);
     if (ret != 0) {