Skip to contentSkip to conversation

Some fixups and improvements ndctl monitor

PATCH In review QI Fuli 3 participants 17 messages Aug 7, 2018 – Aug 10, 2018

Subsystems (2)
lore
Share & tools
lore

QI Fuli

author
#0 lore raw

cover Some fixups and improvements ndctl monitor

Fix a couple of issues about log collection, and add [Install] section to systemd unit file of ndclt-monitor.

---
QI Fuli (4):
ndctl, monitor: fix the lack of detection of invalid path of log file ndctl, monitor: set default log destination to syslog if "--daemon" is specified ndctl, monitor: add timestamp and pid to log messages in log_file() ndctl, monitor: add [Install] Section to systemd unit file of ndctl-monitor

 Documentation/ndctl/ndctl-monitor.txt | 16 +++++++++++++++-
 ndctl/monitor.c                       | 27 ++++++++++++++++++++++++---
 ndctl/monitor.conf                    |  2 ++
 ndctl/ndctl-monitor.service           |  3 +++
 4 files changed, 44 insertions(+), 4 deletions(-)
Signature · 7 lines
2.18.0


_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
author
#1 lore raw

PATCH 1/4 ndctl, monitor: fix the lack of detection of invalid path of log file

Currently the monitor can be started even with an invalid path of log file. This patch adds a detection of invalid path of log file when starting monitor. If the path of log file is invalid, the monitor will refuse to be started.

---
 ndctl/monitor.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
ndctl/monitor.c +10 -1
index f10384b..bf1f1d3 100644
@@ -603,6 +603,7 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 	struct util_filter_ctx fctx = { 0 };
 	struct monitor_filter_arg mfa = { 0 };
 	int i, rc;
+	FILE *f;
 
 	argc = parse_options_prefix(argc, argv, prefix, options, u, 0);
 	for (i = 0; i < argc; i++) {
@@ -630,8 +631,16 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
 		else if (strncmp(monitor.log, "./standard", 10) == 0)
 			; /*default, already set */
-		else
+		else {
+			f = fopen(monitor.log, "a+");
+			if (!f) {
+				error("open %s failed\n", monitor.log);
+				rc = -errno;
+				goto out;
+			}
+			fclose(f);
 			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_file);
+		}
 	}
 
 	if (monitor.daemon) {
Signature · 7 lines
2.18.0


_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Reviewed-by on v1 1/4
#2 lore raw

Re: [ndctl PATCH 1/4] ndctl, monitor: fix the lack of detection of invalid path of log file

Hi Qi,

Quoted 26 lines · QI Fuli

Currently the monitor can be started even with an invalid path of log file. This patch adds a detection of invalid path of log file when starting monitor. If the path of log file is invalid, the monitor will refuse to be started.

---
 ndctl/monitor.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
ndctl/monitor.c +1 -1
index f10384b..bf1f1d3 100644
@@ -603,6 +603,7 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 	struct util_filter_ctx fctx = { 0 };
 	struct monitor_filter_arg mfa = { 0 };
 	int i, rc;
+	FILE *f;
 
 	argc = parse_options_prefix(argc, argv, prefix, options, u, 0);
 	for (i = 0; i < argc; i++) {
@@ -630,8 +631,16 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
 		else if (strncmp(monitor.log, "./standard", 10) == 0)
 			; /*default, already set */
-		else

ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 643

Quoted 10 lines
ndctl/monitor.c +9 -0
+		else {
+			f = fopen(monitor.log, "a+");
+			if (!f) {
+				error("open %s failed\n", monitor.log);
+				rc = -errno;
+				goto out;
+			}
+			fclose(f);
 			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_file);
+		}

In log_file(), the log file does fallback to syslog if the fopen() fails. In my understanding here is that the fallback is needed to save in case of the monitor.log in trouble for example, the parent directory is removed. And, the new fopen() check, you have added by this patch, to inform the invalid log path for users.

Is my understanding correct? If so, make sense to me. Please feel free to add:

Thanks,
Masa

ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 646

Quoted 4 lines
ndctl/monitor.c +0 -0
 	}
 
 	if (monitor.daemon) {

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#3 lore raw

RE: [ndctl PATCH 1/4] ndctl, monitor: fix the lack of detection of invalid path of log file

Quoted 38 lines

-----Original Message-----
From: Masayoshi Mizuma [mailto:[email protected]]
Sent: Wednesday, August 8, 2018 4:06 AM
To: Qi, Fuli/斉 福利 <[email protected]>; [email protected]
Subject: Re: [ndctl PATCH 1/4] ndctl, monitor: fix the lack of detection of invalid path of log file

Hi Qi,

Quoted 28 lines · QI Fuli

Currently the monitor can be started even with an invalid path of log file. This patch adds a detection of invalid path of log file when starting monitor. If the path of log file is invalid, the monitor will refuse to be started.

---
 ndctl/monitor.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
ndctl/monitor.c index f10384b..bf1f1d3 renamed from ndctl/monitor.c +0 -0

100644

ndctl/monitor.c +3 -1
@@ -603,6 +603,7 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 	struct util_filter_ctx fctx = { 0 };
 	struct monitor_filter_arg mfa = { 0 };
 	int i, rc;
+	FILE *f;
 
 	argc = parse_options_prefix(argc, argv, prefix, options, u, 0);
 	for (i = 0; i < argc; i++) {
@@ -630,8 +631,16 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
 		else if (strncmp(monitor.log, "./standard", 10) == 0)
 			; /*default, already set */
-		else
+		else {
+			f = fopen(monitor.log, "a+");
Quoted 9 lines

ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 643

Quoted 8 lines
ndctl/monitor.c +7 -0
+			if (!f) {
+				error("open %s failed\n", monitor.log);
+				rc = -errno;
+				goto out;
+			}
+			fclose(f);
 			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_file);
+		}

Masa,

Thanks for your comments.

Quoted 6 lines

In log_file(), the log file does fallback to syslog if the fopen() fails. In my understanding here is that the fallback is needed to save in case of the monitor.log in trouble for example, the parent directory is removed. And, the new fopen() check, you have added by this patch, to inform the invalid log path for users.

Yes, this is what I wanted to implement.

Quoted 5 lines

Is my understanding correct? If so, make sense to me. Please feel free to add:

Thanks,
QI

Quoted 8 lines

Thanks,
Masa

Quoted 4 lines
ndctl/monitor.c +0 -0
 	}
 
 	if (monitor.daemon) {

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#4 lore raw

PATCH 2/4 ndctl, monitor: set default log destination to syslog if "--daemon" is specified

In reply to QI Fuli

When running monitor as a daemon, if the log destination is "standard" or a relative path for log file, the messages will not be able to be logged. Sometimes, users may not notice that the default log destination is "standard" when they start monitor daemon by systemctl, so they will lose messages. This patch is used to fix the unfriendly interface. When running monitor as a daemon, the default log destination will be changed to syslog. Also, the messages will be forwarded to syslog if the log destination is a relative path for log file.

---
 Documentation/ndctl/ndctl-monitor.txt | 16 +++++++++++++++-
 ndctl/monitor.c                       |  5 ++++-
 ndctl/monitor.conf                    |  2 ++
 3 files changed, 21 insertions(+), 2 deletions(-)
Documentation/ndctl/ndctl-monitor.txt +15 -1
index 1cba9ea..9a8d76b 100644
@@ -67,7 +67,21 @@ OPTIONS
 
 -l <file | syslog | standard>::
 --log=<file | syslog | standard>::
-	Output notifications to <file>, syslog or standard output.
+	Send log messages to the specified destination.
++
+--
+<file>::
+	Send log messages to specified <file>. When fopen() is not able
+	to open <file>, log messages will be forwarded to syslog.
+syslog::
+	Send messages to syslog.
+standard::
+	Send messages to standard output.
+--
++
+The default log destination is 'syslog' if "--daemon" is specified,
+otherwise 'standard'. Note that standard and relative path for <file>
+will not work if "--daemon" is specified.
 
 -c::
 --config-file=::
ndctl/monitor.c +4 -1
index bf1f1d3..2f3d751 100644
@@ -93,7 +93,8 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const char *file,
 	f = fopen(monitor.log, "a+");
 	if (!f) {
 		ndctl_set_log_fn(ctx, log_syslog);
-		err(ctx, "open logfile %s failed\n", monitor.log);
+		err(ctx, "open logfile %s failed, forward messages to syslog\n",
+				monitor.log);
 		did_fail = 1;
 		notice(ctx, "%s\n", buf);
 		goto end;
@@ -644,6 +645,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 	}
 
 	if (monitor.daemon) {
+		if (!monitor.log || strncmp(monitor.log, "./", 2) == 0)
+			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
 		if (daemon(0, 0) != 0) {
 			err((struct ndctl_ctx *)ctx, "daemon start failed\n");
 			goto out;
ndctl/monitor.conf +2 -0
index 857aadf..934e2c0 100644
@@ -38,4 +38,6 @@
 # to standard output (log=standard) or to write into a special file (log=<file>)
 # by setting key "log". If this value is in conflict with the value of
 # [--log=<value>] option, this value will be ignored.
+# Note: Setting value to "standard" or relative path for <file> will not work
+# when running moniotr as a daemon.
 # log = /var/log/ndctl/monitor.log
Signature · 7 lines
2.18.0


_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#5 lore raw

Re: [ndctl PATCH 2/4] ndctl, monitor: set default log destination to syslog if "--daemon" is specified

Hi Qi,

Quoted 57 lines · QI Fuli

When running monitor as a daemon, if the log destination is "standard" or a relative path for log file, the messages will not be able to be logged. Sometimes, users may not notice that the default log destination is "standard" when they start monitor daemon by systemctl, so they will lose messages. This patch is used to fix the unfriendly interface. When running monitor as a daemon, the default log destination will be changed to syslog. Also, the messages will be forwarded to syslog if the log destination is a relative path for log file.

---
 Documentation/ndctl/ndctl-monitor.txt | 16 +++++++++++++++-
 ndctl/monitor.c                       |  5 ++++-
 ndctl/monitor.conf                    |  2 ++
 3 files changed, 21 insertions(+), 2 deletions(-)
Documentation/ndctl/ndctl-monitor.txt +15 -1
index 1cba9ea..9a8d76b 100644
@@ -67,7 +67,21 @@ OPTIONS
 
 -l <file | syslog | standard>::
 --log=<file | syslog | standard>::
-	Output notifications to <file>, syslog or standard output.
+	Send log messages to the specified destination.
++
+--
+<file>::
+	Send log messages to specified <file>. When fopen() is not able
+	to open <file>, log messages will be forwarded to syslog.
+syslog::
+	Send messages to syslog.
+standard::
+	Send messages to standard output.
+--
++
+The default log destination is 'syslog' if "--daemon" is specified,
+otherwise 'standard'. Note that standard and relative path for <file>
+will not work if "--daemon" is specified.
 
 -c::
 --config-file=::
ndctl/monitor.c +2 -1
index bf1f1d3..2f3d751 100644
@@ -93,7 +93,8 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const char *file,
 	f = fopen(monitor.log, "a+");
 	if (!f) {
 		ndctl_set_log_fn(ctx, log_syslog);
-		err(ctx, "open logfile %s failed\n", monitor.log);
+		err(ctx, "open logfile %s failed, forward messages to syslog\n",
+				monitor.log);
 		did_fail = 1;
 		notice(ctx, "%s\n", buf);
 		goto end;

ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 647

Quoted 3 lines
ndctl/monitor.c +0 -0
@@ -644,6 +645,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 	}
 
 	if (monitor.daemon) {

Why don't you add './standard' check? Like as:

                if (strncmp(monitor.log, "./standard", 10) == 0)
                        error("daemon doesn't work for 'standard' log option");
                        goto out;

Thanks,
Masa

Quoted 12 lines
ndctl/monitor.c +2 -0
+		if (!monitor.log || strncmp(monitor.log, "./", 2) == 0)
+			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
 
 		if (daemon(0, 0) != 0) {
 			err((struct ndctl_ctx *)ctx, "daemon start failed\n");
ndctl/monitor.c +0 -0
 			goto out;
ndctl/monitor.conf +0 -0
index 857aadf..934e2c0 100644

ndctl/monitor.conf line 43

Quoted 6 lines
ndctl/monitor.conf +2 -0
@@ -38,4 +38,6 @@
 # to standard output (log=standard) or to write into a special file (log=<file>)
 # by setting key "log". If this value is in conflict with the value of
 # [--log=<value>] option, this value will be ignored.
+# Note: Setting value to "standard" or relative path for <file> will not work
+# when running moniotr as a daemon.
 # log = /var/log/ndctl/monitor.log

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#6 lore raw

RE: [ndctl PATCH 2/4] ndctl, monitor: set default log destination to syslog if "--daemon" is specified

Quoted 72 lines

-----Original Message-----
From: Masayoshi Mizuma [mailto:[email protected]]
Sent: Wednesday, August 8, 2018 4:30 AM
To: Qi, Fuli/斉 福利 <[email protected]>; [email protected]
Subject: Re: [ndctl PATCH 2/4] ndctl, monitor: set default log destination to syslog if "--daemon" is specified

Hi Qi,

Quoted 7 lines · QI Fuli

When running monitor as a daemon, if the log destination is "standard" or a relative path for log file, the messages will not be able to be logged. Sometimes, users may not notice that the default log destination is "standard" when they start monitor daemon by systemctl, so they will lose messages. This patch is used to fix the unfriendly interface. When running monitor as a daemon, the default log destination will be changed to syslog. Also, the messages will be forwarded to syslog if the log destination is

a relative path for log file.

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const

Quoted 41 lines
---
 Documentation/ndctl/ndctl-monitor.txt | 16 +++++++++++++++-
 ndctl/monitor.c                       |  5 ++++-
 ndctl/monitor.conf                    |  2 ++
 3 files changed, 21 insertions(+), 2 deletions(-)
Documentation/ndctl/ndctl-monitor.txt +15 -1
index 1cba9ea..9a8d76b 100644
@@ -67,7 +67,21 @@ OPTIONS
 
 -l <file | syslog | standard>::
 --log=<file | syslog | standard>::
-	Output notifications to <file>, syslog or standard output.
+	Send log messages to the specified destination.
++
+--
+<file>::
+	Send log messages to specified <file>. When fopen() is not able
+	to open <file>, log messages will be forwarded to syslog.
+syslog::
+	Send messages to syslog.
+standard::
+	Send messages to standard output.
+--
++
+The default log destination is 'syslog' if "--daemon" is specified,
+otherwise 'standard'. Note that standard and relative path for <file>
+will not work if "--daemon" is specified.
 
 -c::
 --config-file=::
ndctl/monitor.c index bf1f1d3..2f3d751 renamed from ndctl/monitor.c +0 -0

100644

ndctl/monitor.c +0 -0
@@ -93,7 +93,8 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const

char *file,

Quoted 12 lines
ndctl/monitor.c +2 -1
 	f = fopen(monitor.log, "a+");
 	if (!f) {
 		ndctl_set_log_fn(ctx, log_syslog);
-		err(ctx, "open logfile %s failed\n", monitor.log);
+		err(ctx, "open logfile %s failed, forward messages to syslog\n",
+				monitor.log);
 		did_fail = 1;
 		notice(ctx, "%s\n", buf);
 		goto end;
@@ -644,6 +645,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 	}
 
Quoted 8 lines

ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 647

Quoted 1 line
ndctl/monitor.c +0 -0
 	if (monitor.daemon) {

Why don't you add './standard' check? Like as:

                if (strncmp(monitor.log, "./standard", 10) == 0)
                        error("daemon doesn't work for 'standard' log option");
                        goto out;

Hi Masa,

Thank you for your comment.

When running monitor as a daemon, the messages will not be able to be logged in following cases.
a) Users set the log destination to standard by using [--log] option or setting value of "log" in config file.
b) The log destination is standard by default.
c) Users set the log destination to a relative path of log file by using [--log] option or setting value of "log" in config file.

The './standard' check will only works for case a).

Also, it would be more friendly to set a default log destination to monitor daemon.

Thanks,
QI

Quoted 6 lines

Thanks,
Masa

Quoted 2 lines
ndctl/monitor.c +2 -0
+		if (!monitor.log || strncmp(monitor.log, "./", 2) == 0)
+			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
Quoted 16 lines
Quoted 12 lines
ndctl/monitor.c +0 -0
 		if (daemon(0, 0) != 0) {
 			err((struct ndctl_ctx *)ctx, "daemon start failed\n");
 			goto out;
ndctl/monitor.conf index renamed from ndctl/monitor.conf +0 -0

857aadf..934e2c0 100644

ndctl/monitor.conf +0 -0
@@ -38,4 +38,6 @@
 # to standard output (log=standard) or to write into a special file

(log=<file>) # by setting key "log". If this value is in conflict with the value of # [--log=<value>] option, this value will be ignored.

ndctl/monitor.conf

Quoted 3 lines
ndctl/monitor.conf +2 -0
+# Note: Setting value to "standard" or relative path for <file> will
+not work # when running moniotr as a daemon.
 # log = /var/log/ndctl/monitor.log

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#7 lore raw

Re: [ndctl PATCH 2/4] ndctl, monitor: set default log destination to syslog if "--daemon" is specified

HiQi,

On 08/07/2018 09:31 PM, Qi, Fuli wrote:
...

Quoted 71 lines
Quoted 63 lines · QI Fuli
Quoted 7 lines

When running monitor as a daemon, if the log destination is "standard" or a relative path for log file, the messages will not be able to be logged. Sometimes, users may not notice that the default log destination is "standard" when they start monitor daemon by systemctl, so they will lose messages. This patch is used to fix the unfriendly interface. When running monitor as a daemon, the default log destination will be changed to syslog. Also, the messages will be forwarded to syslog if the log destination is

a relative path for log file.

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const

Quoted 41 lines
---
 Documentation/ndctl/ndctl-monitor.txt | 16 +++++++++++++++-
 ndctl/monitor.c                       |  5 ++++-
 ndctl/monitor.conf                    |  2 ++
 3 files changed, 21 insertions(+), 2 deletions(-)
Documentation/ndctl/ndctl-monitor.txt +15 -1
index 1cba9ea..9a8d76b 100644
@@ -67,7 +67,21 @@ OPTIONS
 
 -l <file | syslog | standard>::
 --log=<file | syslog | standard>::
-	Output notifications to <file>, syslog or standard output.
+	Send log messages to the specified destination.
++
+--
+<file>::
+	Send log messages to specified <file>. When fopen() is not able
+	to open <file>, log messages will be forwarded to syslog.
+syslog::
+	Send messages to syslog.
+standard::
+	Send messages to standard output.
+--
++
+The default log destination is 'syslog' if "--daemon" is specified,
+otherwise 'standard'. Note that standard and relative path for <file>
+will not work if "--daemon" is specified.
 
 -c::
 --config-file=::
ndctl/monitor.c index bf1f1d3..2f3d751 renamed from ndctl/monitor.c +0 -0

100644

ndctl/monitor.c +0 -0
@@ -93,7 +93,8 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const

char *file,

Quoted 12 lines
ndctl/monitor.c +2 -1
 	f = fopen(monitor.log, "a+");
 	if (!f) {
 		ndctl_set_log_fn(ctx, log_syslog);
-		err(ctx, "open logfile %s failed\n", monitor.log);
+		err(ctx, "open logfile %s failed, forward messages to syslog\n",
+				monitor.log);
 		did_fail = 1;
 		notice(ctx, "%s\n", buf);
 		goto end;
@@ -644,6 +645,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 	}
 
Quoted 8 lines

ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 647

Quoted 1 line
ndctl/monitor.c +0 -0
 	if (monitor.daemon) {

Why don't you add './standard' check? Like as:

                if (strncmp(monitor.log, "./standard", 10) == 0)
                        error("daemon doesn't work for 'standard' log option");
                        goto out;
Quoted 8 lines

Hi Masa,

Thank you for your comment.

When running monitor as a daemon, the messages will not be able to be logged in following cases.
a) Users set the log destination to standard by using [--log] option or setting value of "log" in config file.

b) The log destination is standard by default.

Ummm... is this right behavior...? If the monitor running as a daemon, shouldn't the default log destination be standard...?
How about the following change?

ndctl/monitor.c +5 -2
index f10384b..3778334 100644
@@ -611,8 +611,11 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
        if (argc)
                usage_with_options(u, options);
 
-       /* default to log_standard */
-       ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_standard);
+       /* Set default log destination */
+       if (monitor.daemon)
+               ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
+       else
+               ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_standard);
 
        if (monitor.verbose)
                ndctl_set_log_priority((struct ndctl_ctx *)ctx, LOG_DEBUG);
