ndctl, monitor: add ndctl monitor daemon
v9 cover ndctl, monitor: add ndctl monitor daemon
This is the v9 patch for ndctl monitor, a tiny daemon to monitor the smart events of nvdimm DIMMs. Since NVDIMM does not have a feature like mirroring, if it breaks down, the data will be impossible to restore. Ndctl monitor daemon will catch the smart events notify from firmware and outputs notification to logfile, therefore users can replace NVDIMM before it is completely broken.
---
Change log since v8:
- Adding ndctl_cmd_smart_get_event_flags() api
- Adding monitor_filter_arg to the union in util_filter_ctx
- Removing is_dir()
- Replacing malloc + vsprintf with vasprintf() in log_file() and log_syslog()
- Adding parse_monitor_event()
- Refactoring util_dimm_event_filter()
- Adding event_flags to monitor
- Refactoring dimm_event_to_json()
- Adding check_dimm_supported_threshold_alarms()
- Fixing fail token
Change log since v7:
- Replacing logreport() with log_file() and log_syslog()
- Refactoring read_config_file()
- Replacing set_confile() with parse_config()
- Fixing the ndctl/ndct.conf file
Change log since v6:
- Changing License to GPL-2.0
- Adding event object to output notification
- Adding [--dimm-event] option to filter notification by event type
- Rewriting read_config_file()
- Replacing monitor_dimm_event() with monitor_event()
- Renaming some variables
Change log since v5:
- Fixing systemd unit file cannot be installed bug
- Adding license to ./util/abspath.c
Change log since v4:
- Adding OPTION_FILENAME to make sure filename is correct
- Adding configuration file
- Adding [--config-file] option to override the default configuration
- Making some options support multiple space-seperated arguments
- Making systemctl enable ndctl-monitor.service command work
- Making systemctl restart ndctl-monitor.service command work
- Making the directory of systemd unit file to be configurable
- Changing log_file() and log_syslog() to logreport()
- Changing date format in notification to nanoseconds since epoch
- Changing select() to epoll()
- Adding filter_bus() and filter_region()
Change log since v3:
- Removing create-monitor, show-monitor, list-monitor, destroy-monitor
- Adding [--daemon] option to run ndctl monitor as a daemon
- Using systemd to manage ndctl monitor daemon
- Replacing filter_monitor_dimm() with filter_dimm()
Change log since v2:
- Changing the interface of daemon to the ndctl command line
- Changing the name of daemon form "nvdimmd" to "monitor"
- Removing the config file, unit_file, nvdimmd dir
- Removing nvdimmd_test program
- Adding ndctl/monitor.c
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 to 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
QI Fuli (3):
ndctl, monitor: add ndctl monitor
ndctl, monitor: add main ndctl monitor configuration file ndctl, monitor: add the unit file of systemd for ndctl-monitor service
autogen.sh | 3 +- builtin.h | 1 + configure.ac | 22 ++ ndctl/Makefile.am | 12 +- ndctl/lib/libndctl.sym | 1 + ndctl/lib/smart.c | 17 + ndctl/libndctl.h | 6 + ndctl/monitor.c | 646 ++++++++++++++++++++++++++++++++++++ ndctl/monitor.conf | 41 +++ ndctl/ndctl-monitor.service | 7 + ndctl/ndctl.c | 1 + util/filter.h | 9 + 12 files changed, 764 insertions(+), 2 deletions(-) create mode 100644 ndctl/monitor.c create mode 100644 ndctl/monitor.conf create mode 100644 ndctl/ndctl-monitor.service
Signature · 7 lines
2.18.0 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v9 1/3 ndctl, monitor: add ndctl monitor
Ndctl monitor is used for monitoring the smart events of nvdimm DIMMs. When a smart event fires, monitor will output the notifications which include dimm health status and evnet informations to syslog or a logfile by setting [--logfile] option. The notifications follow json format and can be consumed by log collectors like Fluentd.
The objects to monitor can be selected by setting [--dimm] [--region] [--namespace] [--bus] options and the event type can be filtered by setting [--dimm-event] option. These options support multiple space-separated arguments.
Ndctl monitor can be forked as a daemon by using [--daemon] option, such as:
# ndctl monitor --daemon --logfile /var/log/ndctl/monitor.log
--- builtin.h | 1 + ndctl/Makefile.am | 3 +- ndctl/lib/libndctl.sym | 1 + ndctl/lib/smart.c | 17 ++ ndctl/libndctl.h | 6 + ndctl/monitor.c | 531 +++++++++++++++++++++++++++++++++++++++++ ndctl/ndctl.c | 1 + util/filter.h | 9 + 8 files changed, 568 insertions(+), 1 deletion(-) create mode 100644 ndctl/monitor.c
builtin.h +1 -0
@@ -39,6 +39,7 @@ int cmd_inject_error(int argc, const char **argv, void *ctx);int cmd_wait_scrub (int argc,const char **argv,void *ctx);int cmd_start_scrub (int argc,const char **argv,void *ctx);int cmd_list (int argc,const char **argv,void *ctx); +int cmd_monitor (int argc,const char **argv,void *ctx);#ifdef ENABLE_TEST int cmd_test (int argc,const char **argv,void *ctx);#endif
ndctl/Makefile.am +2 -1
@@ -16,7 +16,8 @@ ndctl_SOURCES = ndctl.c \ util/json-smart.c \ util/json-firmware.c \ inject-error.c \ - inject-smart.c + inject-smart.c \ + monitor.c if ENABLE_DESTRUCTIVE ndctl_SOURCES += ../test/blk_namespaces.c \
ndctl/lib/libndctl.sym +1 -0
@@ -366,4 +366,5 @@ global: ndctl_namespace_inject_error2; ndctl_namespace_uninject_error2; ndctl_cmd_ars_stat_get_flag_overflow; + ndctl_cmd_smart_get_event_flags; } LIBNDCTL_15;
ndctl/lib/smart.c +17 -0
@@ -101,6 +101,23 @@ NDCTL_EXPORT unsigned int ndctl_cmd_smart_threshold_get_temperature( smart_cmd_op(smart_threshold_get_supported_alarms, unsigned int, 0); +NDCTL_EXPORT unsigned int ndctl_cmd_smart_get_event_flags(struct ndctl_cmd *cmd) +{ +unsigned int alarm_flags, event_flags =0 ; + + alarm_flags =ndctl_cmd_smart_get_alarm_flags (cmd); +if (alarm_flags &ND_SMART_SPARE_TRIP ) + event_flags |=ND_EVENT_SPARES_REMAINING ; +if (alarm_flags &ND_SMART_MTEMP_TRIP ) + event_flags |=ND_EVENT_MEDIA_TEMPERATURE ; +if (alarm_flags &ND_SMART_CTEMP_TRIP ) + event_flags |=ND_EVENT_CTRL_TEMPERATURE ; +if (ndctl_cmd_smart_get_shutdown_state (cmd)) + event_flags |=ND_EVENT_UNCLEAN_SHUTDOWN ; + +return event_flags; +} +#define smart_cmd_set_op (op) \ NDCTL_EXPORT int ndctl_cmd_##op(struct ndctl_cmd *cmd, unsigned int val) \ { \
ndctl/libndctl.h +6 -0
@@ -240,6 +240,11 @@ int ndctl_cmd_ars_stat_get_flag_overflow(struct ndctl_cmd *ars_stat);#define ND_SMART_NON_CRITICAL_HEALTH (1 << 0)#define ND_SMART_CRITICAL_HEALTH (1 << 1)#define ND_SMART_FATAL_HEALTH (1 << 2) +#define ND_EVENT_SPARES_REMAINING (1 << 0) +#define ND_EVENT_MEDIA_TEMPERATURE (1 << 1) +#define ND_EVENT_CTRL_TEMPERATURE (1 << 2) +#define ND_EVENT_HEALTH_STATE (1 << 3) +#define ND_EVENT_UNCLEAN_SHUTDOWN (1 << 4)struct ndctl_cmd *ndctl_dimm_cmd_new_smart (struct ndctl_dimm *dimm);unsigned int ndctl_cmd_smart_get_flags (struct ndctl_cmd *cmd);
@@ -253,6 +258,7 @@ unsigned int ndctl_cmd_smart_get_life_used(struct ndctl_cmd *cmd);unsigned int ndctl_cmd_smart_get_shutdown_state (struct ndctl_cmd *cmd);unsigned int ndctl_cmd_smart_get_shutdown_count (struct ndctl_cmd *cmd);unsigned int ndctl_cmd_smart_get_vendor_size (struct ndctl_cmd *cmd); +unsigned int ndctl_cmd_smart_get_event_flags (struct ndctl_cmd *cmd);unsigned char *ndctl_cmd_smart_get_vendor_data (struct ndctl_cmd *cmd);struct ndctl_cmd *ndctl_dimm_cmd_new_smart_threshold (struct ndctl_dimm *dimm);unsigned int ndctl_cmd_smart_threshold_get_alarm_control (struct ndctl_cmd *cmd);
ndctl/monitor.c new file +531 -0
531 lines not on this page · raw message
ndctl/ndctl.c +1 -0
@@ -89,6 +89,7 @@ static struct cmd_struct commands[] = { { "wait-scrub", cmd_wait_scrub }, { "start-scrub", cmd_start_scrub }, { "list", cmd_list }, + { "monitor", cmd_monitor}, { "help", cmd_help }, #ifdef ENABLE_TEST { "test", cmd_test },
util/filter.h +9 -0
@@ -13,6 +13,7 @@#ifndef _UTIL_FILTER_H_#define _UTIL_FILTER_H_#include <stdbool.h> +#include <ccan/list/list.h> struct ndctl_bus *util_bus_filter (struct ndctl_bus *bus,const char *ident); struct ndctl_region *util_region_filter(struct ndctl_region *region,
@@ -50,6 +51,13 @@ struct list_filter_arg {unsigned long flags; }; +struct monitor_filter_arg { +struct list_head dimms; +int maxfd_dimm; +int num_dimm; +unsigned long flags; +}; +/* * struct util_filter_ctx - control and callbacks for util_filter_walk() * ->filter_bus() and ->filter_region() return bool because the
@@ -67,6 +75,7 @@ struct util_filter_ctx {union {void *arg;struct list_filter_arg *list; +struct monitor_filter_arg *monitor; }; };
Signature · 7 lines
2.18.0 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitor
Quoted 69 lines · QI Fuli
Ndctl monitor is used for monitoring the smart events of nvdimm DIMMs. When a smart event fires, monitor will output the notifications which include dimm health status and evnet informations to syslog or a logfile by setting [--logfile] option. The notifications follow json format and can be consumed by log collectors like Fluentd.
The objects to monitor can be selected by setting [--dimm] [--region] [--namespace] [--bus] options and the event type can be filtered by setting [--dimm-event] option. These options support multiple space-separated arguments.
Ndctl monitor can be forked as a daemon by using [--daemon] option, such as:
# ndctl monitor --daemon --logfile /var/log/ndctl/monitor.logSigned-off-by QI Fuli <[email protected]>--- builtin.h | 1 + ndctl/Makefile.am | 3 +- ndctl/lib/libndctl.sym | 1 + ndctl/lib/smart.c | 17 ++ ndctl/libndctl.h | 6 + ndctl/monitor.c | 531 +++++++++++++++++++++++++++++++++++++++++ ndctl/ndctl.c | 1 + util/filter.h | 9 + 8 files changed, 568 insertions(+), 1 deletion(-) create mode 100644 ndctl/monitor.cbuiltin.h +1
-0@@ -39,6 +39,7 @@ int cmd_inject_error(int argc, const char **argv, void *ctx);int cmd_wait_scrub (int argc,const char **argv,void *ctx);int cmd_start_scrub (int argc,const char **argv,void *ctx);int cmd_list (int argc,const char **argv,void *ctx); +int cmd_monitor (int argc,const char **argv,void *ctx);#ifdef ENABLE_TEST int cmd_test (int argc,const char **argv,void *ctx);#endif ndctl/Makefile.am +2
-1@@ -16,7 +16,8 @@ ndctl_SOURCES = ndctl.c \ util/json-smart.c \ util/json-firmware.c \ inject-error.c \ - inject-smart.c + inject-smart.c \ + monitor.c if ENABLE_DESTRUCTIVE ndctl_SOURCES += ../test/blk_namespaces.c \ndctl/lib/libndctl.sym +1
-0@@ -366,4 +366,5 @@ global: ndctl_namespace_inject_error2; ndctl_namespace_uninject_error2; ndctl_cmd_ars_stat_get_flag_overflow; + ndctl_cmd_smart_get_event_flags; } LIBNDCTL_15;ndctl/lib/smart.c +0
-0
ndctl/lib/smart.c NDCTL_EXPORT unsigned int ndctl_cmd_smart_threshold_get_temperature( · line 104
Quoted 4 lines
ndctl/lib/smart.c +1
-0@@ -101,6 +101,23 @@ NDCTL_EXPORT unsigned int ndctl_cmd_smart_threshold_get_temperature( smart_cmd_op(smart_threshold_get_supported_alarms, unsigned int, 0); +NDCTL_EXPORT unsigned int ndctl_cmd_smart_get_event_flags(struct ndctl_cmd *cmd)
My expectation for this ndctl_*_get_event_flags() api was to have it be:
ndctl_dimm_get_event_flags()
...and with that in place get rid of the 'struct monitor_dimm' object. Push everything to be retrieved through api calls against a 'struct ndctl_dimm' object. In other words, the usage of 'struct ndctl_cmd' should be hidden and all monitor operations should be done in terms of 'struct ndctl_dimm' helper calls.
This allows for other objects like regions and namespace to grow an event flags api in the future:
ndctl_namespace_get_event_flags()
ndctl_region_get_event_flags()
ndctl_bus_get_event_flags()
...where those objects don't have any relationship with a 'struct ndctl_cmd', so neither should dimm event monitoring, at least not for the library api that ndctl-monitor is using.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
RE: [PATCH v9 1/3] ndctl, monitor: add ndctl monitor
Quoted 85 lines
-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Sunday, July 8, 2018 5:06 AM
To: Qi, Fuli/斉 福利 <[email protected]>
Cc: linux-nvdimm <[email protected]>
Subject: Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitorQuoted 72 lines · QI Fuli
Ndctl monitor is used for monitoring the smart events of nvdimm DIMMs. When a smart event fires, monitor will output the notifications which include dimm health status and evnet informations to syslog or a logfile by setting [--logfile] option. The notifications follow json format and can be consumed by log collectors like Fluentd.
The objects to monitor can be selected by setting [--dimm] [--region] [--namespace] [--bus] options and the event type can be filtered by setting [--dimm-event] option. These options support multiple space-separated arguments.
Ndctl monitor can be forked as a daemon by using [--daemon] option, such as:
# ndctl monitor --daemon --logfile /var/log/ndctl/monitor.logSigned-off-by QI Fuli <[email protected]>--- builtin.h | 1 + ndctl/Makefile.am | 3 +- ndctl/lib/libndctl.sym | 1 + ndctl/lib/smart.c | 17 ++ ndctl/libndctl.h | 6 + ndctl/monitor.c | 531 +++++++++++++++++++++++++++++++++++++++++ ndctl/ndctl.c | 1 + util/filter.h | 9 + 8 files changed, 568 insertions(+), 1 deletion(-) create mode 100644
ndctl/monitor.cbuiltin.h +0
-0@@ -39,6 +39,7 @@ int cmd_inject_error(int argc, const char **argv,void *ctx); int
cmd_wait_scrub(int argc, const char **argv, void *ctx); intcmd_start_scrub(int argc, const char **argv, void *ctx); intcmd_list(int argc, const char **argv, void *ctx); +intcmd_monitor(int argc, const char **argv, void *ctx);
#ifdefENABLE_TEST
intcmd_test(int argc, const char **argv, void *ctx); #endif diff
--git a/ndctl/Makefile.am b/ndctl/Makefile.am index d22a379..7dbf223 100644ndctl/Makefile.am +2
-1@@ -16,7 +16,8 @@ ndctl_SOURCES = ndctl.c \ util/json-smart.c \ util/json-firmware.c \ inject-error.c \ - inject-smart.c + inject-smart.c \ + monitor.c if ENABLE_DESTRUCTIVE ndctl_SOURCES += ../test/blk_namespaces.c \ diff --gita/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index e939993..f64df56 100644
ndctl/lib/libndctl.sym +1
-0@@ -366,4 +366,5 @@ global: ndctl_namespace_inject_error2; ndctl_namespace_uninject_error2; ndctl_cmd_ars_stat_get_flag_overflow; + ndctl_cmd_smart_get_event_flags; } LIBNDCTL_15;ndctl/lib/smart.c index renamed from ndctl/lib/smart.c +0
-00455252..90a65d0 100644
ndctl/lib/smart.c +0
-0@@ -101,6 +101,23 @@ NDCTL_EXPORT unsigned intndctl_cmd_smart_threshold_get_temperature(
smart_cmd_op(smart_threshold_get_supported_alarms, unsigned int, 0);ndctl/lib/smart.c
Quoted 2 lines
ndctl/lib/smart.c +2
-0+NDCTL_EXPORT unsigned int ndctl_cmd_smart_get_event_flags(struct +ndctl_cmd *cmd)My expectation for this ndctl_*_get_event_flags() api was to have it be:
Quoted 8 lines
ndctl_dimm_get_event_flags()...and with that in place get rid of the 'struct
monitor_dimm' object. Push everything to be retrieved through api calls against a 'structndctl_dimm' object. In other words, the usage of 'structndctl_cmd'
should be hidden and all monitor operations should be done in terms of 'structndctl_dimm' helper calls.
Hi Dan,
Thanks for your comments.
In the v9 of monitor, I use the 'struct ndctl_cmd' object in the following places:
ndctl_cmd_smart_get_flags(struct ndctl_cmd *cmd)
ndctl_cmd_smart_get_health(struct ndctl_cmd *cmd)
ndctl_cmd_smart_get_event_flags(struct ndctl_cmd *cmd)
Is it that you want to hide all of the 'struct ndctl_cmd' objects and add the following 'struct ndctl_dimm' helper calls?
ndctl_dimm_get_flags(struct ndctl_dimm *dimm)
ndctl_dimm_get_health(struct ndctl_dimm *dimm)
ndctl_dimm_get_event_flags(struct ndctl_dimm *dimm)
Quoted 11 lines
This allows for other objects like regions and namespace to grow an event flags api in the future:
ndctl_namespace_get_event_flags()
ndctl_region_get_event_flags()
ndctl_bus_get_event_flags()...where those objects don't have any relationship with a 'struct
ndctl_cmd', so neither should dimm event monitoring, at least not for the library api that ndctl-monitor is using.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitor
Quoted 93 lines · Fuli
Quoted 85 lines
-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Sunday, July 8, 2018 5:06 AM
To: Qi, Fuli/斉 福利 <[email protected]>
Cc: linux-nvdimm <[email protected]>
Subject: Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitorQuoted 72 lines · QI Fuli
Ndctl monitor is used for monitoring the smart events of nvdimm DIMMs. When a smart event fires, monitor will output the notifications which include dimm health status and evnet informations to syslog or a logfile by setting [--logfile] option. The notifications follow json format and can be consumed by log collectors like Fluentd.
The objects to monitor can be selected by setting [--dimm] [--region] [--namespace] [--bus] options and the event type can be filtered by setting [--dimm-event] option. These options support multiple space-separated arguments.
Ndctl monitor can be forked as a daemon by using [--daemon] option, such as:
# ndctl monitor --daemon --logfile /var/log/ndctl/monitor.logSigned-off-by QI Fuli <[email protected]>--- builtin.h | 1 + ndctl/Makefile.am | 3 +- ndctl/lib/libndctl.sym | 1 + ndctl/lib/smart.c | 17 ++ ndctl/libndctl.h | 6 + ndctl/monitor.c | 531 +++++++++++++++++++++++++++++++++++++++++ ndctl/ndctl.c | 1 + util/filter.h | 9 + 8 files changed, 568 insertions(+), 1 deletion(-) create mode 100644
ndctl/monitor.cbuiltin.h +0
-0@@ -39,6 +39,7 @@ int cmd_inject_error(int argc, const char **argv,void *ctx); int
cmd_wait_scrub(int argc, const char **argv, void *ctx); intcmd_start_scrub(int argc, const char **argv, void *ctx); intcmd_list(int argc, const char **argv, void *ctx); +intcmd_monitor(int argc, const char **argv, void *ctx);
#ifdefENABLE_TEST
intcmd_test(int argc, const char **argv, void *ctx); #endif diff
--git a/ndctl/Makefile.am b/ndctl/Makefile.am index d22a379..7dbf223 100644ndctl/Makefile.am +2
-1@@ -16,7 +16,8 @@ ndctl_SOURCES = ndctl.c \ util/json-smart.c \ util/json-firmware.c \ inject-error.c \ - inject-smart.c + inject-smart.c \ + monitor.c if ENABLE_DESTRUCTIVE ndctl_SOURCES += ../test/blk_namespaces.c \ diff --gita/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index e939993..f64df56 100644
ndctl/lib/libndctl.sym +1
-0@@ -366,4 +366,5 @@ global: ndctl_namespace_inject_error2; ndctl_namespace_uninject_error2; ndctl_cmd_ars_stat_get_flag_overflow; + ndctl_cmd_smart_get_event_flags; } LIBNDCTL_15;ndctl/lib/smart.c index renamed from ndctl/lib/smart.c +0
-00455252..90a65d0 100644
ndctl/lib/smart.c +0
-0@@ -101,6 +101,23 @@ NDCTL_EXPORT unsigned intndctl_cmd_smart_threshold_get_temperature(
smart_cmd_op(smart_threshold_get_supported_alarms, unsigned int, 0);ndctl/lib/smart.c
Quoted 2 lines
ndctl/lib/smart.c +2
-0+NDCTL_EXPORT unsigned int ndctl_cmd_smart_get_event_flags(struct +ndctl_cmd *cmd)My expectation for this ndctl_*_get_event_flags() api was to have it be:
Quoted 8 lines
ndctl_dimm_get_event_flags()...and with that in place get rid of the 'struct
monitor_dimm' object. Push everything to be retrieved through api calls against a 'structndctl_dimm' object. In other words, the usage of 'structndctl_cmd'
should be hidden and all monitor operations should be done in terms of 'structndctl_dimm' helper calls.
Quoted 8 lines
Hi Dan,
Thanks for your comments.In the v9 of monitor, I use the 'struct
ndctl_cmd' object in the following places:
ndctl_cmd_smart_get_flags(struct ndctl_cmd *cmd)
ndctl_cmd_smart_get_health(struct ndctl_cmd *cmd)
ndctl_cmd_smart_get_event_flags(struct ndctl_cmd *cmd)
Is it that you want to hide all of the 'structndctl_cmd' objects and add the following 'structndctl_dimm' helper calls?
I'm primarily reacting to:
+struct monitor_dimm {
+ struct ndctl_dimm *dimm; + int health_eventfd; + unsigned int health; + unsigned int event_flags; + struct list_node list;
+};
Which is effectively duplicating ndctl_dimm internal data.
Quoted 3 lines
ndctl_dimm_get_flags(struct ndctl_dimm *dimm)ndctl_dimm_get_health(struct ndctl_dimm *dimm)ndctl_dimm_get_event_flags(struct ndctl_dimm *dimm)
I understand why we need ndctl_dimm_get_event_flags() since that tells you what events have fired. Why do we need the other 2? If the event has fired then the monitor proceeds to call util_dimm_health_to_json. Is that not sufficient?
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
RE: [PATCH v9 1/3] ndctl, monitor: add ndctl monitor
Quoted 126 lines
-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Monday, July 9, 2018 3:04 PM
To: Qi, Fuli/斉 福利 <[email protected]>
Cc: linux-nvdimm <[email protected]>
Subject: Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitorQuoted 87 lines · Fuli
Quoted 87 lines
-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Sunday, July 8, 2018 5:06 AM
To: Qi, Fuli/斉 福利 <[email protected]>
Cc: linux-nvdimm <[email protected]>
Subject: Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitorQuoted 74 lines · QI Fuli
Ndctl monitor is used for monitoring the smart events of nvdimm DIMMs. When a smart event fires, monitor will output the notifications which include dimm health status and evnet informations to syslog or a logfile by setting [--logfile] option. The notifications follow json format and can be consumed by log collectors like Fluentd.
The objects to monitor can be selected by setting [--dimm] [--region] [--namespace] [--bus] options and the event type can be filtered by setting [--dimm-event] option. These options support multiple space-separated arguments.
Ndctl monitor can be forked as a daemon by using [--daemon] option, such as:
# ndctl monitor --daemon --logfile /var/log/ndctl/monitor.logSigned-off-by QI Fuli <[email protected]>--- builtin.h | 1 + ndctl/Makefile.am | 3 +- ndctl/lib/libndctl.sym | 1 + ndctl/lib/smart.c | 17 ++ ndctl/libndctl.h | 6 + ndctl/monitor.c | 531 +++++++++++++++++++++++++++++++++++++++++ ndctl/ndctl.c | 1 + util/filter.h | 9 + 8 files changed, 568 insertions(+), 1 deletion(-) create mode100644
ndctl/monitor.cbuiltin.h +0
-0@@ -39,6 +39,7 @@ int cmd_inject_error(int argc, const char **argv,void *ctx); int
cmd_wait_scrub(int argc, const char **argv, void *ctx); intcmd_start_scrub(int argc, const char **argv, void *ctx); intcmd_list(int argc, const char **argv, void *ctx); +intcmd_monitor(int argc, const char **argv, void *ctx);
#ifdefENABLE_TEST
intcmd_test(int argc, const char **argv, void *ctx); #endif diff
--git a/ndctl/Makefile.am b/ndctl/Makefile.am index d22a379..7dbf223
100644ndctl/Makefile.am +2
-1@@ -16,7 +16,8 @@ ndctl_SOURCES = ndctl.c \ util/json-smart.c \ util/json-firmware.c \ inject-error.c \ - inject-smart.c + inject-smart.c \ + monitor.c if ENABLE_DESTRUCTIVE ndctl_SOURCES += ../test/blk_namespaces.c \ diff --gita/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index e939993..f64df56 100644
ndctl/lib/libndctl.sym +1
-0@@ -366,4 +366,5 @@ global: ndctl_namespace_inject_error2; ndctl_namespace_uninject_error2; ndctl_cmd_ars_stat_get_flag_overflow; + ndctl_cmd_smart_get_event_flags; } LIBNDCTL_15;ndctl/lib/smart.c index renamed from ndctl/lib/smart.c +0
-00455252..90a65d0 100644
ndctl/lib/smart.c +0
-0@@ -101,6 +101,23 @@ NDCTL_EXPORT unsigned intndctl_cmd_smart_threshold_get_temperature(
smart_cmd_op(smart_threshold_get_supported_alarms, unsigned int,
0);ndctl/lib/smart.c
Quoted 2 lines
ndctl/lib/smart.c +2
-0+NDCTL_EXPORT unsigned int ndctl_cmd_smart_get_event_flags(struct +ndctl_cmd *cmd)My expectation for this ndctl_*_get_event_flags() api was to have it be:
Quoted 4 lines
Quoted 4 lines
ndctl_dimm_get_event_flags()...and with that in place get rid of the 'struct
monitor_dimm' object. Push everything to be retrieved through api calls against a 'structndctl_dimm'object.
Quoted 4 lines
Quoted 4 lines
In other words, the usage of 'struct
ndctl_cmd'
should be hidden and all monitor operations should be done in terms of 'structndctl_dimm' helper calls.Quoted 8 lines
Hi Dan,
Thanks for your comments.In the v9 of monitor, I use the 'struct
ndctl_cmd' object in the following places:
ndctl_cmd_smart_get_flags(struct ndctl_cmd *cmd)ndctl_cmd_smart_get_health(struct ndctl_cmd *cmd)ndctl_cmd_smart_get_event_flags(struct ndctl_cmd *cmd)Is it
that you want to hide all of the 'structndctl_cmd' objects and add the following'struct
ndctl_dimm' helper calls?I'm primarily reacting to:
ndctl/monitor.c new file +7
-0+struct monitor_dimm { +struct ndctl_dimm *dimm; +int health_eventfd; +unsigned int health; +unsigned int event_flags; +struct list_node list; +};Which is effectively duplicating
ndctl_dimminternal data.
Quoted 9 lines
Quoted 3 lines
ndctl_dimm_get_flags(struct ndctl_dimm *dimm)ndctl_dimm_get_health(struct ndctl_dimm *dimm)ndctl_dimm_get_event_flags(struct ndctl_dimm *dimm)I understand why we need
ndctl_dimm_get_event_flags()since that tells you what events have fired. Why do we need the other 2? If the event has fired then the monitor proceeds to callutil_dimm_health_to_json.
Is that not sufficient?
About ndctl_dimm_get_flags(struct ndctl_dimm *dimm), I think the ND_SMART_ALARM_VALID of DIMM should be confirmed before monitor start. If the smart alarm invalid, the DIMM no need to monitor.
Also, the monitor should know the health of DIMM when it starts. When an event fires, then compare it with current health of DIMM. Therefore, we could know if the dimm-health-state event fired.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitor
Quoted 135 lines · Fuli
Quoted 126 lines
-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Monday, July 9, 2018 3:04 PM
To: Qi, Fuli/斉 福利 <[email protected]>
Cc: linux-nvdimm <[email protected]>
Subject: Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitorQuoted 87 lines · Fuli
Quoted 87 lines
-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Sunday, July 8, 2018 5:06 AM
To: Qi, Fuli/斉 福利 <[email protected]>
Cc: linux-nvdimm <[email protected]>
Subject: Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitorQuoted 74 lines · QI Fuli
Ndctl monitor is used for monitoring the smart events of nvdimm DIMMs. When a smart event fires, monitor will output the notifications which include dimm health status and evnet informations to syslog or a logfile by setting [--logfile] option. The notifications follow json format and can be consumed by log collectors like Fluentd.
The objects to monitor can be selected by setting [--dimm] [--region] [--namespace] [--bus] options and the event type can be filtered by setting [--dimm-event] option. These options support multiple space-separated arguments.
Ndctl monitor can be forked as a daemon by using [--daemon] option, such as:
# ndctl monitor --daemon --logfile /var/log/ndctl/monitor.logSigned-off-by QI Fuli <[email protected]>--- builtin.h | 1 + ndctl/Makefile.am | 3 +- ndctl/lib/libndctl.sym | 1 + ndctl/lib/smart.c | 17 ++ ndctl/libndctl.h | 6 + ndctl/monitor.c | 531 +++++++++++++++++++++++++++++++++++++++++ ndctl/ndctl.c | 1 + util/filter.h | 9 + 8 files changed, 568 insertions(+), 1 deletion(-) create mode100644
ndctl/monitor.cbuiltin.h +0
-0@@ -39,6 +39,7 @@ int cmd_inject_error(int argc, const char **argv,void *ctx); int
cmd_wait_scrub(int argc, const char **argv, void *ctx); intcmd_start_scrub(int argc, const char **argv, void *ctx); intcmd_list(int argc, const char **argv, void *ctx); +intcmd_monitor(int argc, const char **argv, void *ctx);
#ifdefENABLE_TEST
intcmd_test(int argc, const char **argv, void *ctx); #endif diff
--git a/ndctl/Makefile.am b/ndctl/Makefile.am index d22a379..7dbf223
100644ndctl/Makefile.am +2
-1@@ -16,7 +16,8 @@ ndctl_SOURCES = ndctl.c \ util/json-smart.c \ util/json-firmware.c \ inject-error.c \ - inject-smart.c + inject-smart.c \ + monitor.c if ENABLE_DESTRUCTIVE ndctl_SOURCES += ../test/blk_namespaces.c \ diff --gita/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index e939993..f64df56 100644
ndctl/lib/libndctl.sym +1
-0@@ -366,4 +366,5 @@ global: ndctl_namespace_inject_error2; ndctl_namespace_uninject_error2; ndctl_cmd_ars_stat_get_flag_overflow; + ndctl_cmd_smart_get_event_flags; } LIBNDCTL_15;ndctl/lib/smart.c index renamed from ndctl/lib/smart.c +0
-00455252..90a65d0 100644
ndctl/lib/smart.c +0
-0@@ -101,6 +101,23 @@ NDCTL_EXPORT unsigned intndctl_cmd_smart_threshold_get_temperature(
smart_cmd_op(smart_threshold_get_supported_alarms, unsigned int,
0);ndctl/lib/smart.c
Quoted 2 lines
ndctl/lib/smart.c +2
-0+NDCTL_EXPORT unsigned int ndctl_cmd_smart_get_event_flags(struct +ndctl_cmd *cmd)My expectation for this ndctl_*_get_event_flags() api was to have it be:
Quoted 4 lines
Quoted 4 lines
ndctl_dimm_get_event_flags()...and with that in place get rid of the 'struct
monitor_dimm' object. Push everything to be retrieved through api calls against a 'structndctl_dimm'object.
Quoted 4 lines
Quoted 4 lines
In other words, the usage of 'struct
ndctl_cmd'
should be hidden and all monitor operations should be done in terms of 'structndctl_dimm' helper calls.Quoted 8 lines
Hi Dan,
Thanks for your comments.In the v9 of monitor, I use the 'struct
ndctl_cmd' object in the following places:
ndctl_cmd_smart_get_flags(struct ndctl_cmd *cmd)ndctl_cmd_smart_get_health(struct ndctl_cmd *cmd)ndctl_cmd_smart_get_event_flags(struct ndctl_cmd *cmd)Is it
that you want to hide all of the 'structndctl_cmd' objects and add the following'struct
ndctl_dimm' helper calls?I'm primarily reacting to:
ndctl/monitor.c new file +7
-0+struct monitor_dimm { +struct ndctl_dimm *dimm; +int health_eventfd; +unsigned int health; +unsigned int event_flags; +struct list_node list; +};Which is effectively duplicating
ndctl_dimminternal data.Quoted 9 lines
Quoted 3 lines
ndctl_dimm_get_flags(struct ndctl_dimm *dimm)ndctl_dimm_get_health(struct ndctl_dimm *dimm)ndctl_dimm_get_event_flags(struct ndctl_dimm *dimm)I understand why we need
ndctl_dimm_get_event_flags()since that tells you what events have fired. Why do we need the other 2? If the event has fired then the monitor proceeds to callutil_dimm_health_to_json.
Is that not sufficient?
Quoted 4 lines
About
ndctl_dimm_get_flags(struct ndctl_dimm *dimm), I think theND_SMART_ALARM_VALIDof DIMM should be confirmed before monitor start. If the smart alarm invalid, the DIMM no need to monitor.
Also, the monitor should know the health of DIMM when it starts. When an event fires, then compare it with current health of DIMM. Therefore, we could know if the dimm-health-state event fired.
Ok, but that sounds like two APIs. _get_supported_flags() and _get_flags().
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
RE: [PATCH v9 1/3] ndctl, monitor: add ndctl monitor
Quoted 146 lines
-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Monday, July 9, 2018 3:27 PM
To: Qi, Fuli/斉 福利 <[email protected]>
Cc: linux-nvdimm <[email protected]>
Subject: Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitorQuoted 15 lines · Fuli
Quoted 15 lines
-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Monday, July 9, 2018 3:04 PM
To: Qi, Fuli/斉 福利 <[email protected]>
Cc: linux-nvdimm <[email protected]>
Subject: Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitorQuoted 7 lines · Fuli
Quoted 7 lines
-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Sunday, July 8, 2018 5:06 AM
To: Qi, Fuli/斉 福利 <[email protected]>
Cc: linux-nvdimm <[email protected]>
Subject: Re: [PATCH v9 1/3] ndctl, monitor: add ndctl monitorQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · QI Fuli
Quoted 5 lines
Ndctl monitor is used for monitoring the smart events of nvdimm DIMMs. When a smart event fires, monitor will output the notifications which include dimm health status and evnet informations to syslog or a logfile by setting [--logfile] option. The notifications follow json format and can be consumed by log collectors like
Fluentd.
Quoted 116 lines
Quoted 116 lines
Quoted 75 lines
Quoted 75 lines
Quoted 69 lines
The objects to monitor can be selected by setting [--dimm] [--region] [--namespace] [--bus] options and the event type can be filtered by setting [--dimm-event] option. These options support multiple space-separated arguments.
Ndctl monitor can be forked as a daemon by using [--daemon] option, such as:
# ndctl monitor --daemon --logfile /var/log/ndctl/monitor.logSigned-off-by QI Fuli <[email protected]>--- builtin.h | 1 + ndctl/Makefile.am | 3 +- ndctl/lib/libndctl.sym | 1 + ndctl/lib/smart.c | 17 ++ ndctl/libndctl.h | 6 + ndctl/monitor.c | 531 +++++++++++++++++++++++++++++++++++++++++ ndctl/ndctl.c | 1 + util/filter.h | 9 + 8 files changed, 568 insertions(+), 1 deletion(-) create mode100644
ndctl/monitor.cbuiltin.h +1
-0@@ -39,6 +39,7 @@ int cmd_inject_error(int argc, const char **argv, void *ctx); int cmd_wait_scrub(int argc, const char **argv,void *ctx);int cmd_start_scrub (int argc,const char **argv,void *ctx);int cmd_list (int argc,const char **argv,void *ctx); +int cmd_monitor (int argc,const char **argv,void *ctx);#ifdef ENABLE_TEST int cmd_test (int argc,const char **argv,void *ctx);#endif ndctl/Makefile.am index renamed from ndctl/Makefile.am +0
-0d22a379..7dbf223
100644ndctl/Makefile.am +2
-1@@ -16,7 +16,8 @@ ndctl_SOURCES = ndctl.c \ util/json-smart.c \ util/json-firmware.c \ inject-error.c \ - inject-smart.c + inject-smart.c \ + monitor.c if ENABLE_DESTRUCTIVE ndctl_SOURCES += ../test/blk_namespaces.c \ diff --gita/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index e939993..f64df56 100644
ndctl/lib/libndctl.sym +1
-0@@ -366,4 +366,5 @@ global: ndctl_namespace_inject_error2; ndctl_namespace_uninject_error2; ndctl_cmd_ars_stat_get_flag_overflow; + ndctl_cmd_smart_get_event_flags; } LIBNDCTL_15;ndctl/lib/smart.c index renamed from ndctl/lib/smart.c +0
-00455252..90a65d0 100644
ndctl/lib/smart.c +0
-0@@ -101,6 +101,23 @@ NDCTL_EXPORT unsigned intndctl_cmd_smart_threshold_get_temperature(
smart_cmd_op(smart_threshold_get_supported_alarms, unsigned
int, 0);ndctl/lib/smart.c
Quoted 3 lines
ndctl/lib/smart.c +3
-0+NDCTL_EXPORT unsigned int +ndctl_cmd_smart_get_event_flags (struct +ndctl_cmd *cmd)My expectation for this ndctl_*_get_event_flags() api was to have it be:
Quoted 4 lines
Quoted 4 lines
ndctl_dimm_get_event_flags()...and with that in place get rid of the 'struct
monitor_dimm' object. Push everything to be retrieved through api calls against a 'structndctl_dimm'object.
Quoted 7 lines
Quoted 4 lines
In other words, the usage of 'struct
ndctl_cmd' should be hidden and all monitor operations should be done in terms of 'structndctl_dimm' helper calls.Hi Dan,
Thanks for your comments.Quoted 6 lines
In the v9 of monitor, I use the 'struct
ndctl_cmd' object in the following places:
ndctl_cmd_smart_get_flags(struct ndctl_cmd *cmd)ndctl_cmd_smart_get_health(struct ndctl_cmd *cmd)ndctl_cmd_smart_get_event_flags(struct ndctl_cmd *cmd)Is
it that you want to hide all of the 'structndctl_cmd' objects and add the following'struct
ndctl_dimm' helper calls?I'm primarily reacting to:
ndctl/monitor.c new file +7
-0+struct monitor_dimm { +struct ndctl_dimm *dimm; +int health_eventfd; +unsigned int health; +unsigned int event_flags; +struct list_node list; +};Which is effectively duplicating
ndctl_dimminternal data.Quoted 3 lines
ndctl_dimm_get_flags(struct ndctl_dimm *dimm)ndctl_dimm_get_health(struct ndctl_dimm *dimm)ndctl_dimm_get_event_flags(struct ndctl_dimm *dimm)I understand why we need
ndctl_dimm_get_event_flags()since that tells you what events have fired. Why do we need the other 2? If the event has fired then the monitor proceeds to callutil_dimm_health_to_json. Is that not sufficient?
Quoted 9 lines
Quoted 1 line
About
ndctl_dimm_get_flags(struct ndctl_dimm *dimm), I think the
ND_SMART_ALARM_VALIDof DIMM should be confirmed before monitor start.Quoted 2 lines
If the smart alarm invalid, the DIMM no need to monitor.
Also, the monitor should know the health of DIMM when it starts. When an eventfires, then compare it with current health of DIMM.
Quoted 1 line
Therefore, we could know if the dimm-health-state event fired.
Ok, but that sounds like two APIs.
_get_supported_flags()and_get_flags().
Ok, I will add both _get_supported_flags() and _get_flags(). Thank you very much.
Qi
_______________________________________________
Linux-nvdimm mailing list [email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v9 2/3 ndctl, monitor: add main ndctl monitor configuration file
In reply to QI FuliThis patch adds the main configuration file(/etc/ndctl/monitor.conf) of ndctl monitor. It contains the configuration directives that give ndctl monitor instructions. Users can change the configuration by editing this file or using [--config-file] option to override this file. The changed value will work after restart ndctl monitor service.
--- ndctl/Makefile.am | 5 ++ ndctl/monitor.c | 115 +++++++++++++++++++++++++++++++++++++++++++++ ndctl/monitor.conf | 41 ++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 ndctl/monitor.conf
ndctl/Makefile.am +5 -0
@@ -42,3 +42,8 @@ ndctl_SOURCES += ../test/libndctl.c \ ../test/multi-pmem.c \ ../test/core.c endif + +monitor_config_file = monitor.conf +monitor_configdir = /etc/ndctl/ +monitor_config_DATA = $(monitor_config_file) +EXTRA_DIST += $(monitor_config_file)
ndctl/monitor.c +115 -0
139 lines not on this page · raw message
ndctl/monitor.conf new file +41 -0
41 lines not on this page · raw message
Signature · 7 lines
2.18.0 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v9 3/3 ndctl, monitor: add the unit file of systemd for ndctl-monitor service
In reply to QI FuliThis patch adds the systemd unit file for ndctl-monitor service. The systemd unit directory can be configured by setting environment variable "--with-systemd-unit-dir[=DIR]".
A monitor daemon can be started as a system service:
# systemctl start ndctl-monitor.service
--- autogen.sh | 3 ++- configure.ac | 22 ++++++++++++++++++++++ ndctl/Makefile.am | 4 ++++ ndctl/ndctl-monitor.service | 7 +++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 ndctl/ndctl-monitor.service
autogen.sh +2 -1
@@ -17,7 +17,8 @@ libdir() { args="--prefix=/usr \ --sysconfdir=/etc \ ---libdir=$(libdir /usr/lib)" +--libdir=$(libdir /usr/lib) \ +--with-systemd-unit-dir" echo echo "----------------------------------------------------------------"
configure.ac +22 -0
@@ -143,6 +143,27 @@ AC_CHECK_FUNCS([ \ secure_getenv\ ]) +PKG_PROG_PKG_CONFIG +AC_ARG_WITH([systemd-unit-dir], + AS_HELP_STRING([--with-systemd-unit-dir[=DIR]], + [Directory for systemd service files]), + [], + [with_systemd_unit_dir=yes]) + +if test "x$with_systemd_unit_dir" = "xyes"; then + def_systemd_unit_dir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) + if test "x$def_systemd_unit_dir" = "x"; then + AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package]) + with_systemd_unit_dir=no + else + with_systemd_unit_dir="$def_systemd_unit_dir" + fi +fi + +AS_IF([test "x$with_systemd_unit_dir" != "xno"], + [AC_SUBST([systemd_unitdir], [$with_systemd_unit_dir])]) +AM_CONDITIONAL([ENABLE_SYSTEMD_UNIT_DIR], [test "x$with_systemd_unit_dir" != "xno"]) + my_CFLAGS="\ -Wall \ -Wchar-subscripts \
@@ -184,6 +205,7 @@ AC_MSG_RESULT([ sysconfdir: ${sysconfdir} libdir: ${libdir} includedir: ${includedir} + systemd-unit-dir: ${systemd_unitdir} compiler: ${CC} cflags: ${CFLAGS}
ndctl/Makefile.am +4 -0
@@ -47,3 +47,7 @@ monitor_config_file = monitor.conf monitor_configdir = /etc/ndctl/ monitor_config_DATA = $(monitor_config_file) EXTRA_DIST += $(monitor_config_file) + +if ENABLE_SYSTEMD_UNIT_DIR +systemd_unit_DATA = ndctl-monitor.service +endif
ndctl/ndctl-monitor.service new file +7 -0
@@ -0,0 +1,7 @@ +[Unit] +Description=Ndctl Monitor Daemon + +[Service] +Type=forking +ExecStart=/usr/bin/ndctl monitor --daemon +ExecStop=/bin/kill ${MAINPID}
Signature · 7 lines
2.18.0 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm