All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event
@ 2017-11-14  7:46 QI Fuli
  2017-11-14  7:46 ` [RFC PATCH v2 1/7] ndctl: nvdimmd: add LOG_NOTICE level into log_priority QI Fuli
                   ` (7 more replies)
  0 siblings, 8 replies; 20+ messages in thread
From: QI Fuli @ 2017-11-14  7:46 UTC (permalink / raw)
  To: linux-nvdimm

Hi, here is my second version of nvdimm daemon, It would be appreciated
if you could check it.

Change log since v1:
 - Adding a config file(/etc/nvdimmd/nvdimmd.conf)
 - Using struct log_ctx instead of syslog()
   - Using log_syslog() to save the notify messages to syslog
   - Using log_file() to save the notify messages to special file
 - Adding LOG_NOTICE level into log_priority
 - Using automake instead of Makefile
 - Adding a new util file(nvdimmd/util.c) including helper functions needed
   for nvdimm daemon.
 - Adding nvdimmd_test program

---
This is a patch set of nvdimmd, a tiny daemon to monitor the features of over
threshold events. When an over thershold event fires, nvdimmd will output the
notification including dimm health status to syslog or a special file to
users' configuration. Users can choose the output format to be structured json
or text.

Here are out put samples.
- json format:
2017/11/10 11:15:03 [28065] log_notify: nvdimm dimm over threshold notify
{
  "dev":"nmem1",
  "id":"cdab-0a-07e0-feffffff",
  "handle":1,
  "phys_id":1,
  "health":{
    "health_state":"non-critical",
    "temperature_celsius":23,
    "spares_percentage":75,
    "alarm_temperature":true,
    "alarm_spares":true,
    "temperature_threshold":40,
    "spares_threshold":5,
    "life_used_percentage":5,
    "shutdown_state":"clean"
  }
}
- text format:
2017/11/10 16:21:53 [12479] log_notify: nvdimm dimm over threshold notify
dev: nmem1
 health_state: non-critical
 spares_percentage: 75

TODO list:
 - The dimms to monitor should be filtered by namespace and region
 - Add more information into the notify message
 - Make nvdimmd_test an ndctl command or an option of ndctl inject-error

QI Fuli (7):
  ndctl: nvdimmd: add LOG_NOTICE level into log_priority
  ndctl: nvdimmd: add nvdimmd necessary util functions
  ndctl: nvdimmd: add nvdimmd necessary functions
  ndctl: nvdimmd: add body file of nvdimm daemon
  ndctl: nvdimmd: add nvdimmd config file
  ndctl: nvdimmd: add the unit file of systemd for nvdimmd service
  ndctl: nvdimmd: add a temporary test for nvdimm daemon

 Makefile.am             |   2 +-
 configure.ac            |   1 +
 nvdimmd/Makefile.am     |  47 ++++++++
 nvdimmd/libnvdimmd.c    | 315 ++++++++++++++++++++++++++++++++++++++++++++++++
 nvdimmd/libnvdimmd.h    |  53 ++++++++
 nvdimmd/nvdimmd.c       | 112 +++++++++++++++++
 nvdimmd/nvdimmd.conf    |  25 ++++
 nvdimmd/nvdimmd.service |   7 ++
 nvdimmd/nvdimmd_test.c  | 142 ++++++++++++++++++++++
 nvdimmd/util.c          |  80 ++++++++++++
 nvdimmd/util.h          |  33 +++++
 util/log.c              |   2 +
 util/log.h              |   3 +
 13 files changed, 821 insertions(+), 1 deletion(-)
 create mode 100644 nvdimmd/Makefile.am
 create mode 100644 nvdimmd/libnvdimmd.c
 create mode 100644 nvdimmd/libnvdimmd.h
 create mode 100644 nvdimmd/nvdimmd.c
 create mode 100644 nvdimmd/nvdimmd.conf
 create mode 100644 nvdimmd/nvdimmd.service
 create mode 100644 nvdimmd/nvdimmd_test.c
 create mode 100644 nvdimmd/util.c
 create mode 100644 nvdimmd/util.h

-- 
2.9.5