Quoted 3 lines

c) Users set the log destination to a relative path of log file by using [--log] option or setting value of "log" in config file.

The './standard' check will only works for case a).

I'm sorry, but I'm not clear about c)... The './standard' check should not have the effect in case of c), right?
We should check the following three cases for monitor daemon, right?

1. '--log standard' option, or
2. In config file 'log = standard'
3. Both 1. and 2. is not set (default behavior).

If I miss something, sorry about that...

Thanks,
Masa

Quoted 29 lines

Also, it would be more friendly to set a default log destination to monitor daemon.

Thanks,
QI

Quoted 22 lines

Thanks,
Masa

Quoted 18 lines
ndctl/monitor.c +2 -0
+		if (!monitor.log || strncmp(monitor.log, "./", 2) == 0)
+			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
 
 		if (daemon(0, 0) != 0) {
 			err((struct ndctl_ctx *)ctx, "daemon start failed\n");
ndctl/monitor.c +0 -0
 			goto out;
ndctl/monitor.conf index renamed from ndctl/monitor.conf +0 -0

857aadf..934e2c0 100644

ndctl/monitor.conf +0 -0
@@ -38,4 +38,6 @@
 # to standard output (log=standard) or to write into a special file

(log=<file>) # by setting key "log". If this value is in conflict with the value of # [--log=<value>] option, this value will be ignored.

ndctl/monitor.conf +2 -0
+# Note: Setting value to "standard" or relative path for <file> will
+not work # when running moniotr as a daemon.
 # log = /var/log/ndctl/monitor.log

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#8 lore raw

RE: [ndctl PATCH 2/4] ndctl, monitor: set default log destination to syslog if "--daemon" is specified

Quoted 90 lines

-----Original Message-----
From: Masayoshi Mizuma [mailto:[email protected]]
Sent: Wednesday, August 8, 2018 10:35 PM
To: Qi, Fuli/斉 福利 <[email protected]>; [email protected]
Subject: Re: [ndctl PATCH 2/4] ndctl, monitor: set default log destination to syslog if "--daemon" is specified

HiQi,

On 08/07/2018 09:31 PM, Qi, Fuli wrote:
...

Quoted 74 lines
Quoted 66 lines · QI Fuli
Quoted 8 lines

When running monitor as a daemon, if the log destination is "standard" or a relative path for log file, the messages will not be able to be logged. Sometimes, users may not notice that the default log destination is "standard" when they start monitor daemon by systemctl, so they will lose messages. This patch is used to fix the unfriendly interface. When running monitor as a daemon, the default log destination will be changed to syslog. Also, the messages will be forwarded to syslog if the log destination is

a relative path for log file.

Quoted 42 lines
---
 Documentation/ndctl/ndctl-monitor.txt | 16 +++++++++++++++-
 ndctl/monitor.c                       |  5 ++++-
 ndctl/monitor.conf                    |  2 ++
 3 files changed, 21 insertions(+), 2 deletions(-)
Documentation/ndctl/ndctl-monitor.txt +15 -1
index 1cba9ea..9a8d76b 100644
@@ -67,7 +67,21 @@ OPTIONS
 
 -l <file | syslog | standard>::
 --log=<file | syslog | standard>::
-	Output notifications to <file>, syslog or standard output.
+	Send log messages to the specified destination.
++
+--
+<file>::
+	Send log messages to specified <file>. When fopen() is not able
+	to open <file>, log messages will be forwarded to syslog.
+syslog::
+	Send messages to syslog.
+standard::
+	Send messages to standard output.
+--
++
+The default log destination is 'syslog' if "--daemon" is specified,
+otherwise 'standard'. Note that standard and relative path for
+<file> will not work if "--daemon" is specified.
 
 -c::
 --config-file=::
ndctl/monitor.c index renamed from ndctl/monitor.c +0 -0

bf1f1d3..2f3d751
100644

ndctl/monitor.c +0 -0
@@ -93,7 +93,8 @@ static void log_file(struct ndctl_ctx *ctx, int
Quoted 1 line

priority, const

char *file,

Quoted 12 lines
ndctl/monitor.c +2 -1
 	f = fopen(monitor.log, "a+");
 	if (!f) {
 		ndctl_set_log_fn(ctx, log_syslog);
-		err(ctx, "open logfile %s failed\n", monitor.log);
+		err(ctx, "open logfile %s failed, forward messages to syslog\n",
+				monitor.log);
 		did_fail = 1;
 		notice(ctx, "%s\n", buf);
 		goto end;
@@ -644,6 +645,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 	}
 
Quoted 8 lines

ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 647

Quoted 1 line
ndctl/monitor.c +0 -0
 	if (monitor.daemon) {

Why don't you add './standard' check? Like as:

                if (strncmp(monitor.log, "./standard", 10) == 0)
                        error("daemon doesn't work for 'standard' log option");
                        goto out;
Quoted 5 lines

Hi Masa,

Thank you for your comment.

When running monitor as a daemon, the messages will not be able to be logged in

Quoted 8 lines

following cases.

Quoted 1 line

a) Users set the log destination to standard by using [--log] option or setting value

of "log" in config file.

Quoted 1 line

b) The log destination is standard by default.

Ummm... is this right behavior...? If the monitor running as a daemon, shouldn't the default log destination be standard...?

No, If the monitor runs as a daemon, the default log destination should not be standard. The default log destination should be syslog, otherwise the messages will not be able to be logged like now.

Quoted 7 lines

How about the following change?

ndctl/monitor.c +0 -0
@@ -611,8 +611,11 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
        if (argc)

ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 619

Quoted 10 lines
ndctl/monitor.c +5 -2
                usage_with_options(u, options);
 
-       /* default to log_standard */
-       ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_standard);
+       /* Set default log destination */
+       if (monitor.daemon)
+               ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
+       else
+               ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_standard);
 

I think there is no need to additionally check the monitor.daemon, and we can just set the default log destination to standard here. The log destination can be changed to syslog by the following code if monitor.log is NULL, which means case b).

	if (monitor.daemon) {

+ if (!monitor.log || strncmp(monitor.log, "./", 2) == 0)
+ ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);

Quoted 10 lines
ndctl/monitor.c +0 -0
        if (monitor.verbose)
                ndctl_set_log_priority((struct ndctl_ctx *)ctx, LOG_DEBUG);
Quoted 2 lines

c) Users set the log destination to a relative path of log file by using [--log] option

or setting value of "log" in config file.

Quoted 2 lines

The './standard' check will only works for case a).

I'm sorry, but I'm not clear about c)... The './standard' check should not have the effect in case of c), right?

Yes, Let me use a sample to clarify the case c).

 # ndctl monitor --daemon --log ./monitor.log
In this case, the messages are not able to be logged.
Quoted 6 lines

We should check the following three cases for monitor daemon, right?

1. '--log standard' option, or
2. In config file 'log = standard'
3. Both 1. and 2. is not set (default behavior).

Yes, and apart from the cases above, we should also check the case c).

Thanks,
QI

Quoted 35 lines

If I miss something, sorry about that...

Thanks,
Masa

Quoted 29 lines

