From 259628f8644bf6a7a4e5f629aae9187107ce961e Mon Sep 17 00:00:00 2001 From: "TG, Hari" Date: Fri, 13 Sep 2019 13:20:39 -0700 Subject: [PATCH] Updated the CollectHealth and CollectPerfMetrics config value types to boolean. 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 --- configure.ac | 2 +- src/collectd.conf.in | 6 +++--- src/collectd.conf.pod | 19 ++++++++++--------- src/dcpmm.c | 37 +++++++++++++++++++++++++++---------- 4 files changed, 41 insertions(+), 23 deletions(-) mode change 100755 => 100644 src/dcpmm.c diff --git a/configure.ac b/configure.ac index 1b5eff723..d2bfd749c 100644 --- a/configure.ac +++ b/configure.ac @@ -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.])], diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 903308d0d..0176e5e3f 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -547,9 +547,9 @@ # # Interval 10.0 -# CollectHealth 0 -# CollectPerfMetrics 1 -# EnableDispatchAll 0 +# CollectHealth false +# CollectPerfMetrics true +# EnableDispatchAll false # # diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 996046c98..32cecb774 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -2541,14 +2541,15 @@ values. Defaults to the global hostname setting. =head2 Plugin C The I will collect Intel(R) Optane(TM) DC Persistent Memory related performance statistics. +The plugin requires root privileges to perform the statistics collection. B Interval 10.0 - CollectHealth 0 - CollectPerfMetrics 1 - EnableDispatchAll 0 + CollectHealth false + CollectPerfMetrics true + EnableDispatchAll false =over 4 @@ -2558,9 +2559,9 @@ B Sets the I in which the values will be collected. Defaults to C value. This will override the I for I plugin. None of the other plugins will be affected. -=item B I<0>|I<1> +=item B I|I -Collects health information. I. Defaults to C<0>. +Collects health information. I. Defaults to C. 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 I<0>|I<1> +=item B I|I -Collects memory performance metrics. I. Defaults to C<1>. +Collects memory performance metrics. I. Defaults to C. 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 I<0> +=item B I This parameter helps to seamlessly enable simultaneous health and memory perf metrics collection in future. -This is unused at the moment and I always be I<0>. +This is unused at the moment and I always be I. =back diff --git a/src/dcpmm.c b/src/dcpmm.c old mode 100755 new mode 100644 index 157cc707a..8a3acac99 --- a/src/dcpmm.c +++ b/src/dcpmm.c @@ -32,9 +32,10 @@ #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); -- 2.47.2