]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Updated the CollectHealth and CollectPerfMetrics config value types to boolean.
authorTG, Hari <hari.tg@intel.com>
Fri, 13 Sep 2019 20:20:39 +0000 (13:20 -0700)
committerTG, Hari <hari.tg@intel.com>
Fri, 13 Sep 2019 20:20:39 +0000 (13:20 -0700)
Added error check for condition where both the above values are disabled.
Added root privilege required info to plugin description and error messages.

Signed-off-by: TG, Hari <hari.tg@intel.com>
configure.ac
src/collectd.conf.in
src/collectd.conf.pod
src/dcpmm.c [changed mode: 0755->0644]

index 1b5eff7239a4c178a04e2928c0cddf596c43a15c..d2bfd749c6ab0a9e2235e91d230e6622e2c0f1ea 100644 (file)
@@ -4388,9 +4388,9 @@ fi
 AC_SUBST([PERL_CFLAGS])
 AC_SUBST([PERL_LIBS])
 
-
 # }}}
 
+
 # --with-libpmwapi {{{
 AC_ARG_WITH([libpmwapi],
   [AS_HELP_STRING([--with-libpmwapi@<:@=PREFIX@:>@], [Path to libpmwapi.])],
index 903308d0d1e3a2fa44f6563ec793208ef50e757b..0176e5e3f1511fe8688fe6f162ec797a1c161dbd 100644 (file)
 
 #<Plugin dcpmm>
 #    Interval 10.0
-#    CollectHealth 0
-#    CollectPerfMetrics 1
-#    EnableDispatchAll 0
+#    CollectHealth false
+#    CollectPerfMetrics true
+#    EnableDispatchAll false
 #</Plugin>
 
 #<Plugin df>
index 996046c98be0b161d7c407781b00413f68dac6e2..32cecb7746350b9735a2b5396e748464247013d1 100644 (file)
@@ -2541,14 +2541,15 @@ values. Defaults to the global hostname setting.
 =head2 Plugin C<dcpmm>
 
 The I<dcpmm plugin> will collect Intel(R) Optane(TM) DC Persistent Memory related performance statistics.
+The plugin requires root privileges to perform the statistics collection.
 
 B<Synopsis:>
 
  <Plugin "dcpmm">
    Interval 10.0
-   CollectHealth 0
-   CollectPerfMetrics 1
-   EnableDispatchAll 0
+   CollectHealth false
+   CollectPerfMetrics true
+   EnableDispatchAll false
  </Plugin>
 
 =over 4
@@ -2558,9 +2559,9 @@ B<Synopsis:>
 Sets the I<Interval (in seconds)> in which the values will be collected. Defaults to C<global Interval> value.
 This will override the I<global Interval> for I<dcpmm> plugin. None of the other plugins will be affected.
 
-=item B<CollectHealth> I<0>|I<1>
+=item B<CollectHealth> I<true>|I<false>
 
-Collects health information. I<CollectHealth and CollectPerfMetrics cannot be 1 at the same time>. Defaults to C<0>.
+Collects health information. I<CollectHealth and CollectPerfMetrics cannot be true at the same time>. Defaults to C<false>.
 
 The health information metrics are the following:
   health_status        Overall health summary (0: normal | 1: non-critical | 2: critical | 3: fatal).
@@ -2574,9 +2575,9 @@ The health information metrics are the following:
   max_media_temp       The media’s the highest temperature reported in degrees Celsius.
   max_controller_temp  The controller’s highest temperature reported in degrees Celsius.
 
-=item B<CollectPerfMetrics> I<0>|I<1>
+=item B<CollectPerfMetrics> I<true>|I<false>
 
-Collects memory performance metrics. I<CollectHealth and CollectPerfMetrics cannot be 1 at the same time>. Defaults to C<1>.
+Collects memory performance metrics. I<CollectHealth and CollectPerfMetrics cannot be true at the same time>. Defaults to C<true>.
 
 The memory performance metrics are the following:
   total_bytes_read    Number of bytes transacted by the read operations.
@@ -2590,10 +2591,10 @@ The memory performance metrics are the following:
   read_hit_ratio      Measures the efficiency of the buffer in the read path. Range of 0.0 - 0.75.
   write_hit_ratio     Measures the efficiency of the buffer in the write path. Range of 0.0 - 1.0.
 
-=item B<EnableDispatchAll> I<0>
+=item B<EnableDispatchAll> I<false>
 
 This parameter helps to seamlessly enable simultaneous health and memory perf metrics collection in future.
-This is unused at the moment and I<must> always be I<0>.
+This is unused at the moment and I<must> always be I<false>.
 
 =back
 
old mode 100755 (executable)
new mode 100644 (file)
index 157cc70..8a3acac
 #include "pmw_api.h"
 
 #define PLUGIN_NAME "dcpmm"
+#define PRINT_BOOL(s) (s ? "true" : "false")
 
 int num_nvdimms;
-int enable_dispatch_all = 0;
+bool enable_dispatch_all = false;
 cdtime_t interval = 0;
 PMWATCH_OP_BUF pmw_output_buf;
 PMWATCH_CONFIG_NODE pmwatch_config;
@@ -193,13 +194,20 @@ static int dcpmm_init(void) {
 
   ret = PMWAPIGetDIMMCount(&num_nvdimms);
   if (ret != 0) {
-    ERROR(PLUGIN_NAME ": Failed to obtain count of Intel(R) Optane DCPMM.");
+    ERROR(PLUGIN_NAME ": Failed to obtain count of Intel(R) Optane DCPMM."
+                      "A common cause for this is collectd running without"
+                      "root privileges. Ensure that collectd is running with"
+                      "root privileges.");
+
     return ret;
   }
 
   ret = PMWAPIStart(pmwatch_config);
   if (ret != 0) {
-    ERROR(PLUGIN_NAME ": Failed to start the collection.");
+    ERROR(PLUGIN_NAME ": Failed to start the collection."
+                      "A common cause for this is collectd running without"
+                      "root privileges. Ensure that collectd is running with"
+                      "root privileges.");
     return ret;
   }
 
@@ -229,13 +237,14 @@ static int dcpmm_config(oconfig_item_t *ci) {
       }
     } else if (strncasecmp("CollectHealth", child->key,
                            strlen("CollectHealth")) == 0) {
-      ret = cf_util_get_int(child, &pmwatch_config.collect_health);
+      ret = cf_util_get_boolean(child, &pmwatch_config.collect_health);
+
     } else if (strncasecmp("CollectPerfMetrics", child->key,
                            strlen("CollectPerfMetrics")) == 0) {
-      ret = cf_util_get_int(child, &pmwatch_config.collect_perf_metrics);
+      ret = cf_util_get_boolean(child, &pmwatch_config.collect_perf_metrics);
     } else if (strncasecmp("EnableDispatchAll", child->key,
                            strlen("EnableDispatchAll")) == 0) {
-      ret = cf_util_get_int(child, &enable_dispatch_all);
+      ret = cf_util_get_boolean(child, &enable_dispatch_all);
     } else {
       ERROR(PLUGIN_NAME ": Unkown configuration parameter %s.", child->key);
       ret = 1;
@@ -247,10 +256,18 @@ static int dcpmm_config(oconfig_item_t *ci) {
     }
   }
 
-  DEBUG("%s Config: Interval %.2f ; CollectHealth %d ; CollectdPerfMetrics %d "
-        "; EnableDispatchAll %d",
-        PLUGIN_NAME, pmwatch_config.interval, pmwatch_config.collect_health,
-        pmwatch_config.collect_perf_metrics, enable_dispatch_all);
+  DEBUG("%s Config: Interval %.2f ; CollectHealth %s ; CollectdPerfMetrics %s "
+        "; EnableDispatchAll %s",
+        PLUGIN_NAME, pmwatch_config.interval,
+        PRINT_BOOL(pmwatch_config.collect_health),
+        PRINT_BOOL(pmwatch_config.collect_perf_metrics),
+        PRINT_BOOL(enable_dispatch_all));
+
+  if (!pmwatch_config.collect_health && !pmwatch_config.collect_perf_metrics) {
+    ERROR(PLUGIN_NAME ": CollectdHealth and CollectPerfMetrics are disabled. "
+                      "Enable atleast one.");
+    return 1;
+  }
 
   plugin_register_complex_read(NULL, PLUGIN_NAME, dcpmm_read, interval, NULL);