_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [RFC PATCH v2 1/7] ndctl: nvdimmd: add LOG_NOTICE level into log_priority
  2017-11-14  7:46 [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event QI Fuli
@ 2017-11-14  7:46 ` QI Fuli
  2017-11-14  7:46 ` [RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions QI Fuli
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: QI Fuli @ 2017-11-14  7:46 UTC (permalink / raw)
  To: linux-nvdimm

This patch adds LOG_NOTICE level into log_priority for the notifications.
Because the LOG_INFO level is too low for the notifications of nvdimm
dimm over threshold event, and the event notifications are not up to
LOG_ERROR level.

Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
---
 util/log.c | 2 ++
 util/log.h | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/util/log.c b/util/log.c
index cc4d7d8..c60ca33 100644
--- a/util/log.c
+++ b/util/log.c
@@ -50,6 +50,8 @@ static int log_priority(const char *priority)
 		return LOG_INFO;
 	if (strncmp(priority, "debug", 5) == 0)
 		return LOG_DEBUG;
+	if (strncmp(priority, "notice", 6) == 0)
+		return LOG_NOTICE;
 	return 0;
 }
 
diff --git a/util/log.h b/util/log.h
index 5fc56e8..495e0d3 100644
--- a/util/log.h
+++ b/util/log.h
@@ -48,15 +48,18 @@ do { \
 #  endif
 #  define log_info(ctx, arg...) log_cond(ctx, LOG_INFO, ## arg)
 #  define log_err(ctx, arg...) log_cond(ctx, LOG_ERR, ## arg)
+#  define log_notice(ctx, arg...) log_cond(ctx, LOG_NOTICE, ## arg)
 #else
 #  define log_dbg(ctx, arg...) log_null(ctx, ## arg)
 #  define log_info(ctx, arg...) log_null(ctx, ## arg)
 #  define log_err(ctx, arg...) log_null(ctx, ## arg)
+#  define log_notice(ctx, arg...) log_null(ctx, ## arg)
 #endif
 
 #define dbg(x, arg...) log_dbg(&(x)->ctx, ## arg)
 #define info(x, arg...) log_info(&(x)->ctx, ## arg)
 #define err(x, arg...) log_err(&(x)->ctx, ## arg)
+#define notice(x, arg...) log_notice(&(x)->ctx, ## arg)
 
 #ifndef HAVE_SECURE_GETENV
 #  ifdef HAVE___SECURE_GETENV
-- 
2.9.5


_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions
  2017-11-14  7:46 [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event QI Fuli
  2017-11-14  7:46 ` [RFC PATCH v2 1/7] ndctl: nvdimmd: add LOG_NOTICE level into log_priority QI Fuli
@ 2017-11-14  7:46 ` QI Fuli
  2017-11-20 21:19   ` Dan Williams
  2017-11-14  7:47 ` [RFC PATCH v2 3/7] ndctl: nvdimmd: add nvdimmd necessary functions QI Fuli
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: QI Fuli @ 2017-11-14  7:46 UTC (permalink / raw)
  To: linux-nvdimm

This patch is used to provide helper functions needed for nvdimm daemon.
These util functions can be used by other features as well in the future.

Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
---
 nvdimmd/util.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 nvdimmd/util.h | 33 ++++++++++++++++++++++++
 2 files changed, 113 insertions(+)
 create mode 100644 nvdimmd/util.c
 create mode 100644 nvdimmd/util.h

diff --git a/nvdimmd/util.c b/nvdimmd/util.c
new file mode 100644
index 0000000..ef6819e
--- /dev/null
+++ b/nvdimmd/util.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "util.h"
+
+void logrotate(char *file)
+{
+	time_t c_time;
+	char buf[4096], tstamp[32];
+
+	c_time = time(NULL);
+	strftime(tstamp, sizeof(tstamp), ".%Y%m%d%H%M%S", localtime(&c_time));
+	strcpy(buf, file);
+	strcat(buf, tstamp);
+	rename(file, buf);
+}
+
+long get_size(char *file)
+{
+	struct stat buf;
+	if (stat(file, &buf) == 0)
+		return buf.st_size;
+	return -1L;
+}
+
+char *set_string(char **str, const char *value)
+{
+	*str = strdup(value);
+	return *str;
+}
+
+char *trim_string(char *str)
+{
+	char *start;
+	char *end;
+	int len = strlen(str);
+
+	if (len == 0)
+		return NULL;
+
+	if (str[len-1] == '\n') {
+		len--;
+		str[len] = 0;
+	}
+
+	start = str;
+	end = str + len - 1;
+	while(*start && isspace(*start))
+		start++;
+	while(*end && isspace(*end))
+		*end-- = 0;
+	strcpy(str, start);
+	return str;
+}
+
+int split_string(char *str, const char *deli, char *outlist[])
+{
+	int cnt = 0;
+	char *temp;
+
+	temp = strtok(str, deli);
+	while (temp != NULL && cnt < NUM_MAX_DIMM) {
+		outlist[cnt++] = temp;
+		temp = strtok(NULL, deli);
+	}
+	return cnt;
+}
diff --git a/nvdimmd/util.h b/nvdimmd/util.h
new file mode 100644
index 0000000..9648256
--- /dev/null
+++ b/nvdimmd/util.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
+#ifndef _UTIL_H_
+#define _UTIL_H_
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <ctype.h>
+#define NUM_MAX_DIMM 1024
+
+void logrotate(char *file);
+
+long get_size(char *file);
+
+char *set_string(char **str, const char *value);
+
+char *trim_string(char *str);
+
+int split_string(char *str, const char *deli, char *outlist[]);
+
+#endif
-- 
2.9.5


_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC PATCH v2 3/7] ndctl: nvdimmd: add nvdimmd necessary functions
  2017-11-14  7:46 [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event QI Fuli
  2017-11-14  7:46 ` [RFC PATCH v2 1/7] ndctl: nvdimmd: add LOG_NOTICE level into log_priority QI Fuli
  2017-11-14  7:46 ` [RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions QI Fuli
@ 2017-11-14  7:47 ` QI Fuli
  2017-11-14  7:47 ` [RFC PATCH v2 4/7] ndctl: nvdimmd: add body file of nvdimm daemon QI Fuli
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: QI Fuli @ 2017-11-14  7:47 UTC (permalink / raw)
  To: linux-nvdimm

Libnvdimmd is used to provide nvdimmd necessary functions.
The get_nvdimmd_conf() will read the nvdimmd.conf and set the
parameters' value as global variables when nvdimmd service starts.

Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
---
 nvdimmd/libnvdimmd.c | 315 +++++++++++++++++++++++++++++++++++++++++++++++++++
 nvdimmd/libnvdimmd.h |  53 +++++++++
 2 files changed, 368 insertions(+)
 create mode 100644 nvdimmd/libnvdimmd.c
 create mode 100644 nvdimmd/libnvdimmd.h

diff --git a/nvdimmd/libnvdimmd.c b/nvdimmd/libnvdimmd.c
new file mode 100644
index 0000000..7e5d16b
--- /dev/null
+++ b/nvdimmd/libnvdimmd.c
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
+/*
+ * This program is used to provide nvdimm daemon necessary functions.
+ */
+
+#include <syslog.h>
+#include <json-c/json.h>
+#include <util/json.h>
+#include <util/filter.h>
+#include <ndctl/lib/private.h>
+#include <dirent.h>
+#include "libnvdimmd.h"
+
+void log_syslog(struct ndctl_ctx *ctx, int priority, const char *file,
+	int line, const char *fn, const char *format, va_list args)
+{
+	char buf[BUF_SIZE];
+	struct log_ctx *log_ctx;
+
+	log_ctx = &ctx->ctx;
+	vsnprintf(buf, sizeof(buf), format, args);
+	syslog(priority, "%s: %s: %s", log_ctx->owner, fn, buf);
+}
+
+void log_file(struct ndctl_ctx *ctx, int priority, const char *file,
+	int line, const char *fn, const char *format, va_list args)
+{
+	DIR *dir;
+	FILE *f;
+	time_t c_time;
+	char date[32], buf[BUF_SIZE];
+	char *filename;
+	int len = strlen(nvdimmd_cf->logfile) + strlen("/var/log/nvdimmd/");
+
+	filename = (char *) malloc(len);
+	strcpy(filename, "/var/log/nvdimmd/");
+	strcat(filename, nvdimmd_cf->logfile);
+
+	dir = opendir("/var/log/nvdimmd");
+	if (dir) {
+		if (get_size(filename) >= 20000000)
+			logrotate(filename);
+	} else {
+		if (mkdir("/var/log/nvdimmd", 0744) == -1) {
+			syslog(LOG_ERR, "cannot make dir /var/log/nvdimmd\n");
+			exit(EXIT_FAILURE);
+		}
+	}
+
+	f = fopen(filename, "a+");
+	if (f == NULL) {
+		syslog(LOG_ERR, "%s cannot be opened\n", filename);
+		exit(EXIT_FAILURE);
+	}
+
+	c_time = time(NULL);
+	strftime(date, sizeof(date), "%Y/%m/%d %H:%M:%S", localtime(&c_time));
+	vsnprintf(buf, sizeof(buf), format, args);
+	fprintf(f, "%s [%u] %s: %s\n", date, (int)getpid(), fn, buf);
+	fclose(f);
+	free(filename);
+}
+
+static char *get_json_msg(struct ndctl_ctx *ctx, struct threshold_dimm *t_dimm)
+{
+	struct json_object *jdimm, *jhealth;
+	char *msg;
+
+	msg = (char *) malloc(1024);
+	msg[0] = '\0';
+	jdimm = util_dimm_to_json(t_dimm->dimm, 0);
+	if (!jdimm) {
+		printf("no jdimm");
+	}
+	jhealth = util_dimm_health_to_json(t_dimm->dimm);
+	if (jhealth)
+		json_object_object_add(jdimm, "health", jhealth);
+	else if (ndctl_dimm_is_cmd_supported(t_dimm->dimm, ND_CMD_SMART))
+		dbg(ctx, "dimm [%s] do not support smart", t_dimm->devname);
+	else
+		dbg(ctx, "dimm [%s] can not get health info", t_dimm->devname);
+
+	strcat(msg, json_object_to_json_string_ext(jdimm,
+			JSON_C_TO_STRING_PRETTY));
+	return msg;
+}
+
+static char *get_text_msg(struct ndctl_ctx *ctx, struct threshold_dimm *t_dimm)
+{
+	char *msg;
+	struct ndctl_cmd *cmd;
+	int rc;
+	unsigned int flags;
+
+	msg = (char *) malloc(1024);
+	msg[0] = '\0';
+	strcat(msg, "dev: ");
+	strcat(msg, t_dimm->devname);
+	strcat(msg, "\n health_state: ");
+
+	cmd = ndctl_dimm_cmd_new_smart(t_dimm->dimm);
+	if (!cmd) {
+		dbg(ctx, "new smart command error");
+		goto out;
+	}
+
+	rc = ndctl_cmd_submit(cmd);
+	if (rc || ndctl_cmd_get_firmware_status(cmd)) {
+		dbg(ctx, "subbmit smart command error");
+		goto out;
+	}
+
+	flags = ndctl_cmd_smart_get_flags(cmd);
+	if (flags & ND_SMART_HEALTH_VALID) {
+		unsigned int health = ndctl_cmd_smart_get_health(cmd);
+		if (health & ND_SMART_FATAL_HEALTH)
+			strcat(msg, "fatal");
+		else if (health & ND_SMART_CRITICAL_HEALTH)
+			strcat(msg, "critical");
+		else if (health & ND_SMART_NON_CRITICAL_HEALTH)
+			strcat(msg, "non-critical");
+		else
+			strcat(msg, "ok");
+	} else {
+		strcat(msg, "failed to get data");
+	}
+	strcat(msg, "\n spares_percentage: ");
+
+	if (flags & ND_SMART_SPARES_VALID) {
+		char buf[6];
+		snprintf(buf, 6, "%d", ndctl_cmd_smart_get_spares(cmd));
+		strcat(msg, buf);
+	}
+	else
+		strcat(msg, "failed to get data");
+
+	ndctl_cmd_unref(cmd);
+	return msg;
+
+ out:
+	strcat(msg, "failed to get data\n spares_percentage: failed to get data");
+	return msg;
+}
+
+static void get_notice_msg(struct ndctl_ctx *ctx, struct threshold_dimm *t_dimm,
+				char **log_msg)
+{
+	char *msg;
+	msg = (char *) malloc(2048);
+	msg[0] = '\0';
+	strcat(msg, "nvdimm dimm over threshold notify\n");
+
+	if (strcmp(nvdimmd_cf->logformat, "json") == 0)
+		strcat(msg, get_json_msg(ctx, t_dimm));
+	else
+		strcat(msg, get_text_msg(ctx, t_dimm));
+
+	*log_msg = msg;
+}
+
+int log_notify(struct ndctl_ctx *ctx, struct threshold_dimm *t_dimm,
+		int cnt_dimm, fd_set fds, int cnt_select)
+{
+	int log_notify = 0;
+	char *log_msg;
+
+	for (int i = 0; i < cnt_dimm; i++) {
+		if (log_notify >= cnt_select)
+			break;
+
+		if (!FD_ISSET(t_dimm[i].health_eventfd, &fds))
+			continue;
+		log_notify++;
+
+		get_notice_msg(ctx, &t_dimm[i], &log_msg);
+		notice(ctx, "%s", log_msg);
+		free(log_msg);
+	}
+	return log_notify;
+}
+
+int get_threshold_dimm(struct ndctl_ctx *ctx, struct threshold_dimm *t_dimm,
+			fd_set *fds, int *maxfd)
+{
+	struct ndctl_bus *bus;
+	struct ndctl_dimm *dimm;
+	bool flag = false;
+	int fd, cnt_dimm = 0;
+	char buf[BUF_SIZE];
+
+	ndctl_bus_foreach(ctx, bus) {
+		for (int i = 0; i < cnt_mbus; i++) {
+			if (util_bus_filter(bus, buslist[i])) {
+				flag = true;
+				break;
+			}
+		}
+		if (!flag)
+			continue;
+		flag = false;
+		ndctl_dimm_foreach(bus, dimm) {
+			for (int j = 0; j < cnt_mdimm; j++) {
+				if (util_dimm_filter(dimm, dimmlist[j])) {
+					flag = true;
+					break;
+				}
+			}
+			if (!flag)
+				continue;
+			flag = false;
+			if (!ndctl_dimm_is_cmd_supported(dimm,
+					ND_CMD_SMART_THRESHOLD))
+				continue;
+			t_dimm[cnt_dimm].dimm = dimm;
+			t_dimm[cnt_dimm].devname = ndctl_dimm_get_devname(dimm);
+			fd = ndctl_dimm_get_health_eventfd(dimm);
+			read(fd, buf, sizeof(buf));
+			t_dimm[cnt_dimm].health_eventfd = fd;
+
+			if (fds)
+				FD_SET(fd, fds);
+			if (maxfd) {
+				if (*maxfd < fd)
+					*maxfd = fd;
+			}
+			cnt_dimm++;
+		}
+	}
+	return cnt_dimm;
+}
+
+int get_nvdimmd_conf(const char *path)
+{
+	FILE *f;
+	char buf[BUF_SIZE];
+	struct nvdimmd_conf *conf;
+
+	f = fopen(path, "r");
+	if (f == NULL) {
+		syslog(LOG_ERR, "%s cannot be found\n", path);
+		return -1;
+	}
+
+	conf = calloc(1, sizeof(struct nvdimmd_conf));
+	if (conf == NULL)
+		goto file_err;
+
+	while (fgets(buf, BUF_SIZE, f) != NULL) {
+		char *key;
+		char *value;
+
+		key = trim_string(buf);
+
+		if (key[0] == '#' || key[0] == '\0'){
+			continue;
+		}
+
+		value = strchr(key, '=');
+		if (value == NULL)
+			continue;
+
+		value[0] = '\0';
+		value++;
+
+		key = trim_string(key);
+		if (key == NULL)
+			continue;
+		value = trim_string(value);
+		if (value == NULL)
+			continue;
+
+		if (strcmp(key, "LOGFILE") == 0) {
+			set_string(&conf->logfile, value);
+			continue;
+		}
+		if (strcmp(key, "LOGFORMAT") == 0) {
+			set_string(&conf->logformat, value);
+			continue;
+		}
+		if (strcmp(key, "MONITORBUS") == 0) {
+			set_string(&conf->mbus, value);
+			continue;
+		}
+		if (strcmp(key, "MONITORDIMM") == 0) {
+			set_string(&conf->mdimm, value);
+			continue;
+		}
+	}
+	fclose(f);
+
+	if (conf->logfile == NULL || conf->logformat == NULL
+		|| conf->mbus == NULL || conf->mdimm == NULL)
+		return -1;
+
+	nvdimmd_cf = conf;
+	cnt_mbus = split_string(nvdimmd_cf->mbus, ",", buslist);
+	cnt_mdimm = split_string(nvdimmd_cf->mdimm, ",", dimmlist);
+	return 0;
+
+file_err:
+	fclose(f);
+	return -1;
+}
diff --git a/nvdimmd/libnvdimmd.h b/nvdimmd/libnvdimmd.h
new file mode 100644
index 0000000..75317e0
--- /dev/null
+++ b/nvdimmd/libnvdimmd.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
+#ifndef _LIBNVDIMMD_H_
+#define _LIBBVDIMMD_H_
+
+#include <stdio.h>
+#include <util/log.h>
+#include <ndctl/libndctl.h>
+#include "util.h"
+#define BUF_SIZE 4096
+
+struct nvdimmd_conf {
+	char *logfile;
+	char *logformat;
+	char *mbus;
+	char *mdimm;
+};
+
+struct threshold_dimm {
+	struct ndctl_dimm *dimm;
+	const char *devname;
+	int health_eventfd;
+};
+
+struct nvdimmd_conf *nvdimmd_cf;
+char *buslist[NUM_MAX_DIMM];
+char *dimmlist[NUM_MAX_DIMM];
+int cnt_mbus, cnt_mdimm;
+
+void log_syslog(struct ndctl_ctx *ctx, int priority, const char *file, int line,
+		const char *fn, const char *format, va_list args);
+void log_file(struct ndctl_ctx *ctx, int priority, const char *file,
+	int line, const char *fn, const char *format, va_list args);
+
+int log_notify(struct ndctl_ctx *ctx, struct threshold_dimm *t_dimm,
+		int count_dimm, fd_set fds, int count_select);
+int get_threshold_dimm(struct ndctl_ctx *ctx,
+		struct threshold_dimm *t_dimm, fd_set *fds, int *maxfd);
+
+int get_nvdimmd_conf(const char *path);
+
+#endif
-- 
2.9.5


_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC PATCH v2 4/7] ndctl: nvdimmd: add body file of nvdimm daemon
  2017-11-14  7:46 [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event QI Fuli
                   ` (2 preceding siblings ...)
  2017-11-14  7:47 ` [RFC PATCH v2 3/7] ndctl: nvdimmd: add nvdimmd necessary functions QI Fuli
@ 2017-11-14  7:47 ` QI Fuli
  2017-11-20 21:31   ` Dan Williams
  2017-11-14  7:47 ` [RFC PATCH v2 5/7] ndctl: nvdimmd: add nvdimmd config file QI Fuli
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: QI Fuli @ 2017-11-14  7:47 UTC (permalink / raw)
  To: linux-nvdimm

This patch adds the body file of nvdimm daemon and compiles nvdimmd
with automake.

Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
---
 Makefile.am         |   2 +-
 configure.ac        |   1 +
 nvdimmd/Makefile.am |  19 +++++++++
 nvdimmd/nvdimmd.c   | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 nvdimmd/Makefile.am
 create mode 100644 nvdimmd/nvdimmd.c

diff --git a/Makefile.am b/Makefile.am
index b538b1f..ff91439 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
 include Makefile.am.in
 
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-SUBDIRS = . daxctl/lib ndctl/lib ndctl daxctl
+SUBDIRS = . daxctl/lib ndctl/lib ndctl daxctl nvdimmd
 if ENABLE_DOCS
 SUBDIRS += Documentation/ndctl Documentation/daxctl
 endif
diff --git a/configure.ac b/configure.ac
index 5b10381..3ce71e3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -274,6 +274,7 @@ AC_CONFIG_FILES([
         daxctl/lib/Makefile
         ndctl/lib/Makefile
         ndctl/Makefile
+	nvdimmd/Makefile
         daxctl/Makefile
         test/Makefile
         Documentation/ndctl/Makefile
diff --git a/nvdimmd/Makefile.am b/nvdimmd/Makefile.am
new file mode 100644
index 0000000..9883edd
--- /dev/null
+++ b/nvdimmd/Makefile.am
@@ -0,0 +1,19 @@
+include $(top_srcdir)/Makefile.am.in
+
+bin_PROGRAMS = nvdimmd
+
+nvdimmd_SOURCES =\
+		nvdimmd.c \
+		libnvdimmd.c \
+		util.c \
+		../util/log.c \
+		../util/json.c \
+		../ndctl/util/json-smart.c
+
+nvdimmd_LDADD = ../ndctl/lib/libndctl.la \
+		../daxctl/lib/libdaxctl.la \
+		../libutil.a \
+		$(KMOD_LIBS) \
+		$(JSON_LIBS) \
+		$(UUID_LIBS) \
+		$(UDEV_LIBS)
diff --git a/nvdimmd/nvdimmd.c b/nvdimmd/nvdimmd.c
new file mode 100644
index 0000000..f451751
--- /dev/null
+++ b/nvdimmd/nvdimmd.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
+/*
+ * Nvdimm daemon is used to monitor the features of over threshold events.
+ * It automatically searches and monitors all of the dimms which support smart
+ * threshold. When an over threshold event fires, it will write a notification
+ * into the system log.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <syslog.h>
+#include <errno.h>
+#include <ndctl/lib/private.h>
+#include "libnvdimmd.h"
+
+static int wait_threshold_notify(struct ndctl_ctx *ctx)
+{
+	int rc, maxfd, cnt_dimm;
+	struct threshold_dimm *t_dimm;
+
+	t_dimm = calloc(NUM_MAX_DIMM, sizeof(struct threshold_dimm));
+	if (!t_dimm) {
+		err(ctx, "t_dimm memory not allocated");
+		goto out;
+	}
+
+	fd_set fds;
+	FD_ZERO(&fds);
+
+	cnt_dimm = get_threshold_dimm(ctx, t_dimm, &fds, &maxfd);
+	if (cnt_dimm == 0) {
+		err(ctx, "no dimm supports over threshold notification\n");
+		goto out;
+	}
+
+	rc = select(maxfd + 1, NULL, NULL, &fds, NULL);
+	if (rc < 1) {
+		if (rc == 0)
+			err(ctx, "select unexpected timeout\n");
+		else
+			err(ctx, "select %s\n", strerror(errno));
+		goto out;
+	}
+
+	log_notify(ctx, t_dimm, cnt_dimm, fds, rc);
+
+	free(t_dimm);
+	return 0;
+
+out:
+	return 1;
+}
+
+static void nvdimmd_log_init(struct ndctl_ctx *ctx, int priority,
+				const char *owner, const char *log_env)
+{
+	log_init(&ctx->ctx, owner, log_env);
+	ndctl_set_log_priority(ctx, priority);
+	if (strcmp(nvdimmd_cf->logfile, "syslog") == 0)
+		ndctl_set_log_fn(ctx, log_syslog);
+	else
+		ndctl_set_log_fn(ctx, log_file);
+}
+
+int main(void)
+{
+	if (daemon(0, 0) != 0) {
+		syslog(LOG_ERR, "nvdimmd error: daemon start failed\n");
+		exit(EXIT_FAILURE);
+	}
+	struct ndctl_ctx *ctx;
+	int rc, ret = 0;
+	const char *conf_path = "/etc/nvdimmd/nvdimmd.conf";
+
+	syslog(LOG_INFO, "nvdimmd: started\n");
+
+	if (get_nvdimmd_conf(conf_path) != 0) {
+		syslog(LOG_ERR, "nvdimmd.conf error \n");
+		goto out;
+	}
+
+	while (ret == 0) {
+		rc = ndctl_new(&ctx);
+		if (rc)
+			goto out;
+
+		nvdimmd_log_init(ctx, LOG_NOTICE, "nvdimmd", "NVDIMMD_LOG");
+		ret = wait_threshold_notify(ctx);
+		ndctl_unref(ctx);
+	}
+
+	syslog(LOG_INFO, "nvdimmd: ended\n");
+	return 0;
+
+out:
+	return 1;
+}
-- 
2.9.5


_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC PATCH v2 5/7] ndctl: nvdimmd: add nvdimmd config file
  2017-11-14  7:46 [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event QI Fuli
                   ` (3 preceding siblings ...)
  2017-11-14  7:47 ` [RFC PATCH v2 4/7] ndctl: nvdimmd: add body file of nvdimm daemon QI Fuli
@ 2017-11-14  7:47 ` QI Fuli
  2017-11-14  7:47 ` [RFC PATCH v2 6/7] ndctl: nvdimmd: add the unit file of systemd for nvdimmd service QI Fuli
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: QI Fuli @ 2017-11-14  7:47 UTC (permalink / raw)
  To: linux-nvdimm

This patch adds nvdimmd.conf.
Autotools to install the config file for nvdimmd service.
The nvdimmd.conf includs the following parameters.
   - LOGFILE: Users can choose either to write the notifications into syslog
     (LOGFILE=syslog), or to send into a special file under /var/log/nvdimmd/
     (such as LOGFILE=nvdimmd.log) by configuring LOGFILE parameter in the
     config file.
   - LOGFORMAT: Users can choose the format of notification to be structured
     json(LOGFORMAT=json) or text(LOGFORMAT=text) by configuring LOGFORMAT
     parameter in the config file.
   - MONITORDIMM: The dimms to monitor are filtered via dimm's name by setting
     MONITORDIMM parameter in the config file. When setting up multiple dimms,
     the names of dimms should be separated by ",".(MONITORDIMM=nmem0,nmem1,nmem2)
   - MONITORBUS: The dimms to monitor are filtered via its parent bus by setting
     MONITORBUS parameter as well. When setting up multiple dimms, the names of
     buses should be separated by "," (MONITORBUS=ndbus0,ndbus1)
The nvdimmd.conf would be read when nvdimmd service starts. Users need to restart
nvdimmd service after changing the value of paramaters in nvdimmd.conf.

Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
---
 nvdimmd/Makefile.am  |  9 +++++++++
 nvdimmd/nvdimmd.conf | 25 +++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 nvdimmd/nvdimmd.conf

diff --git a/nvdimmd/Makefile.am b/nvdimmd/Makefile.am
index 9883edd..6716547 100644
--- a/nvdimmd/Makefile.am
+++ b/nvdimmd/Makefile.am
@@ -17,3 +17,12 @@ nvdimmd_LDADD = ../ndctl/lib/libndctl.la \
 		$(JSON_LIBS) \
 		$(UUID_LIBS) \
 		$(UDEV_LIBS)
+
+conffiles = nvdimmd.conf
+
+confdir = /etc/nvdimmd/
+
+conf_DATA = $(conffiles)
+
+EXTRA_DIST =\
+	$(conffiles)
diff --git a/nvdimmd/nvdimmd.conf b/nvdimmd/nvdimmd.conf
new file mode 100644
index 0000000..4e6a12a
--- /dev/null
+++ b/nvdimmd/nvdimmd.conf
@@ -0,0 +1,25 @@
+# This is the main Nvdimm daemon configuration file. It contains the
+# configuration directives that give nvdimmd its instructions.
+# You can change settings by editing this file.
+# The changed item will work after restart nvdimmd service.
+# In this file, lines starting with a hash (#) are comments.
+# The following charecters are not allowed the value: : # ? / \ % " '
+
+# LOGFILE: Users can choose either to write the notifications into syslog
+# (LOGFILE=syslog), or to send into a special file under /var/log/nvdimmd/
+# (such as LOGFILE=nvdimmd.log) by setting LOGFILE.
+LOGFILE=nvdimmd.log
+
+# LOGFORMAT: Users can choose the format of notification to be json
+# (LOGFORMAT=json) or text(LOGFORMAT=text) by setting LOGFORMAT.
+LOGFORMAT = json
+
+# MONITORDIMM: The dimms to monitor are filtered via dimm's name by setting
+# MONITORDIMM. When setting up mutiple dimms, the names of dimms should be
+# separated by ",".(MONITORDIMM=nmem0,nmem1,nmem2)
+MONITORDIMM=all
+
+# MONITORBUS: The dimms to monitor are filtered via its parent bus by
+# setting as well. When setting up mutiple dimms, the names of buses
+# should be seprated by "," (MONITORBUS=ndbus0,ndbus1)
+MONITORBUS=all
-- 
2.9.5


_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC PATCH v2 6/7] ndctl: nvdimmd: add the unit file of systemd for nvdimmd service
  2017-11-14  7:46 [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event QI Fuli
                   ` (4 preceding siblings ...)
  2017-11-14  7:47 ` [RFC PATCH v2 5/7] ndctl: nvdimmd: add nvdimmd config file QI Fuli
@ 2017-11-14  7:47 ` QI Fuli
  2017-11-14  7:47 ` [RFC PATCH v2 7/7] ndctl: nvdimmd: add a temporary test for nvdimm daemon QI Fuli
  2017-11-20  6:33 ` [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event Dan Williams
  7 siblings, 0 replies; 20+ messages in thread
From: QI Fuli @ 2017-11-14  7:47 UTC (permalink / raw)
  To: linux-nvdimm

This patch adds and autotools to install the unit file of systemd for
nvdimmd service.

Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
---
 nvdimmd/Makefile.am     | 7 +++++++
 nvdimmd/nvdimmd.service | 7 +++++++
 2 files changed, 14 insertions(+)
 create mode 100644 nvdimmd/nvdimmd.service

diff --git a/nvdimmd/Makefile.am b/nvdimmd/Makefile.am
index 6716547..bca0bc8 100644
--- a/nvdimmd/Makefile.am
+++ b/nvdimmd/Makefile.am
@@ -18,6 +18,12 @@ nvdimmd_LDADD = ../ndctl/lib/libndctl.la \
 		$(UUID_LIBS) \
 		$(UDEV_LIBS)
 
+unitfiles = nvdimmd.service
+
+unitdir = /usr/lib/systemd/system/
+
+unit_DATA = $(unitfiles)
+
 conffiles = nvdimmd.conf
 
 confdir = /etc/nvdimmd/
@@ -25,4 +31,5 @@ confdir = /etc/nvdimmd/
 conf_DATA = $(conffiles)
 
 EXTRA_DIST =\
+	$(unitfiles) \
 	$(conffiles)
diff --git a/nvdimmd/nvdimmd.service b/nvdimmd/nvdimmd.service
new file mode 100644
index 0000000..0b96aaa
--- /dev/null
+++ b/nvdimmd/nvdimmd.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Nvdimm Daemon
+
+[Service]
+Type=forking
+ExecStart=/usr/bin/nvdimmd
+ExecStop=/usr/bin/kill ${MAINPID}
-- 
2.9.5


_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC PATCH v2 7/7] ndctl: nvdimmd: add a temporary test for nvdimm daemon
  2017-11-14  7:46 [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event QI Fuli
                   ` (5 preceding siblings ...)
  2017-11-14  7:47 ` [RFC PATCH v2 6/7] ndctl: nvdimmd: add the unit file of systemd for nvdimmd service QI Fuli
@ 2017-11-14  7:47 ` QI Fuli
  2017-11-20  6:33 ` [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event Dan Williams
  7 siblings, 0 replies; 20+ messages in thread
From: QI Fuli @ 2017-11-14  7:47 UTC (permalink / raw)
  To: linux-nvdimm

This patch is used to test nvdimmd service temporarily.
I will make it an ndctl command or an option of ndctl inject-error
in next step.
Currently, You can test nvdimm daemon with the following command.

  nvdimmd_test [nmemX] [all]

Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
---
 nvdimmd/Makefile.am    |  14 ++++-
 nvdimmd/nvdimmd_test.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 155 insertions(+), 1 deletion(-)
 create mode 100644 nvdimmd/nvdimmd_test.c

diff --git a/nvdimmd/Makefile.am b/nvdimmd/Makefile.am
index bca0bc8..cca1980 100644
--- a/nvdimmd/Makefile.am
+++ b/nvdimmd/Makefile.am
@@ -1,6 +1,6 @@
 include $(top_srcdir)/Makefile.am.in
 
-bin_PROGRAMS = nvdimmd
+bin_PROGRAMS = nvdimmd nvdimmd_test
 
 nvdimmd_SOURCES =\
 		nvdimmd.c \
@@ -18,6 +18,18 @@ nvdimmd_LDADD = ../ndctl/lib/libndctl.la \
 		$(UUID_LIBS) \
 		$(UDEV_LIBS)
 
+nvdimmd_test_SOURCES =\
+		nvdimmd_test.c \
+		../util/log.c
+
+nvdimmd_test_LDADD =\
+		../ndctl/lib/libndctl.la \
+		../daxctl/lib/libdaxctl.la \
+		../libutil.a \
+		$(KMOD_LIBS) \
+		$(UUID_LIBS) \
+		$(UDEV_LIBS)
+
 unitfiles = nvdimmd.service
 
 unitdir = /usr/lib/systemd/system/
diff --git a/nvdimmd/nvdimmd_test.c b/nvdimmd/nvdimmd_test.c
new file mode 100644
index 0000000..8d16243
--- /dev/null
+++ b/nvdimmd/nvdimmd_test.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2017, FUJITSU LIMITED. All rirhts reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
+/*
+ * This program is used to call the emulation of event of over threshold.
+ * You can test nvdimmd daemon with the following command.
+ * nvdimmd_test [nmemX] [all]
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <syslog.h>
+#include <util/log.h>
+#include <ndctl/libndctl.h>
+#define NUM_MAX_DIMM 1024
+#include <ndctl/lib/private.h>
+
+struct threshold_dimm {
+	struct ndctl_dimm *dimm;
+	const char *devname;
+	int health_eventfd;
+};
+
+const char *test_help_info = "nvdimmd_test [nmemX] [all]";
+
+static int get_threshold(struct ndctl_ctx *ctx, struct threshold_dimm *t_dimm)
+{
+	struct ndctl_bus *bus;
+	struct ndctl_dimm *dimm;
+	int cnt_dimm = 0;
+
+	ndctl_bus_foreach(ctx, bus) {
+		ndctl_dimm_foreach(bus, dimm) {
+			if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART_THRESHOLD))
+				continue;
+			t_dimm[cnt_dimm].dimm = dimm;
+			t_dimm[cnt_dimm].devname = ndctl_dimm_get_devname(dimm);
+			cnt_dimm++;
+		}
+	}
+	return cnt_dimm;
+}
+
+static int test_submit_cmd(struct threshold_dimm *t_dimm)
+{
+	struct ndctl_cmd *cmd;
+	const char *msg = "command to call over threshold event notification: ";
+
+	cmd = ndctl_dimm_cmd_new_smart_threshold(t_dimm->dimm);
+	if (!cmd) {
+		fprintf(stderr, "failed to prepare %s[%s]\n",
+				msg, t_dimm->devname);
+		return -1;
+	}
+	if(ndctl_cmd_submit(cmd)) {
+		fprintf(stderr, "failed to submit %s[%s]\n",
+				msg, t_dimm->devname);
+		return -1;
+	}
+	ndctl_cmd_unref(cmd);
+	return 0;
+}
+
+static int
+test_submit(struct threshold_dimm *t_dimm, int count_dimm, char *test_devname)
+{
+	int count_test = 0;
+
+	for (int i= 0; i < count_dimm; i++) {
+		if (!strcmp(test_devname, "all")) {
+			if (!test_submit_cmd(&t_dimm[i]))
+				count_test++;
+			continue;
+		}
+		if (!strcmp(test_devname, t_dimm[i].devname)) {
+			if (!test_submit_cmd(&t_dimm[i]))
+				count_test++;
+			else
+				count_test--;
+			break;
+		}
+	}
+	return count_test;
+}
+
+int main(int argc, char *argv[])
+{
+	struct ndctl_ctx *ctx;
+	int rc, count_dimm;
+	char *test_devname;
+	struct threshold_dimm *t_dimm;
+
+	if (argc < 1) {
+		fprintf(stderr, "usage: %s\n", test_help_info);
+		goto out;
+	}
+
+	test_devname = argv[1];
+	if (!test_devname || !strcmp(test_devname, "--help")){
+		fprintf(stderr, "usage: %s\n", test_help_info);
+		goto out;
+	}
+	rc = ndctl_new(&ctx);
+	if (rc)
+		goto out;
+
+	t_dimm = calloc(NUM_MAX_DIMM, sizeof(struct threshold_dimm));
+	if (!t_dimm) {
+		fprintf(stderr, "nvdimmd test error: memory not allocate\n");
+		goto out;
+	}
+
+	count_dimm = get_threshold(ctx, t_dimm);
+	if (count_dimm == 0) {
+		fprintf(stderr, "nvdimmd test error: no dimm support over threshold\n");
+		goto out;
+	}
+
+	rc = test_submit(t_dimm, count_dimm, test_devname);
+
+	if (!rc && strcmp(test_devname, "all"))
+		fprintf(stderr, "UNKNOWM DIMM_NAME\n");
+	else if (rc >= 0)
+		printf("%d nvdimmd test submit: [%s]\n", rc, test_devname);
+
+	ndctl_unref(ctx);
+out:
+	return 1;
+}
-- 
2.9.5


_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event
  2017-11-14  7:46 [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event QI Fuli
                   ` (6 preceding siblings ...)
  2017-11-14  7:47 ` [RFC PATCH v2 7/7] ndctl: nvdimmd: add a temporary test for nvdimm daemon QI Fuli
@ 2017-11-20  6:33 ` Dan Williams
  2017-11-20 10:07   ` Yasunori Goto
  7 siblings, 1 reply; 20+ messages in thread
From: Dan Williams @ 2017-11-20  6:33 UTC (permalink / raw)
  To: QI Fuli; +Cc: linux-nvdimm

On Mon, Nov 13, 2017 at 11:46 PM, QI Fuli <qi.fuli@jp.fujitsu.com> wrote:
> Hi, here is my second version of nvdimm daemon, It would be appreciated
> if you could check it.
>
> Change log since v1:
>  - Adding a config file(/etc/nvdimmd/nvdimmd.conf)
>  - Using struct log_ctx instead of syslog()
>    - Using log_syslog() to save the notify messages to syslog
>    - Using log_file() to save the notify messages to special file
>  - Adding LOG_NOTICE level into log_priority
>  - Using automake instead of Makefile
>  - Adding a new util file(nvdimmd/util.c) including helper functions needed
>    for nvdimm daemon.
>  - Adding nvdimmd_test program
>
> ---
> This is a patch set of nvdimmd, a tiny daemon to monitor the features of over
> threshold events. When an over thershold event fires, nvdimmd will output the
> notification including dimm health status to syslog or a special file to
> users' configuration. Users can choose the output format to be structured json
> or text.
>
> Here are out put samples.
> - json format:
> 2017/11/10 11:15:03 [28065] log_notify: nvdimm dimm over threshold notify
> {
>   "dev":"nmem1",
>   "id":"cdab-0a-07e0-feffffff",
>   "handle":1,
>   "phys_id":1,
>   "health":{
>     "health_state":"non-critical",
>     "temperature_celsius":23,
>     "spares_percentage":75,
>     "alarm_temperature":true,
>     "alarm_spares":true,
>     "temperature_threshold":40,
>     "spares_threshold":5,
>     "life_used_percentage":5,
>     "shutdown_state":"clean"
>   }
> }
> - text format:
> 2017/11/10 16:21:53 [12479] log_notify: nvdimm dimm over threshold notify
> dev: nmem1
>  health_state: non-critical
>  spares_percentage: 75

Are these formats that services like Scribe and Fluent can consume?
I'd like to see a sample hook up to those applications.

I'm also wondering that since this will be a long running service that
may gain more functionality over time, if we should write it in a
language that does not have the security sharp edges of C.

I've been looking for an excuse to use the Go language on a project,
and this seems a good opportunity.

>
> TODO list:
>  - The dimms to monitor should be filtered by namespace and region

Yes, I'd like to make this equivalent to 'ndctl list' in terms filtering.

>  - Add more information into the notify message
>  - Make nvdimmd_test an ndctl command or an option of ndctl inject-error

Yes, the test events should originate from "ndctl inject-error".
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event
  2017-11-20  6:33 ` [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event Dan Williams
@ 2017-11-20 10:07   ` Yasunori Goto
  2017-11-20 16:13     ` Dan Williams
  0 siblings, 1 reply; 20+ messages in thread
From: Yasunori Goto @ 2017-11-20 10:07 UTC (permalink / raw)
  To: Dan Williams; +Cc: linux-nvdimm

> On Mon, Nov 13, 2017 at 11:46 PM, QI Fuli <qi.fuli@jp.fujitsu.com> wrote:
> > Hi, here is my second version of nvdimm daemon, It would be appreciated
> > if you could check it.
> >
> > Change log since v1:
> >  - Adding a config file(/etc/nvdimmd/nvdimmd.conf)
> >  - Using struct log_ctx instead of syslog()
> >    - Using log_syslog() to save the notify messages to syslog
> >    - Using log_file() to save the notify messages to special file
> >  - Adding LOG_NOTICE level into log_priority
> >  - Using automake instead of Makefile
> >  - Adding a new util file(nvdimmd/util.c) including helper functions needed
> >    for nvdimm daemon.
> >  - Adding nvdimmd_test program
> >
> > ---
> > This is a patch set of nvdimmd, a tiny daemon to monitor the features of over
> > threshold events. When an over thershold event fires, nvdimmd will output the
> > notification including dimm health status to syslog or a special file to
> > users' configuration. Users can choose the output format to be structured json
> > or text.
> >
> > Here are out put samples.
> > - json format:
> > 2017/11/10 11:15:03 [28065] log_notify: nvdimm dimm over threshold notify
> > {
> >   "dev":"nmem1",
> >   "id":"cdab-0a-07e0-feffffff",
> >   "handle":1,
> >   "phys_id":1,
> >   "health":{
> >     "health_state":"non-critical",
> >     "temperature_celsius":23,
> >     "spares_percentage":75,
> >     "alarm_temperature":true,
> >     "alarm_spares":true,
> >     "temperature_threshold":40,
> >     "spares_threshold":5,
> >     "life_used_percentage":5,
> >     "shutdown_state":"clean"
> >   }
> > }
> > - text format:
> > 2017/11/10 16:21:53 [12479] log_notify: nvdimm dimm over threshold notify
> > dev: nmem1
> >  health_state: non-critical
> >  spares_percentage: 75
> 
> Are these formats that services like Scribe and Fluent can consume?
> I'd like to see a sample hook up to those applications.
> 
> I'm also wondering that since this will be a long running service that
> may gain more functionality over time, if we should write it in a
> language that does not have the security sharp edges of C.
> 
> I've been looking for an excuse to use the Go language on a project,
> and this seems a good opportunity.

Hmmmmm, This seems to be big change of direction of nvdimmd.

Certainly, go-lang is good and interesting language in my impression.
But, if nvdimmd is re-created by go-lang, I suppose nvdimmd will need to
discard many functions of ndctl libraries, and need to re-create them by golang.

(Though golang may be able to link C-lang libraries, then its security
 will be simlar with C-lang level, not go-lang level, I think.)

Do you intent that we should re-create many functions for golang?

In addition, do you include source code of go-lang nvdimmd in ndctl source code?


Thanks,


> 
> >
> > TODO list:
> >  - The dimms to monitor should be filtered by namespace and region
> 
> Yes, I'd like to make this equivalent to 'ndctl list' in terms filtering.
> 
> >  - Add more information into the notify message
> >  - Make nvdimmd_test an ndctl command or an option of ndctl inject-error
> 
> Yes, the test events should originate from "ndctl inject-error".
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm



_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event
  2017-11-20 10:07   ` Yasunori Goto
@ 2017-11-20 16:13     ` Dan Williams
  2017-11-21  1:59       ` Qi, Fuli
  0 siblings, 1 reply; 20+ messages in thread
From: Dan Williams @ 2017-11-20 16:13 UTC (permalink / raw)
  To: Yasunori Goto; +Cc: linux-nvdimm

On Mon, Nov 20, 2017 at 2:07 AM, Yasunori Goto <y-goto@jp.fujitsu.com> wrote:
>> On Mon, Nov 13, 2017 at 11:46 PM, QI Fuli <qi.fuli@jp.fujitsu.com> wrote:
>> > Hi, here is my second version of nvdimm daemon, It would be appreciated
>> > if you could check it.
>> >
>> > Change log since v1:
>> >  - Adding a config file(/etc/nvdimmd/nvdimmd.conf)
>> >  - Using struct log_ctx instead of syslog()
>> >    - Using log_syslog() to save the notify messages to syslog
>> >    - Using log_file() to save the notify messages to special file
>> >  - Adding LOG_NOTICE level into log_priority
>> >  - Using automake instead of Makefile
>> >  - Adding a new util file(nvdimmd/util.c) including helper functions needed
>> >    for nvdimm daemon.
>> >  - Adding nvdimmd_test program
>> >
>> > ---
>> > This is a patch set of nvdimmd, a tiny daemon to monitor the features of over
>> > threshold events. When an over thershold event fires, nvdimmd will output the
>> > notification including dimm health status to syslog or a special file to
>> > users' configuration. Users can choose the output format to be structured json
>> > or text.
>> >
>> > Here are out put samples.
>> > - json format:
>> > 2017/11/10 11:15:03 [28065] log_notify: nvdimm dimm over threshold notify
>> > {
>> >   "dev":"nmem1",
>> >   "id":"cdab-0a-07e0-feffffff",
>> >   "handle":1,
>> >   "phys_id":1,
>> >   "health":{
>> >     "health_state":"non-critical",
>> >     "temperature_celsius":23,
>> >     "spares_percentage":75,
>> >     "alarm_temperature":true,
>> >     "alarm_spares":true,
>> >     "temperature_threshold":40,
>> >     "spares_threshold":5,
>> >     "life_used_percentage":5,
>> >     "shutdown_state":"clean"
>> >   }
>> > }
>> > - text format:
>> > 2017/11/10 16:21:53 [12479] log_notify: nvdimm dimm over threshold notify
>> > dev: nmem1
>> >  health_state: non-critical
>> >  spares_percentage: 75
>>
>> Are these formats that services like Scribe and Fluent can consume?
>> I'd like to see a sample hook up to those applications.
>>
>> I'm also wondering that since this will be a long running service that
>> may gain more functionality over time, if we should write it in a
>> language that does not have the security sharp edges of C.
>>
>> I've been looking for an excuse to use the Go language on a project,
>> and this seems a good opportunity.
>
> Hmmmmm, This seems to be big change of direction of nvdimmd.
>
> Certainly, go-lang is good and interesting language in my impression.
> But, if nvdimmd is re-created by go-lang, I suppose nvdimmd will need to
> discard many functions of ndctl libraries, and need to re-create them by golang.
>
> (Though golang may be able to link C-lang libraries, then its security
>  will be simlar with C-lang level, not go-lang level, I think.)
>
> Do you intent that we should re-create many functions for golang?
>
> In addition, do you include source code of go-lang nvdimmd in ndctl source code?

Yes, but let's continue with C for now, I took a look and the impact
is not quite as straightforward as I thought.

The next step is to build a demonstration of Scribe or Fluentd
consuming nvdimmd events.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions
  2017-11-14  7:46 ` [RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions QI Fuli
@ 2017-11-20 21:19   ` Dan Williams
  2017-12-06  7:14     ` Qi, Fuli
  0 siblings, 1 reply; 20+ messages in thread
From: Dan Williams @ 2017-11-20 21:19 UTC (permalink / raw)
  To: QI Fuli; +Cc: linux-nvdimm

On Mon, Nov 13, 2017 at 11:46 PM, QI Fuli <qi.fuli@jp.fujitsu.com> wrote:
> This patch is used to provide helper functions needed for nvdimm daemon.
> These util functions can be used by other features as well in the future.
>
> Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
> ---
>  nvdimmd/util.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  nvdimmd/util.h | 33 ++++++++++++++++++++++++
>  2 files changed, 113 insertions(+)
>  create mode 100644 nvdimmd/util.c
>  create mode 100644 nvdimmd/util.h
>
> diff --git a/nvdimmd/util.c b/nvdimmd/util.c
> new file mode 100644
> index 0000000..ef6819e
> --- /dev/null
> +++ b/nvdimmd/util.c
> @@ -0,0 +1,80 @@
> +/*
> + * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU Lesser General Public License,
> + * version 2.1, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT ANY
> + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
> + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
> + * more details.
> + */
> +
> +#include <stdlib.h>
> +#include <string.h>
> +#include <time.h>
> +#include "util.h"
> +
> +void logrotate(char *file)
> +{
> +       time_t c_time;
> +       char buf[4096], tstamp[32];
> +
> +       c_time = time(NULL);
> +       strftime(tstamp, sizeof(tstamp), ".%Y%m%d%H%M%S", localtime(&c_time));
> +       strcpy(buf, file);
> +       strcat(buf, tstamp);
> +       rename(file, buf);
> +}

Why does the monitor need to rotate logs? This should be the
responsibility of whatever is consuming  the nvdimmd events.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 4/7] ndctl: nvdimmd: add body file of nvdimm daemon
  2017-11-14  7:47 ` [RFC PATCH v2 4/7] ndctl: nvdimmd: add body file of nvdimm daemon QI Fuli
@ 2017-11-20 21:31   ` Dan Williams
  0 siblings, 0 replies; 20+ messages in thread
From: Dan Williams @ 2017-11-20 21:31 UTC (permalink / raw)
  To: QI Fuli; +Cc: linux-nvdimm

On Mon, Nov 13, 2017 at 11:47 PM, QI Fuli <qi.fuli@jp.fujitsu.com> wrote:
> This patch adds the body file of nvdimm daemon and compiles nvdimmd
> with automake.
>
> Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
> ---
>  Makefile.am         |   2 +-
>  configure.ac        |   1 +
>  nvdimmd/Makefile.am |  19 +++++++++
>  nvdimmd/nvdimmd.c   | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 133 insertions(+), 1 deletion(-)
>  create mode 100644 nvdimmd/Makefile.am
>  create mode 100644 nvdimmd/nvdimmd.c
>
> diff --git a/Makefile.am b/Makefile.am
> index b538b1f..ff91439 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -1,7 +1,7 @@
>  include Makefile.am.in
>
>  ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
> -SUBDIRS = . daxctl/lib ndctl/lib ndctl daxctl
> +SUBDIRS = . daxctl/lib ndctl/lib ndctl daxctl nvdimmd
>  if ENABLE_DOCS
>  SUBDIRS += Documentation/ndctl Documentation/daxctl
>  endif
> diff --git a/configure.ac b/configure.ac
> index 5b10381..3ce71e3 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -274,6 +274,7 @@ AC_CONFIG_FILES([
>          daxctl/lib/Makefile
>          ndctl/lib/Makefile
>          ndctl/Makefile
> +       nvdimmd/Makefile
>          daxctl/Makefile
>          test/Makefile
>          Documentation/ndctl/Makefile
> diff --git a/nvdimmd/Makefile.am b/nvdimmd/Makefile.am
> new file mode 100644
> index 0000000..9883edd
> --- /dev/null
> +++ b/nvdimmd/Makefile.am
> @@ -0,0 +1,19 @@
> +include $(top_srcdir)/Makefile.am.in
> +
> +bin_PROGRAMS = nvdimmd
> +
> +nvdimmd_SOURCES =\
> +               nvdimmd.c \
> +               libnvdimmd.c \
> +               util.c \
> +               ../util/log.c \
> +               ../util/json.c \
> +               ../ndctl/util/json-smart.c
> +
> +nvdimmd_LDADD = ../ndctl/lib/libndctl.la \
> +               ../daxctl/lib/libdaxctl.la \
> +               ../libutil.a \
> +               $(KMOD_LIBS) \
> +               $(JSON_LIBS) \
> +               $(UUID_LIBS) \
> +               $(UDEV_LIBS)
> diff --git a/nvdimmd/nvdimmd.c b/nvdimmd/nvdimmd.c
> new file mode 100644
> index 0000000..f451751
> --- /dev/null
> +++ b/nvdimmd/nvdimmd.c
> @@ -0,0 +1,112 @@
> +/*
> + * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU Lesser General Public License,
> + * version 2.1, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT ANY
> + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
> + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
> + * more details.
> + */
> +
> +/*
> + * Nvdimm daemon is used to monitor the features of over threshold events.
> + * It automatically searches and monitors all of the dimms which support smart
> + * threshold. When an over threshold event fires, it will write a notification
> + * into the system log.
> + */
> +
> +#include <stdlib.h>
> +#include <unistd.h>
> +#include <string.h>
> +#include <signal.h>
> +#include <sys/stat.h>
> +#include <syslog.h>
> +#include <errno.h>
> +#include <ndctl/lib/private.h>
> +#include "libnvdimmd.h"
> +
> +static int wait_threshold_notify(struct ndctl_ctx *ctx)
> +{
> +       int rc, maxfd, cnt_dimm;
> +       struct threshold_dimm *t_dimm;
> +
> +       t_dimm = calloc(NUM_MAX_DIMM, sizeof(struct threshold_dimm));
> +       if (!t_dimm) {
> +               err(ctx, "t_dimm memory not allocated");
> +               goto out;
> +       }
> +
> +       fd_set fds;
> +       FD_ZERO(&fds);
> +
> +       cnt_dimm = get_threshold_dimm(ctx, t_dimm, &fds, &maxfd);
> +       if (cnt_dimm == 0) {
> +               err(ctx, "no dimm supports over threshold notification\n");
> +               goto out;
> +       }
> +
> +       rc = select(maxfd + 1, NULL, NULL, &fds, NULL);
> +       if (rc < 1) {
> +               if (rc == 0)
> +                       err(ctx, "select unexpected timeout\n");
> +               else
> +                       err(ctx, "select %s\n", strerror(errno));
> +               goto out;
> +       }
> +
> +       log_notify(ctx, t_dimm, cnt_dimm, fds, rc);
> +
> +       free(t_dimm);
> +       return 0;
> +
> +out:
> +       return 1;
> +}
> +
> +static void nvdimmd_log_init(struct ndctl_ctx *ctx, int priority,
> +                               const char *owner, const char *log_env)
> +{
> +       log_init(&ctx->ctx, owner, log_env);
> +       ndctl_set_log_priority(ctx, priority);
> +       if (strcmp(nvdimmd_cf->logfile, "syslog") == 0)
> +               ndctl_set_log_fn(ctx, log_syslog);
> +       else
> +               ndctl_set_log_fn(ctx, log_file);
> +}
> +
> +int main(void)
> +{
> +       if (daemon(0, 0) != 0) {
> +               syslog(LOG_ERR, "nvdimmd error: daemon start failed\n");
> +               exit(EXIT_FAILURE);
> +       }
> +       struct ndctl_ctx *ctx;
> +       int rc, ret = 0;
> +       const char *conf_path = "/etc/nvdimmd/nvdimmd.conf";
> +
> +       syslog(LOG_INFO, "nvdimmd: started\n");
> +
> +       if (get_nvdimmd_conf(conf_path) != 0) {
> +               syslog(LOG_ERR, "nvdimmd.conf error \n");
> +               goto out;
> +       }
> +
> +       while (ret == 0) {
> +               rc = ndctl_new(&ctx);
> +               if (rc)
> +                       goto out;
> +
> +               nvdimmd_log_init(ctx, LOG_NOTICE, "nvdimmd", "NVDIMMD_LOG");
> +               ret = wait_threshold_notify(ctx);
> +               ndctl_unref(ctx);

We shouldn't need to setup and teardown the ndctl_ctx after each wake up.

In general I think we need to start with the end result of what data
and events do want to emit and have in the logs and then work
backwards from there. I think the first step is define a set of event
names and event record details.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event
  2017-11-20 16:13     ` Dan Williams
@ 2017-11-21  1:59       ` Qi, Fuli
  2017-12-07  9:58         ` Qi, Fuli
  0 siblings, 1 reply; 20+ messages in thread
From: Qi, Fuli @ 2017-11-21  1:59 UTC (permalink / raw)
  To: Dan Williams, Yasunori Goto; +Cc: linux-nvdimm



On 2017/11/21 1:13, Dan Williams wrote:
> On Mon, Nov 20, 2017 at 2:07 AM, Yasunori Goto <y-goto@jp.fujitsu.com> wrote:
>>> On Mon, Nov 13, 2017 at 11:46 PM, QI Fuli <qi.fuli@jp.fujitsu.com> wrote:
>>>> Hi, here is my second version of nvdimm daemon, It would be appreciated
>>>> if you could check it.
>>>>
>>>> Change log since v1:
>>>>   - Adding a config file(/etc/nvdimmd/nvdimmd.conf)
>>>>   - Using struct log_ctx instead of syslog()
>>>>     - Using log_syslog() to save the notify messages to syslog
>>>>     - Using log_file() to save the notify messages to special file
>>>>   - Adding LOG_NOTICE level into log_priority
>>>>   - Using automake instead of Makefile
>>>>   - Adding a new util file(nvdimmd/util.c) including helper functions needed
>>>>     for nvdimm daemon.
>>>>   - Adding nvdimmd_test program
>>>>
>>>> ---
>>>> This is a patch set of nvdimmd, a tiny daemon to monitor the features of over
>>>> threshold events. When an over thershold event fires, nvdimmd will output the
>>>> notification including dimm health status to syslog or a special file to
>>>> users' configuration. Users can choose the output format to be structured json
>>>> or text.
>>>>
>>>> Here are out put samples.
>>>> - json format:
>>>> 2017/11/10 11:15:03 [28065] log_notify: nvdimm dimm over threshold notify
>>>> {
>>>>    "dev":"nmem1",
>>>>    "id":"cdab-0a-07e0-feffffff",
>>>>    "handle":1,
>>>>    "phys_id":1,
>>>>    "health":{
>>>>      "health_state":"non-critical",
>>>>      "temperature_celsius":23,
>>>>      "spares_percentage":75,
>>>>      "alarm_temperature":true,
>>>>      "alarm_spares":true,
>>>>      "temperature_threshold":40,
>>>>      "spares_threshold":5,
>>>>      "life_used_percentage":5,
>>>>      "shutdown_state":"clean"
>>>>    }
>>>> }
>>>> - text format:
>>>> 2017/11/10 16:21:53 [12479] log_notify: nvdimm dimm over threshold notify
>>>> dev: nmem1
>>>>   health_state: non-critical
>>>>   spares_percentage: 75
>>> Are these formats that services like Scribe and Fluent can consume?
>>> I'd like to see a sample hook up to those applications.
>>>
>>> I'm also wondering that since this will be a long running service that
>>> may gain more functionality over time, if we should write it in a
>>> language that does not have the security sharp edges of C.
>>>
>>> I've been looking for an excuse to use the Go language on a project,
>>> and this seems a good opportunity.
>> Hmmmmm, This seems to be big change of direction of nvdimmd.
>>
>> Certainly, go-lang is good and interesting language in my impression.
>> But, if nvdimmd is re-created by go-lang, I suppose nvdimmd will need to
>> discard many functions of ndctl libraries, and need to re-create them by golang.
>>
>> (Though golang may be able to link C-lang libraries, then its security
>>   will be simlar with C-lang level, not go-lang level, I think.)
>>
>> Do you intent that we should re-create many functions for golang?
>>
>> In addition, do you include source code of go-lang nvdimmd in ndctl source code?
> Yes, but let's continue with C for now, I took a look and the impact
> is not quite as straightforward as I thought.
>
> The next step is to build a demonstration of Scribe or Fluentd
> consuming nvdimmd events.
>
Ok, I will make a sample hook up to Fluentd.

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions
  2017-11-20 21:19   ` Dan Williams
@ 2017-12-06  7:14     ` Qi, Fuli
  2017-12-06 16:53       ` Dan Williams
  0 siblings, 1 reply; 20+ messages in thread
From: Qi, Fuli @ 2017-12-06  7:14 UTC (permalink / raw)
  To: Dan Williams; +Cc: linux-nvdimm

On 2017/11/21 6:19, Dan Williams wrote:
> On Mon, Nov 13, 2017 at 11:46 PM, QI Fuli <qi.fuli@jp.fujitsu.com> wrote:
>> This patch is used to provide helper functions needed for nvdimm daemon.
>> These util functions can be used by other features as well in the future.
>>
>> Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
>> ---
>>   nvdimmd/util.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   nvdimmd/util.h | 33 ++++++++++++++++++++++++
>>   2 files changed, 113 insertions(+)
>>   create mode 100644 nvdimmd/util.c
>>   create mode 100644 nvdimmd/util.h
>>
>> diff --git a/nvdimmd/util.c b/nvdimmd/util.c
>> new file mode 100644
>> index 0000000..ef6819e
>> --- /dev/null
>> +++ b/nvdimmd/util.c
>> @@ -0,0 +1,80 @@
>> +/*
>> + * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved.
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms and conditions of the GNU Lesser General Public License,
>> + * version 2.1, as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope it will be useful, but WITHOUT ANY
>> + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
>> + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
>> + * more details.
>> + */
>> +
>> +#include <stdlib.h>
>> +#include <string.h>
>> +#include <time.h>
>> +#include "util.h"
>> +
>> +void logrotate(char *file)
>> +{
>> +       time_t c_time;
>> +       char buf[4096], tstamp[32];
>> +
>> +       c_time = time(NULL);
>> +       strftime(tstamp, sizeof(tstamp), ".%Y%m%d%H%M%S", localtime(&c_time));
>> +       strcpy(buf, file);
>> +       strcat(buf, tstamp);
>> +       rename(file, buf);
>> +}
> Why does the monitor need to rotate logs? This should be the
> responsibility of whatever is consuming  the nvdimmd events.
When I wrote it, I thought that users can rotate nvdimmd logs without 
using other tools.
If you think it is not necessary, I will remove it in next version.

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions
  2017-12-06  7:14     ` Qi, Fuli
@ 2017-12-06 16:53       ` Dan Williams
  2017-12-07  9:55         ` Qi, Fuli
  0 siblings, 1 reply; 20+ messages in thread
From: Dan Williams @ 2017-12-06 16:53 UTC (permalink / raw)
  To: Qi, Fuli; +Cc: linux-nvdimm

On Tue, Dec 5, 2017 at 11:14 PM, Qi, Fuli <qi.fuli@jp.fujitsu.com> wrote:
> On 2017/11/21 6:19, Dan Williams wrote:
>>
>> On Mon, Nov 13, 2017 at 11:46 PM, QI Fuli <qi.fuli@jp.fujitsu.com> wrote:
>>>
>>> This patch is used to provide helper functions needed for nvdimm daemon.
>>> These util functions can be used by other features as well in the future.
>>>
>>> Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
>>> ---
>>>   nvdimmd/util.c | 80
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>   nvdimmd/util.h | 33 ++++++++++++++++++++++++
>>>   2 files changed, 113 insertions(+)
>>>   create mode 100644 nvdimmd/util.c
>>>   create mode 100644 nvdimmd/util.h
>>>
>>> diff --git a/nvdimmd/util.c b/nvdimmd/util.c
>>> new file mode 100644
>>> index 0000000..ef6819e
>>> --- /dev/null
>>> +++ b/nvdimmd/util.c
>>> @@ -0,0 +1,80 @@
>>> +/*
>>> + * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved.
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> it
>>> + * under the terms and conditions of the GNU Lesser General Public
>>> License,
>>> + * version 2.1, as published by the Free Software Foundation.
>>> + *
>>> + * This program is distributed in the hope it will be useful, but
>>> WITHOUT ANY
>>> + * WARRANTY; without even the implied warranty of MERCHANTABILITY or
>>> FITNESS
>>> + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
>>> for
>>> + * more details.
>>> + */
>>> +
>>> +#include <stdlib.h>
>>> +#include <string.h>
>>> +#include <time.h>
>>> +#include "util.h"
>>> +
>>> +void logrotate(char *file)
>>> +{
>>> +       time_t c_time;
>>> +       char buf[4096], tstamp[32];
>>> +
>>> +       c_time = time(NULL);
>>> +       strftime(tstamp, sizeof(tstamp), ".%Y%m%d%H%M%S",
>>> localtime(&c_time));
>>> +       strcpy(buf, file);
>>> +       strcat(buf, tstamp);
>>> +       rename(file, buf);
>>> +}
>>
>> Why does the monitor need to rotate logs? This should be the
>> responsibility of whatever is consuming  the nvdimmd events.
>
> When I wrote it, I thought that users can rotate nvdimmd logs without using
> other tools.
> If you think it is not necessary, I will remove it in next version.
>

In general we should let other system components handle the mechanics
they are responsible to handle. In this case as long as nvdimmd
reports the log message to the systemd-journal or the platform's
syslog facility then it has done its job and the log machinery is
responsible for rotation.

I've also been giving more thought about the command line interface
for the monitor. I think it should reuse the "ndctl list"
infrastructure for selecting and filtering devices so the user can
launch monitors like this:

        ndctl monitor --dimms --namespace=namespace0.0 --action=page_admin.sh
        ndctl monitor -BDRN --action=log

Where those commands would  run the 'page admin' script if any DIMM
event happens on any DIMM associated with namespace0.0, and log
everything else" that happens on any other device. We likely also need
"--event=" to control the events to filter, and a --list-events option
to enumerate all the possible events.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions
  2017-12-06 16:53       ` Dan Williams
@ 2017-12-07  9:55         ` Qi, Fuli
  2017-12-09 23:54           ` Dan Williams
  0 siblings, 1 reply; 20+ messages in thread
From: Qi, Fuli @ 2017-12-07  9:55 UTC (permalink / raw)
  To: Dan Williams; +Cc: linux-nvdimm


>>>> +       rename(file, buf);
>>>> +}
>>> Why does the monitor need to rotate logs? This should be the
>>> responsibility of whatever is consuming  the nvdimmd events.
>> When I wrote it, I thought that users can rotate nvdimmd logs without using
>> other tools.
>> If you think it is not necessary, I will remove it in next version.
>>
> In general we should let other system components handle the mechanics
> they are responsible to handle. In this case as long as nvdimmd
> reports the log message to the systemd-journal or the platform's
> syslog facility then it has done its job and the log machinery is
> responsible for rotation.
>
> I've also been giving more thought about the command line interface
> for the monitor. I think it should reuse the "ndctl list"
> infrastructure for selecting and filtering devices so the user can
> launch monitors like this:
>
>          ndctl monitor --dimms --namespace=namespace0.0 --action=page_admin.sh
>          ndctl monitor -BDRN --action=log
>
> Where those commands would  run the 'page admin' script if any DIMM
> event happens on any DIMM associated with namespace0.0, and log
> everything else" that happens on any other device. We likely also need
> "--event=" to control the events to filter, and a --list-events option
> to enumerate all the possible events.
>
>
My original plan was user launches the nvdimm monitor services with 
systemctl command
like: $systemctl start nvdimmd, then nvdimmd reads a config file
to select and filter devices or any other settings.

In my first impression, your idea, which is by command line options,
seems to be attractive. But I'm not sure yet.

So, I have some questions.

Q1) Which is better interface config file or command option?

     For example, please consider a use-case which user execute
     plural nvdimm daemons to monitor plural areas.

    - config file
      To make plural daemons, user need to prepare different name of
      config files.
      But, user can manage each daemon with the name of files.

    - ndctl
      It is easy to make environment plural nvdimm daemons.
      However, I could not find the way for users to manage them.
      How to specify each daemon to stop/restart them?

Q2) What filter option is necessary?
    a) filter by dimm
    b) filter by bus
    c) filter by region
    d) filter by namespace
    e) filter by device name
    f) filter by event
    g) all (default)

   a) is already implemented because it is easy.
      (However, to be honest, I don't have any concrete use-case.
       Do you have any idea?)
   b) is same with a). I don't know any use-case about bus-filter.
      (any use-case?)
   c), d) or e) will be probably necessary.
     Probably, I think it is useful to notify each applications
     which uses each regions/namespace.
     However, I feel I need more time to investigate how to implement it 
