> -----Original Message-----
> From: Dan Williams [mailto:firstname.lastname@example.org]
> Sent: Thursday, March 15, 2018 3:20 AM
> To: Qi, Fuli/斉 福利 <qi.fuli(a)jp.fujitsu.com>
> Cc: linux-nvdimm <linux-nvdimm(a)lists.01.org>
> Subject: Re: [RFC PATCH v4] ndctl: monitor: add ndctl monitor daemon
> On Tue, Mar 13, 2018 at 4:33 AM, QI Fuli <qi.fuli(a)jp.fujitsu.com> wrote:
> > This is the v4 patch for ndctl monitor daemon, a tiny daemon to monitor the
> > smart events of nvdimm DIMMs. Users can run a monitor as a one-shot
> > or a daemon in background by using the [--daemon] option. DIMMs to monitor
> > can be selected by [--dimm] [--bus] [--region] [--namespace] options.
> > When a smart event fires, monitor daemon will log the notification which
> > including dimm health status to syslog or a logfile by setting [--log] option.
> > The notification follows json format and can be consumed by log collectors
> > like Fluented.
> > For example, a monitor daemon can be started by the following command:
> > # ndctl monitor --dimm nmem1 --log /var/log/monitor.log --daemon
> > Then check the monitor daemon status by using systemd:
> > # systemctl status ndctl-monitor(a)daemon-name.service
> > To stop the monitor daemon by:
> > # systemctl stop ndctl-monitor(a)daemon-name.service
> > Also, a monitor daemon can be started by systemd:
> > # systemctl start ndctl-monitor.service
> > Which monitors all dimms.
> > In this implemention, when a ndctl monitor starts with [--daemon] option, all
> > the arguments will be saved into a temp file named as daemon-name and placed
> > under /etc/sysconfig/ndctl/ directory. The temp file would be used as an
> > EnvironmentFile by systemd, and it would be deleted automatically when the
> > systemd service is stopped.
> The monitors started by hand should be kept separate from the monitors
> started by systemd. The default monitor started by systemd should get
> its configuration from /etc/ndctl.conf, and we should otherwise have a
> --conf-file option to the monitor to override the default
> configuration. Any other monitors started outside of the systemd
> should remain independent.
I prefer to add an EnvironmentFile like /etc/sysconfig/ndctl/monitor to systemd
rather than add a configuration file. According to , environment variable
substitution is supported in systemd.service, so we can define the variables through
In this fashion, we do not need to add any extra codes to parse the configuration file.
In this case, [--conf-file] option is not necessary either.
According to , sytemd units can be instantiated from a template file, thus we only
need to add a template unit file in advance.
If user wants to run multiple monitors with different configurations, they can
them by adding multiple EnvironmentFiles, like
Then the monitors can be started by command like
"# systemctl start ndctl-monitor@<monitor1...n>.service".
When the monitors started by hand, it will do not need any configuration files,
because we can add options and parameters directly.
This seems to needlessly tie ndctl to systemd, it should be able to
operate without requiring systemd. I expect it would be
straightforward to copy the configuration file implementation from