Also, it would be more friendly to set a default log destination to monitor daemon.

Thanks,
QI

Quoted 22 lines

Thanks,
Masa

Quoted 18 lines
ndctl/monitor.c +2 -0
+		if (!monitor.log || strncmp(monitor.log, "./", 2) == 0)
+			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
 
 		if (daemon(0, 0) != 0) {
 			err((struct ndctl_ctx *)ctx, "daemon start failed\n");
ndctl/monitor.c +0 -0
 			goto out;
ndctl/monitor.conf index renamed from ndctl/monitor.conf +0 -0

857aadf..934e2c0 100644

ndctl/monitor.conf +0 -0
@@ -38,4 +38,6 @@
 # to standard output (log=standard) or to write into a special file

(log=<file>) # by setting key "log". If this value is in conflict with the value of # [--log=<value>] option, this value will be ignored.

ndctl/monitor.conf +2 -0
+# Note: Setting value to "standard" or relative path for <file>
+will not work # when running moniotr as a daemon.
 # log = /var/log/ndctl/monitor.log

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reviewed-by
#9 lore raw

Re: [ndctl PATCH 2/4] ndctl, monitor: set default log destination to syslog if "--daemon" is specified

Hi Qi,

On 08/08/2018 11:59 AM, Qi, Fuli wrote:
...

Quoted 37 lines
Quoted 37 lines
Quoted 28 lines
Quoted 20 lines
Quoted 7 lines
ndctl/monitor.c index renamed from ndctl/monitor.c +0 -0

bf1f1d3..2f3d751
100644

ndctl/monitor.c +0 -0
@@ -93,7 +93,8 @@ static void log_file(struct ndctl_ctx *ctx, int

priority, const

char *file,

Quoted 12 lines
ndctl/monitor.c +2 -1
 	f = fopen(monitor.log, "a+");
 	if (!f) {
 		ndctl_set_log_fn(ctx, log_syslog);
-		err(ctx, "open logfile %s failed\n", monitor.log);
+		err(ctx, "open logfile %s failed, forward messages to syslog\n",
+				monitor.log);
 		did_fail = 1;
 		notice(ctx, "%s\n", buf);
 		goto end;
@@ -644,6 +645,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
 	}
 
Quoted 8 lines

ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 647

Quoted 1 line
ndctl/monitor.c +0 -0
 	if (monitor.daemon) {

Why don't you add './standard' check? Like as:

                if (strncmp(monitor.log, "./standard", 10) == 0)
                        error("daemon doesn't work for 'standard' log option");
                        goto out;
Quoted 5 lines

Hi Masa,

Thank you for your comment.

When running monitor as a daemon, the messages will not be able to be logged in

following cases.

Quoted 1 line

a) Users set the log destination to standard by using [--log] option or setting value

of "log" in config file.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

b) The log destination is standard by default.

Ummm... is this right behavior...? If the monitor running as a daemon, shouldn't the default log destination be standard...?

No, If the monitor runs as a daemon, the default log destination should not be standard. The default log destination should be syslog, otherwise the messages will not be able to be logged like now.

I see. This is what I want to say. Sorry for my explanation is not enough.

Quoted 23 lines
Quoted 8 lines

How about the following change?

ndctl/monitor.c +0 -0
@@ -611,8 +611,11 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
        if (argc)

ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 619

Quoted 10 lines
ndctl/monitor.c +5 -2
                usage_with_options(u, options);
 
-       /* default to log_standard */
-       ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_standard);
+       /* Set default log destination */
+       if (monitor.daemon)
+               ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
+       else
+               ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_standard);
 