yet.
   f) I don't have idea what kind of event should be filtered.
         Currently, I can think the followings
         - spare threshold event
         - temperature threshold event
     Would you mind elaborating a bit more?
   g) is essential of cause.

BTW, Currently, I would like to merge a), b), e), f) at this time as a 
first version
of NVDIMM daemon. and make c) and d) at next version.
About actions, I think more research and discussion is needed,
so I will only implement output to log in first version.

How do you think?
Thanks

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event
  2017-11-21  1:59       ` Qi, Fuli
@ 2017-12-07  9:58         ` Qi, Fuli
  2017-12-07 19:34           ` Dan Williams
  0 siblings, 1 reply; 20+ messages in thread
From: Qi, Fuli @ 2017-12-07  9:58 UTC (permalink / raw)
  To: Dan Williams; +Cc: linux-nvdimm



On 2017/11/21 10:59, Qi, Fuli wrote:
>
>
> On 2017/11/21 1:13, Dan Williams wrote:
>> On Mon, Nov 20, 2017 at 2:07 AM, Yasunori Goto 
>> <y-goto@jp.fujitsu.com> wrote:
>>>> On Mon, Nov 13, 2017 at 11:46 PM, QI Fuli <qi.fuli@jp.fujitsu.com> 
>>>> wrote:
>>>>> Hi, here is my second version of nvdimm daemon, It would be 
>>>>> appreciated
>>>>> if you could check it.
>>>>>
>>>>> Change log since v1:
>>>>>   - Adding a config file(/etc/nvdimmd/nvdimmd.conf)
>>>>>   - Using struct log_ctx instead of syslog()
>>>>>     - Using log_syslog() to save the notify messages to syslog
>>>>>     - Using log_file() to save the notify messages to special file
>>>>>   - Adding LOG_NOTICE level into log_priority
>>>>>   - Using automake instead of Makefile
>>>>>   - Adding a new util file(nvdimmd/util.c) including helper 
>>>>> functions needed
>>>>>     for nvdimm daemon.
>>>>>   - Adding nvdimmd_test program
>>>>>
>>>>> ---
>>>>> This is a patch set of nvdimmd, a tiny daemon to monitor the 
>>>>> features of over
>>>>> threshold events. When an over thershold event fires, nvdimmd will 
>>>>> output the
>>>>> notification including dimm health status to syslog or a special 
>>>>> file to
>>>>> users' configuration. Users can choose the output format to be 
>>>>> structured json
>>>>> or text.
>>>>>
>>>>> Here are out put samples.
>>>>> - json format:
>>>>> 2017/11/10 11:15:03 [28065] log_notify: nvdimm dimm over threshold 
>>>>> notify
>>>>> {
>>>>>    "dev":"nmem1",
>>>>>    "id":"cdab-0a-07e0-feffffff",
>>>>>    "handle":1,
>>>>>    "phys_id":1,
>>>>>    "health":{
>>>>>      "health_state":"non-critical",
>>>>>      "temperature_celsius":23,
>>>>>      "spares_percentage":75,
>>>>>      "alarm_temperature":true,
>>>>>      "alarm_spares":true,
>>>>>      "temperature_threshold":40,
>>>>>      "spares_threshold":5,
>>>>>      "life_used_percentage":5,
>>>>>      "shutdown_state":"clean"
>>>>>    }
>>>>> }
>>>>> - text format:
>>>>> 2017/11/10 16:21:53 [12479] log_notify: nvdimm dimm over threshold 
>>>>> notify
>>>>> dev: nmem1
>>>>>   health_state: non-critical
>>>>>   spares_percentage: 75
>>>> Are these formats that services like Scribe and Fluent can consume?
>>>> I'd like to see a sample hook up to those applications.
>>>>
>>>> I'm also wondering that since this will be a long running service that
>>>> may gain more functionality over time, if we should write it in a
>>>> language that does not have the security sharp edges of C.
>>>>
>>>> I've been looking for an excuse to use the Go language on a project,
>>>> and this seems a good opportunity.
>>> Hmmmmm, This seems to be big change of direction of nvdimmd.
>>>
>>> Certainly, go-lang is good and interesting language in my impression.
>>> But, if nvdimmd is re-created by go-lang, I suppose nvdimmd will 
>>> need to
>>> discard many functions of ndctl libraries, and need to re-create 
>>> them by golang.
>>>
>>> (Though golang may be able to link C-lang libraries, then its security
>>>   will be simlar with C-lang level, not go-lang level, I think.)
>>>
>>> Do you intent that we should re-create many functions for golang?
>>>
>>> In addition, do you include source code of go-lang nvdimmd in ndctl 
>>> source code?
>> Yes, but let's continue with C for now, I took a look and the impact
>> is not quite as straightforward as I thought.
>>
>> The next step is to build a demonstration of Scribe or Fluentd
>> consuming nvdimmd events.
>>
> Ok, I will make a sample hook up to Fluentd.
>
>
I tried to hook up the current json format output to Fluentd,
Fluentd parsed each line in the output as a new event.
The current json format output cannot be consumed by Fluentd without
any plugins. This is undesired.
So I changed the multiline json format output to one-line like the following
sample, then Fluentd parsed it well.

{"datetime":"2017/11/28 
11:00:12","pid":7013,"dev":"nmem1","health":{"health_state":"non-critical","temperature_celsius":23,"spares_percentage":75","life_used_percentage":5,"shutdown_state":"clean"}}

I think one-line output will get consumed more easily by other data collect
services besides Fluentd. All the output items should be placed in json 
block,
such as datetime, eventid.

So I would like to change current multi-line json format output to one line
and move all items into json block.

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event
  2017-12-07  9:58         ` Qi, Fuli
@ 2017-12-07 19:34           ` Dan Williams
  0 siblings, 0 replies; 20+ messages in thread
From: Dan Williams @ 2017-12-07 19:34 UTC (permalink / raw)
  To: Qi, Fuli; +Cc: linux-nvdimm

On Thu, Dec 7, 2017 at 1:58 AM, Qi, Fuli <qi.fuli@jp.fujitsu.com> wrote:
[..]
>> Ok, I will make a sample hook up to Fluentd.
>>
>>
> I tried to hook up the current json format output to Fluentd,
> Fluentd parsed each line in the output as a new event.
> The current json format output cannot be consumed by Fluentd without
> any plugins. This is undesired.
> So I changed the multiline json format output to one-line like the following
> sample, then Fluentd parsed it well.
>
> {"datetime":"2017/11/28 11:00:12","pid":7013,"dev":"nmem1","health":{"health_state":"non-critical","temperature_celsius":23,"spares_percentage":75","life_used_percentage":5,"shutdown_state":"clean"}}
>
> I think one-line output will get consumed more easily by other data collect
> services besides Fluentd. All the output items should be placed in json block,
> such as datetime, eventid.
>
> So I would like to change current multi-line json format output to one line
> and move all items into json block.
>

This is just a small matter of using the JSON_C_TO_STRING_PLAIN flag
instead of JSON_C_TO_STRING_PRETTY when emitting json
(json_object_to_json_string_ext()) for Fluentd or another service to
consume.

Also, when creating a json record for Fluentd I think the standard
record that ndctl list reports should be wrapped as a sub-object i.e:

{
  "dev":"nmem3",
  "id":"cdab-0a-07e0-feffffff",
  "handle":1,
  "phys_id":1,
  "health":{
    "health_state":"non-critical",
    "temperature_celsius":23,
    "spares_percentage":75,
    "alarm_temperature":true,
    "alarm_spares":true,
    "temperature_threshold":80.125,
    "spares_threshold":128,
    "life_used_percentage":5,
    "shutdown_state":"clean"
  }
}

...becomes:

{
  "timestamp":"YYYY/MM/DD HH:mm:ss",
  "pid":1234,
  {
    "dev":"nmem3",
    "id":"cdab-0a-07e0-feffffff",
    "handle":1,
    "phys_id":1,
    "health":{
      "health_state":"non-critical",
      "temperature_celsius":23,
      "spares_percentage":75,
      "alarm_temperature":true,
      "alarm_spares":true,
      "temperature_threshold":80.125,
      "spares_threshold":128,
      "life_used_percentage":5,
      "shutdown_state":"clean"
    }
  }
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions
  2017-12-07  9:55         ` Qi, Fuli
@ 2017-12-09 23:54           ` Dan Williams
  0 siblings, 0 replies; 20+ messages in thread
From: Dan Williams @ 2017-12-09 23:54 UTC (permalink / raw)
  To: Qi, Fuli; +Cc: linux-nvdimm

On Thu, Dec 7, 2017 at 1:55 AM, Qi, Fuli <qi.fuli@jp.fujitsu.com> wrote:
>
>>>>> +       rename(file, buf);
>>>>> +}
>>>>
>>>> Why does the monitor need to rotate logs? This should be the
>>>> responsibility of whatever is consuming  the nvdimmd events.
>>>
>>> When I wrote it, I thought that users can rotate nvdimmd logs without
>>> using
>>> other tools.
>>> If you think it is not necessary, I will remove it in next version.
>>>
>> In general we should let other system components handle the mechanics
>> they are responsible to handle. In this case as long as nvdimmd
>> reports the log message to the systemd-journal or the platform's
>> syslog facility then it has done its job and the log machinery is
>> responsible for rotation.
>>
>> I've also been giving more thought about the command line interface
>> for the monitor. I think it should reuse the "ndctl list"
>> infrastructure for selecting and filtering devices so the user can
>> launch monitors like this:
>>
>>          ndctl monitor --dimms --namespace=namespace0.0
>> --action=page_admin.sh
>>          ndctl monitor -BDRN --action=log
>>
>> Where those commands would  run the 'page admin' script if any DIMM
>> event happens on any DIMM associated with namespace0.0, and log
>> everything else" that happens on any other device. We likely also need
>> "--event=" to control the events to filter, and a --list-events option
>> to enumerate all the possible events.
>>
>>
> My original plan was user launches the nvdimm monitor services with
> systemctl command
> like: $systemctl start nvdimmd, then nvdimmd reads a config file
> to select and filter devices or any other settings.
>
> In my first impression, your idea, which is by command line options,
> seems to be attractive. But I'm not sure yet.
>
> So, I have some questions.
>
> Q1) Which is better interface config file or command option?
>
>     For example, please consider a use-case which user execute
>     plural nvdimm daemons to monitor plural areas.
>
>    - config file
>      To make plural daemons, user need to prepare different name of
>      config files.
>      But, user can manage each daemon with the name of files.
>
>    - ndctl
>      It is easy to make environment plural nvdimm daemons.
>      However, I could not find the way for users to manage them.
>      How to specify each daemon to stop/restart them?

Every option that can be specified via a configuration file should
also be enabled via a command line operation, see dnsmasq as an
example.

The systemd service file can launch a single instance to use a default
configuration file, but that's just a default that the user is free to
ignore and they can always launch monitor instances by hand for
testing or custom monitoring purposes.

> Q2) What filter option is necessary?
>    a) filter by dimm
>    b) filter by bus
>    c) filter by region
>    d) filter by namespace
>    e) filter by device name
>    f) filter by event
>    g) all (default)
>
>   a) is already implemented because it is easy.
>      (However, to be honest, I don't have any concrete use-case.
>       Do you have any idea?)
>   b) is same with a). I don't know any use-case about bus-filter.
>      (any use-case?)
>   c), d) or e) will be probably necessary.
>     Probably, I think it is useful to notify each applications
>     which uses each regions/namespace.
>     However, I feel I need more time to investigate how to implement it yet.

You don't need to implement it. All of this filtering is already
present in the 'ndctl list' command. We just need to refactor the code
that walks and filters the device tree to be re-used by the monitor
implementation.

>   f) I don't have idea what kind of event should be filtered.
>         Currently, I can think the followings
>         - spare threshold event
>         - temperature threshold event
>     Would you mind elaborating a bit more?

Every event that we can monitor needs a name and a corresponding event
record format in json. The event list I can think of is:

dimm-spares-remaining
dimm-media-temperature
dimm-controller-temperature
dimm-health-state
dimm-unclean-shutdown
dimm-detected
namespace-media-error
namespace-detected
region-media-error
region-detected
bus-media-error
bus-address-range-scrub-complete
bus-detected

Any others?
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-12-09 23:49 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-14  7:46 [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event QI Fuli
2017-11-14  7:46 ` [RFC PATCH v2 1/7] ndctl: nvdimmd: add LOG_NOTICE level into log_priority QI Fuli
2017-11-14  7:46 ` [RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions QI Fuli
2017-11-20 21:19   ` Dan Williams
2017-12-06  7:14     ` Qi, Fuli
2017-12-06 16:53       ` Dan Williams
2017-12-07  9:55         ` Qi, Fuli
2017-12-09 23:54           ` Dan Williams
2017-11-14  7:47 ` [RFC PATCH v2 3/7] ndctl: nvdimmd: add nvdimmd necessary functions QI Fuli
2017-11-14  7:47 ` [RFC PATCH v2 4/7] ndctl: nvdimmd: add body file of nvdimm daemon QI Fuli
2017-11-20 21:31   ` Dan Williams
2017-11-14  7:47 ` [RFC PATCH v2 5/7] ndctl: nvdimmd: add nvdimmd config file QI Fuli
2017-11-14  7:47 ` [RFC PATCH v2 6/7] ndctl: nvdimmd: add the unit file of systemd for nvdimmd service QI Fuli
2017-11-14  7:47 ` [RFC PATCH v2 7/7] ndctl: nvdimmd: add a temporary test for nvdimm daemon QI Fuli
2017-11-20  6:33 ` [RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event Dan Williams
2017-11-20 10:07   ` Yasunori Goto
2017-11-20 16:13     ` Dan Williams
2017-11-21  1:59       ` Qi, Fuli
2017-12-07  9:58         ` Qi, Fuli
2017-12-07 19:34           ` Dan Williams

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.