I think there is no need to additionally check the monitor.daemon, and we can just set the default log destination to standard here. The log destination can be changed to syslog by the following code if monitor.log is NULL, which means case b).

	if (monitor.daemon) {

Review

Quoted 2 lines
(quoted diff) +2 -0
+		if (!monitor.log || strncmp(monitor.log, "./", 2) == 0)
+			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);

Ah, you are right, thanks.

Quoted 15 lines
Quoted 10 lines
ndctl/monitor.c +0 -0
        if (monitor.verbose)
                ndctl_set_log_priority((struct ndctl_ctx *)ctx, LOG_DEBUG);
Quoted 2 lines

c) Users set the log destination to a relative path of log file by using [--log] option

or setting value of "log" in config file.

Quoted 2 lines

The './standard' check will only works for case a).

I'm sorry, but I'm not clear about c)... The './standard' check should not have the effect in case of c), right?

Yes, Let me use a sample to clarify the case c).

 # ndctl monitor --daemon --log ./monitor.log
In this case, the messages are not able to be logged.
Quoted 7 lines
Quoted 6 lines

We should check the following three cases for monitor daemon, right?

1. '--log standard' option, or
2. In config file 'log = standard'
3. Both 1. and 2. is not set (default behavior).

Yes, and apart from the cases above, we should also check the case c).

OK, thanks! I'm clear now, so please feel free to add:

Thanks,
Masa

Quoted 40 lines

Thanks,
QI

Quoted 35 lines

If I miss something, sorry about that...

Thanks,
Masa

Quoted 29 lines

Also, it would be more friendly to set a default log destination to monitor daemon.

Thanks,
QI

Quoted 22 lines

Thanks,
Masa

Quoted 18 lines
ndctl/monitor.c +2 -0
+		if (!monitor.log || strncmp(monitor.log, "./", 2) == 0)
+			ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
 
 		if (daemon(0, 0) != 0) {
 			err((struct ndctl_ctx *)ctx, "daemon start failed\n");
ndctl/monitor.c +0 -0
 			goto out;
ndctl/monitor.conf index renamed from ndctl/monitor.conf +0 -0

857aadf..934e2c0 100644

ndctl/monitor.conf +0 -0
@@ -38,4 +38,6 @@
 # to standard output (log=standard) or to write into a special file

(log=<file>) # by setting key "log". If this value is in conflict with the value of # [--log=<value>] option, this value will be ignored.

ndctl/monitor.conf +2 -0
+# Note: Setting value to "standard" or relative path for <file>
+will not work # when running moniotr as a daemon.
 # log = /var/log/ndctl/monitor.log

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#10 lore raw

PATCH 3/4 ndctl, monitor: add timestamp and pid to log messages in log_file()

In reply to QI Fuli

This patch is used to add timestamp and process id to log messages when logging messages to a file.

---
 ndctl/monitor.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
ndctl/monitor.c +10 -1
index 2f3d751..d29e378 100644
@@ -84,6 +84,8 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const char *file,
 {
 	FILE *f;
 	char *buf;
+	struct timespec ts;
+	char timestamp[32];
 
 	if (vasprintf(&buf, format, args) < 0) {
 		fail("vasprintf error\n");
@@ -99,7 +101,14 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const char *file,
 		notice(ctx, "%s\n", buf);
 		goto end;
 	}
-	fprintf(f, "%s", buf);
+
+	if (priority != LOG_NOTICE) {
+		clock_gettime(CLOCK_REALTIME, &ts);
+		sprintf(timestamp, "%10ld.%09ld", ts.tv_sec, ts.tv_nsec);
+		fprintf(f, "[%s] [%d] %s", timestamp, getpid(), buf);
+	} else
+		fprintf(f, "%s", buf);
+
 	fflush(f);
 	fclose(f);
 end:
Signature · 7 lines
2.18.0


_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#11 lore raw

Re: [ndctl PATCH 3/4] ndctl, monitor: add timestamp and pid to log messages in log_file()

Hi Qi,

Quoted 22 lines · QI Fuli

This patch is used to add timestamp and process id to log messages when logging messages to a file.

---
 ndctl/monitor.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
ndctl/monitor.c +2 -0
index 2f3d751..d29e378 100644
@@ -84,6 +84,8 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const char *file,
 {
 	FILE *f;
 	char *buf;
+	struct timespec ts;
+	char timestamp[32];
 
 	if (vasprintf(&buf, format, args) < 0) {
 		fail("vasprintf error\n");

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const char *file, · line 105

Quoted 6 lines
ndctl/monitor.c +2 -1
@@ -99,7 +101,14 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const char *file,
 		notice(ctx, "%s\n", buf);
 		goto end;
 	}
-	fprintf(f, "%s", buf);
+
+	if (priority != LOG_NOTICE) {

Why is the timestamp not needed in case of LOG_NOTICE...?

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const char *file, · line 108

Quoted 3 lines
ndctl/monitor.c +3 -0
+		clock_gettime(CLOCK_REALTIME, &ts);
+		sprintf(timestamp, "%10ld.%09ld", ts.tv_sec, ts.tv_nsec);
+		fprintf(f, "[%s] [%d] %s", timestamp, getpid(), buf);

What is the pid for...?

Thanks,
Masa

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const char *file,

Quoted 6 lines
ndctl/monitor.c +3 -0
+	} else
+		fprintf(f, "%s", buf);
+>  	fflush(f);
 	fclose(f);
 end:
 

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#12 lore raw

RE: [ndctl PATCH 3/4] ndctl, monitor: add timestamp and pid to log messages in log_file()

Quoted 33 lines

-----Original Message-----
From: Masayoshi Mizuma [mailto:[email protected]]
Sent: Wednesday, August 8, 2018 3:40 AM
To: Qi, Fuli/斉 福利 <[email protected]>; [email protected]
Subject: Re: [ndctl PATCH 3/4] ndctl, monitor: add timestamp and pid to log messages in log_file()

Hi Qi,

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const

Quoted 22 lines · QI Fuli

This patch is used to add timestamp and process id to log messages when logging messages to a file.

---
 ndctl/monitor.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
ndctl/monitor.c index 2f3d751..d29e378 renamed from ndctl/monitor.c +0 -0

100644

ndctl/monitor.c +2 -0
@@ -84,6 +84,8 @@ static void log_file(struct ndctl_ctx *ctx, int
 priority, const char *file,  {
 	FILE *f;
 	char *buf;
+	struct timespec ts;
+	char timestamp[32];
 
 	if (vasprintf(&buf, format, args) < 0) {
 		fail("vasprintf error\n");
@@ -99,7 +101,14 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const

char *file,

Quoted 7 lines

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const char *file, · line 105

Quoted 6 lines
ndctl/monitor.c +2 -1
 		notice(ctx, "%s\n", buf);
 		goto end;
 	}
-	fprintf(f, "%s", buf);
+
+	if (priority != LOG_NOTICE) {

Hi Masa,

Thanks for your comments.

Quoted 1 line

Why is the timestamp not needed in case of LOG_NOTICE...?

Because LOG_NOTICE level is only used for smart event notification in monitor. Since the timestamp and pid are already added to json format messages by notify_dimm_event(), so there is no need to add them again.

Quoted 7 lines

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const char *file, · line 108

Quoted 4 lines
ndctl/monitor.c +3 -0
+		clock_gettime(CLOCK_REALTIME, &ts);
+		sprintf(timestamp, "%10ld.%09ld", ts.tv_sec, ts.tv_nsec);
+		fprintf(f, "[%s] [%d] %s", timestamp, getpid(), buf);

What is the pid for...?

Multiple monitor can be run at the same time and they may send messages to a common log file. In this case, the pid could help users to know the monitor where each message came from.

Thanks,
QI

Quoted 10 lines

Thanks,
Masa

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const char *file,

Quoted 6 lines
ndctl/monitor.c +3 -0
+	} else
+		fprintf(f, "%s", buf);
+>  	fflush(f);
 	fclose(f);
 end:
 

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reviewed-by
#13 lore raw

Re: [ndctl PATCH 3/4] ndctl, monitor: add timestamp and pid to log messages in log_file()

Quoted 42 lines · Fuli
Quoted 33 lines

-----Original Message-----
From: Masayoshi Mizuma [mailto:[email protected]]
Sent: Wednesday, August 8, 2018 3:40 AM
To: Qi, Fuli/斉 福利 <[email protected]>; [email protected]
Subject: Re: [ndctl PATCH 3/4] ndctl, monitor: add timestamp and pid to log messages in log_file()

Hi Qi,

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const

Quoted 22 lines · QI Fuli

This patch is used to add timestamp and process id to log messages when logging messages to a file.

---
 ndctl/monitor.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
ndctl/monitor.c index 2f3d751..d29e378 renamed from ndctl/monitor.c +0 -0

100644

ndctl/monitor.c +2 -0
@@ -84,6 +84,8 @@ static void log_file(struct ndctl_ctx *ctx, int
 priority, const char *file,  {
 	FILE *f;
 	char *buf;
+	struct timespec ts;
+	char timestamp[32];
 
 	if (vasprintf(&buf, format, args) < 0) {
 		fail("vasprintf error\n");
@@ -99,7 +101,14 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const

char *file,

Quoted 7 lines

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const char *file, · line 105

Quoted 6 lines
ndctl/monitor.c +2 -1
 		notice(ctx, "%s\n", buf);
 		goto end;
 	}
-	fprintf(f, "%s", buf);
+
+	if (priority != LOG_NOTICE) {

Hi Masa,

Quoted 7 lines

Thanks for your comments.

Quoted 1 line

Why is the timestamp not needed in case of LOG_NOTICE...?

Because LOG_NOTICE level is only used for smart event notification in monitor. Since the timestamp and pid are already added to json format messages by notify_dimm_event(), so there is no need to add them again.

I see, thanks.

Quoted 10 lines
Quoted 8 lines

ndctl/monitor.c static void log_file(struct ndctl_ctx *ctx, int priority, const char *file, · line 108

Quoted 5 lines
ndctl/monitor.c +3 -0
+		clock_gettime(CLOCK_REALTIME, &ts);
+		sprintf(timestamp, "%10ld.%09ld", ts.tv_sec, ts.tv_nsec);
+		fprintf(f, "[%s] [%d] %s", timestamp, getpid(), buf);

What is the pid for...?

Multiple monitor can be run at the same time and they may send messages to a common log file. In this case, the pid could help users to know the monitor where each message came from.

OK, got it.

Your patch is good to me. Please feel free to add:

Thanks,
Masa

Quoted 15 lines

Thanks,
QI

Quoted 10 lines

Thanks,
Masa

Quoted 6 lines
ndctl/monitor.c +3 -0
+	} else
+		fprintf(f, "%s", buf);
+>  	fflush(f);
 	fclose(f);
 end:
 

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#14 lore raw

PATCH 4/4 ndctl, monitor: add [Install] Section to systemd unit file of ndctl-monitor

In reply to QI Fuli

This patch is used to add "[Install]" section to systemd unit file of ndctl-monitor. Therefore, users can set ndctl-monitor unit enable.

---
 ndctl/ndctl-monitor.service | 3 +++
 1 file changed, 3 insertions(+)
ndctl/ndctl-monitor.service +3 -0
index 44f9326..342a1b1 100644
@@ -5,3 +5,6 @@ Description=Ndctl Monitor Daemon
 Type=forking
 ExecStart=/usr/bin/ndctl monitor --daemon
 ExecStop=/bin/kill ${MAINPID}
+
+[Install]
+WantedBy=multi-user.target
Signature · 7 lines
2.18.0


_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Reviewed-by on v1 4/4
#15 lore raw

Re: [ndctl PATCH 4/4] ndctl, monitor: add [Install] Section to systemd unit file of ndctl-monitor

Hi Qi,

Looks good to me. Please free to add:

Thanks,
Masa

Quoted 14 lines · QI Fuli

This patch is used to add "[Install]" section to systemd unit file of ndctl-monitor. Therefore, users can set ndctl-monitor unit enable.

---
 ndctl/ndctl-monitor.service | 3 +++
 1 file changed, 3 insertions(+)
ndctl/ndctl-monitor.service +0 -0
index 44f9326..342a1b1 100644

ndctl/ndctl-monitor.service Description=Ndctl Monitor Daemon · line 10

Quoted 6 lines
ndctl/ndctl-monitor.service +3 -0
@@ -5,3 +5,6 @@ Description=Ndctl Monitor Daemon
 Type=forking
 ExecStart=/usr/bin/ndctl monitor --daemon
 ExecStop=/bin/kill ${MAINPID}
+
+[Install]
+WantedBy=multi-user.target

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

maintainer
#16 lore raw
In reply to QI Fuli
Quoted 11 lines · QI Fuli

Fix a couple of issues about log collection, and add [Install] section to systemd unit file of ndclt-monitor.

---
QI Fuli (4):
ndctl, monitor: fix the lack of detection of invalid path of log file ndctl, monitor: set default log destination to syslog if "--daemon" is specified ndctl, monitor: add timestamp and pid to log messages in log_file() ndctl, monitor: add [Install] Section to systemd unit file of ndctl-monitor

Quoted 6 lines
 Documentation/ndctl/ndctl-monitor.txt | 16 +++++++++++++++-
 ndctl/monitor.c                       | 27 ++++++++++++++++++++++++---
 ndctl/monitor.conf                    |  2 ++
 ndctl/ndctl-monitor.service           |  3 +++
 4 files changed, 44 insertions(+), 4 deletions(-)

Hi Qi,

These look good, applied.

Thanks,
-Vishal
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm